begin process at 2012 05 29 18:21:17
  Trouver un code source :
 
dans
 
Accueil > Forum > 

Archive C/C++

 > 

Archives

 > 

API

 > 

PB EditBox


Derniers messages déposésPoser une question dans le forum ou lancer une discussion

PB EditBox

vendredi 30 mai 2003 à 16:15:14 | PB EditBox

SfyLer

Bonjour à tous !
J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je ne sait pas comment les editbox peuvent ecrire dans les variables IP et PORT.
Voici la source vous comprendrez mieu


#include "stdafx.h"
#include "resource.h"
#include <stdio.h>
#include <iostream.h>
#include <time.h>
#include <conio.h>
#include <istream.h>
#pragma comment(lib, "ws2_32.lib")
#include <winsock2.h>

#define MAX_LOADSTRING 100
#define ID_BUTTON 100
#define ID_EDITBOX 100

// Global Variables:
HINSTANCE hInst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text

// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;

// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_SCANNERBYSFYLER, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);

// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}

hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SCANNERBYSFYLER);

// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}

return msg.wParam;
}



//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCANNERBYSFYLER);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
wcex.lpszMenuName = (LPCSTR)IDC_SCANNERBYSFYLER;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);

return RegisterClassEx(&wcex);
}

//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // Store instance handle in our global variable

hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 180, 250, HWND_DESKTOP, NULL, hInstance, NULL);
HWND edithWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
10, 10, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
SetWindowText(edithWnd, "IP");

HWND edithWnd1 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
10, 50, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
SetWindowText(edithWnd1, "PORT");
// Création du bouton
HWND cmdhWnd = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT,
10, 150, 150, 30, hWnd, (HMENU)ID_BUTTON, hInstance, NULL);
SetWindowText(cmdhWnd, "Scan");

if (!hWnd)
{
return FALSE;
}

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);


return TRUE;
}

//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
if ((LOWORD(wParam) == ID_BUTTON) && (HIWORD(wParam) == BN_CLICKED))
{
MessageBox(hWnd, "Scan en cours", "Scanner", MB_OK|MB_ICONINFORMATION);

WSADATA WSAData; // tout les prog de
WSAStartup(MAKEWORD(2,0),&WSAData);

SOCKET sock;

SOCKADDR_IN sin;
//ICI JAIMERAIS QUE CE SOIT LES EDIT BOX QUI REMPLISSE IP ET PORT
sin.sin_addr.s_addr = inet_addr(IP); // definit les propriétés
sin.sin_family = AF_INET; // de la socket
sin.sin_port = htons(PORT);

sock = socket(AF_INET,SOCK_STREAM,0);
n = connect(sock,(SOCKADDR *)&sin,sizeof(sin));
if(n == 0) // si on peut se connecter (donc si le port est ouvert)
{
MessageBox(hWnd, "Le port est ouvert", "Scanner", MB_OK|MB_ICONINFORMATION);
}
else
{
MessageBox(hWnd, "Le port est fermé", "Scanner", MB_OK|MB_ICONINFORMATION);

}
closesocket(sock);
WSACleanup();


//execution du code
}
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);

EndPaint(hWnd, &ps);
break;

case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;

case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}


http://totalpcone.free.fr
vendredi 30 mai 2003 à 16:23:07 | Re : PB EditBox

BruNews

Administrateur CodeS-SourceS
GetWindowText(hedit, szbuff, lenbuff);
ou alors:
GetDlgItemText(hdlg, IDED_IP, szbuff, lenbuff);
donc si tu as char szIP[20]:
nbrcaracs = GetWindowText(hedit, szIP, 20);
BruNews, ciao...


-------------------------------
Réponse au message :
-------------------------------

> Bonjour à tous !
> J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je ne sait pas comment les editbox peuvent ecrire dans les variables IP et PORT.
> Voici la source vous comprendrez mieu
>
>
> #include "stdafx.h"
> #include "resource.h"
> #include <stdio.h>
> #include <iostream.h>
> #include <time.h>
> #include <conio.h>
> #include <istream.h>
> #pragma comment(lib, "ws2_32.lib")
> #include <winsock2.h>
>
> #define MAX_LOADSTRING 100
> #define ID_BUTTON 100
> #define ID_EDITBOX 100
>
> // Global Variables:
> HINSTANCE hInst; // current instance
> TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
> TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
>
> // Foward declarations of functions included in this code module:
> ATOM MyRegisterClass(HINSTANCE hInstance);
> BOOL InitInstance(HINSTANCE, int);
> LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
> LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
>
> int APIENTRY WinMain(HINSTANCE hInstance,
> HINSTANCE hPrevInstance,
> LPSTR lpCmdLine,
> int nCmdShow)
> {
> // TODO: Place code here.
> MSG msg;
> HACCEL hAccelTable;
>
> // Initialize global strings
> LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
> LoadString(hInstance, IDC_SCANNERBYSFYLER, szWindowClass, MAX_LOADSTRING);
> MyRegisterClass(hInstance);
>
> // Perform application initialization:
> if (!InitInstance (hInstance, nCmdShow))
> {
> return FALSE;
> }
>
> hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SCANNERBYSFYLER);
>
> // Main message loop:
> while (GetMessage(&msg, NULL, 0, 0))
> {
> if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
> {
> TranslateMessage(&msg);
> DispatchMessage(&msg);
> }
> }
>
> return msg.wParam;
> }
>
>
>
> //
> // FUNCTION: MyRegisterClass()
> //
> // PURPOSE: Registers the window class.
> //
> // COMMENTS:
> //
> // This function and its usage is only necessary if you want this code
> // to be compatible with Win32 systems prior to the 'RegisterClassEx'
> // function that was added to Windows 95. It is important to call this function
> // so that the application will get 'well formed' small icons associated
> // with it.
> //
> ATOM MyRegisterClass(HINSTANCE hInstance)
> {
> WNDCLASSEX wcex;
>
> wcex.cbSize = sizeof(WNDCLASSEX);
>
> wcex.style = CS_HREDRAW | CS_VREDRAW;
> wcex.lpfnWndProc = (WNDPROC)WndProc;
> wcex.cbClsExtra = 0;
> wcex.cbWndExtra = 0;
> wcex.hInstance = hInstance;
> wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCANNERBYSFYLER);
> wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> wcex.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
> wcex.lpszMenuName = (LPCSTR)IDC_SCANNERBYSFYLER;
> wcex.lpszClassName = szWindowClass;
> wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
>
> return RegisterClassEx(&wcex);
> }
>
> //
> // FUNCTION: InitInstance(HANDLE, int)
> //
> // PURPOSE: Saves instance handle and creates main window
> //
> // COMMENTS:
> //
> // In this function, we save the instance handle in a global variable and
> // create and display the main program window.
> //
> BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
> {
> HWND hWnd;
>
> hInst = hInstance; // Store instance handle in our global variable
>
> hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
> CW_USEDEFAULT, CW_USEDEFAULT, 180, 250, HWND_DESKTOP, NULL, hInstance, NULL);
> HWND edithWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> 10, 10, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> SetWindowText(edithWnd, "IP");
>
> HWND edithWnd1 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> 10, 50, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> SetWindowText(edithWnd1, "PORT");
> // Création du bouton
> HWND cmdhWnd = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT,
> 10, 150, 150, 30, hWnd, (HMENU)ID_BUTTON, hInstance, NULL);
> SetWindowText(cmdhWnd, "Scan");
>
> if (!hWnd)
> {
> return FALSE;
> }
>
> ShowWindow(hWnd, nCmdShow);
> UpdateWindow(hWnd);
>
>
> return TRUE;
> }
>
> //
> // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
> //
> // PURPOSE: Processes messages for the main window.
> //
> // WM_COMMAND - process the application menu
> // WM_PAINT - Paint the main window
> // WM_DESTROY - post a quit message and return
> //
> //
> LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> {
> int wmId, wmEvent;
> PAINTSTRUCT ps;
> HDC hdc;
> TCHAR szHello[MAX_LOADSTRING];
> LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
>
> switch (message)
> {
> case WM_COMMAND:
> wmId = LOWORD(wParam);
> wmEvent = HIWORD(wParam);
> if ((LOWORD(wParam) == ID_BUTTON) && (HIWORD(wParam) == BN_CLICKED))
> {
> MessageBox(hWnd, "Scan en cours", "Scanner", MB_OK|MB_ICONINFORMATION);
>
> WSADATA WSAData; // tout les prog de
> WSAStartup(MAKEWORD(2,0),&WSAData);
>
> SOCKET sock;
>
> SOCKADDR_IN sin;
> //ICI JAIMERAIS QUE CE SOIT LES EDIT BOX QUI REMPLISSE IP ET PORT
> sin.sin_addr.s_addr = inet_addr(IP); // definit les propriétés
> sin.sin_family = AF_INET; // de la socket
> sin.sin_port = htons(PORT);
>
> sock = socket(AF_INET,SOCK_STREAM,0);
> n = connect(sock,(SOCKADDR *)&sin,sizeof(sin));
> if(n == 0) // si on peut se connecter (donc si le port est ouvert)
> {
> MessageBox(hWnd, "Le port est ouvert", "Scanner", MB_OK|MB_ICONINFORMATION);
> }
> else
> {
> MessageBox(hWnd, "Le port est fermé", "Scanner", MB_OK|MB_ICONINFORMATION);
>
> }
> closesocket(sock);
> WSACleanup();
>
>
> //execution du code
> }
> // Parse the menu selections:
> switch (wmId)
> {
> case IDM_ABOUT:
> DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
> break;
> case IDM_EXIT:
> DestroyWindow(hWnd);
> break;
> default:
> return DefWindowProc(hWnd, message, wParam, lParam);
> }
> break;
> case WM_PAINT:
> hdc = BeginPaint(hWnd, &ps);
> // TODO: Add any drawing code here...
> RECT rt;
> GetClientRect(hWnd, &rt);
>
> EndPaint(hWnd, &ps);
> break;
>
> case WM_DESTROY:
> PostQuitMessage(0);
> break;
> default:
> return DefWindowProc(hWnd, message, wParam, lParam);
> }
> return 0;
> }
>
> // Mesage handler for about box.
> LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
> {
> switch (message)
> {
> case WM_INITDIALOG:
> return TRUE;
>
> case WM_COMMAND:
> if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
> {
> EndDialog(hDlg, LOWORD(wParam));
> return TRUE;
> }
> break;
> }
> return FALSE;
> }
>
>
> http://totalpcone.free.fr
vendredi 30 mai 2003 à 17:07:33 | Re : PB EditBox

SfyLer

merci beaucoup ! mais jai encore un blem pour le port:
char *LePORT = NULL;
unsigned int TextLen = 0;
TextLen = GetWindowTextLength(EditHandle);
LeText = new char[(TextLen + 2)];
TextLen = GetWindowText(EditHandle, LeText, (TextLen + 1));

Le pb c'est que sa, sa prend ce ke ya ecri dans le edit box et sa le met dans une variable char, et je narrive pas a ce ki prennent une variable int, pouvez vous juste modifier ce code pour ke sa marche ?
http://totalpc.free.fr


-------------------------------
Réponse au message :
-------------------------------

> GetWindowText(hedit, szbuff, lenbuff);
> ou alors:
> GetDlgItemText(hdlg, IDED_IP, szbuff, lenbuff);
> donc si tu as char szIP[20]:
> nbrcaracs = GetWindowText(hedit, szIP, 20);
> BruNews, ciao...
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > Bonjour à tous !
> > J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je ne sait pas comment les editbox peuvent ecrire dans les variables IP et PORT.
> > Voici la source vous comprendrez mieu
> >
> >
> > #include "stdafx.h"
> > #include "resource.h"
> > #include <stdio.h>
> > #include <iostream.h>
> > #include <time.h>
> > #include <conio.h>
> > #include <istream.h>
> > #pragma comment(lib, "ws2_32.lib")
> > #include <winsock2.h>
> >
> > #define MAX_LOADSTRING 100
> > #define ID_BUTTON 100
> > #define ID_EDITBOX 100
> >
> > // Global Variables:
> > HINSTANCE hInst; // current instance
> > TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
> > TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
> >
> > // Foward declarations of functions included in this code module:
> > ATOM MyRegisterClass(HINSTANCE hInstance);
> > BOOL InitInstance(HINSTANCE, int);
> > LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
> > LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
> >
> > int APIENTRY WinMain(HINSTANCE hInstance,
> > HINSTANCE hPrevInstance,
> > LPSTR lpCmdLine,
> > int nCmdShow)
> > {
> > // TODO: Place code here.
> > MSG msg;
> > HACCEL hAccelTable;
> >
> > // Initialize global strings
> > LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
> > LoadString(hInstance, IDC_SCANNERBYSFYLER, szWindowClass, MAX_LOADSTRING);
> > MyRegisterClass(hInstance);
> >
> > // Perform application initialization:
> > if (!InitInstance (hInstance, nCmdShow))
> > {
> > return FALSE;
> > }
> >
> > hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SCANNERBYSFYLER);
> >
> > // Main message loop:
> > while (GetMessage(&msg, NULL, 0, 0))
> > {
> > if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
> > {
> > TranslateMessage(&msg);
> > DispatchMessage(&msg);
> > }
> > }
> >
> > return msg.wParam;
> > }
> >
> >
> >
> > //
> > // FUNCTION: MyRegisterClass()
> > //
> > // PURPOSE: Registers the window class.
> > //
> > // COMMENTS:
> > //
> > // This function and its usage is only necessary if you want this code
> > // to be compatible with Win32 systems prior to the 'RegisterClassEx'
> > // function that was added to Windows 95. It is important to call this function
> > // so that the application will get 'well formed' small icons associated
> > // with it.
> > //
> > ATOM MyRegisterClass(HINSTANCE hInstance)
> > {
> > WNDCLASSEX wcex;
> >
> > wcex.cbSize = sizeof(WNDCLASSEX);
> >
> > wcex.style = CS_HREDRAW | CS_VREDRAW;
> > wcex.lpfnWndProc = (WNDPROC)WndProc;
> > wcex.cbClsExtra = 0;
> > wcex.cbWndExtra = 0;
> > wcex.hInstance = hInstance;
> > wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCANNERBYSFYLER);
> > wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> > wcex.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
> > wcex.lpszMenuName = (LPCSTR)IDC_SCANNERBYSFYLER;
> > wcex.lpszClassName = szWindowClass;
> > wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
> >
> > return RegisterClassEx(&wcex);
> > }
> >
> > //
> > // FUNCTION: InitInstance(HANDLE, int)
> > //
> > // PURPOSE: Saves instance handle and creates main window
> > //
> > // COMMENTS:
> > //
> > // In this function, we save the instance handle in a global variable and
> > // create and display the main program window.
> > //
> > BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
> > {
> > HWND hWnd;
> >
> > hInst = hInstance; // Store instance handle in our global variable
> >
> > hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
> > CW_USEDEFAULT, CW_USEDEFAULT, 180, 250, HWND_DESKTOP, NULL, hInstance, NULL);
> > HWND edithWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > 10, 10, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > SetWindowText(edithWnd, "IP");
> >
> > HWND edithWnd1 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > 10, 50, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > SetWindowText(edithWnd1, "PORT");
> > // Création du bouton
> > HWND cmdhWnd = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT,
> > 10, 150, 150, 30, hWnd, (HMENU)ID_BUTTON, hInstance, NULL);
> > SetWindowText(cmdhWnd, "Scan");
> >
> > if (!hWnd)
> > {
> > return FALSE;
> > }
> >
> > ShowWindow(hWnd, nCmdShow);
> > UpdateWindow(hWnd);
> >
> >
> > return TRUE;
> > }
> >
> > //
> > // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
> > //
> > // PURPOSE: Processes messages for the main window.
> > //
> > // WM_COMMAND - process the application menu
> > // WM_PAINT - Paint the main window
> > // WM_DESTROY - post a quit message and return
> > //
> > //
> > LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> > {
> > int wmId, wmEvent;
> > PAINTSTRUCT ps;
> > HDC hdc;
> > TCHAR szHello[MAX_LOADSTRING];
> > LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
> >
> > switch (message)
> > {
> > case WM_COMMAND:
> > wmId = LOWORD(wParam);
> > wmEvent = HIWORD(wParam);
> > if ((LOWORD(wParam) == ID_BUTTON) && (HIWORD(wParam) == BN_CLICKED))
> > {
> > MessageBox(hWnd, "Scan en cours", "Scanner", MB_OK|MB_ICONINFORMATION);
> >
> > WSADATA WSAData; // tout les prog de
> > WSAStartup(MAKEWORD(2,0),&WSAData);
> >
> > SOCKET sock;
> >
> > SOCKADDR_IN sin;
> > //ICI JAIMERAIS QUE CE SOIT LES EDIT BOX QUI REMPLISSE IP ET PORT
> > sin.sin_addr.s_addr = inet_addr(IP); // definit les propriétés
> > sin.sin_family = AF_INET; // de la socket
> > sin.sin_port = htons(PORT);
> >
> > sock = socket(AF_INET,SOCK_STREAM,0);
> > n = connect(sock,(SOCKADDR *)&sin,sizeof(sin));
> > if(n == 0) // si on peut se connecter (donc si le port est ouvert)
> > {
> > MessageBox(hWnd, "Le port est ouvert", "Scanner", MB_OK|MB_ICONINFORMATION);
> > }
> > else
> > {
> > MessageBox(hWnd, "Le port est fermé", "Scanner", MB_OK|MB_ICONINFORMATION);
> >
> > }
> > closesocket(sock);
> > WSACleanup();
> >
> >
> > //execution du code
> > }
> > // Parse the menu selections:
> > switch (wmId)
> > {
> > case IDM_ABOUT:
> > DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
> > break;
> > case IDM_EXIT:
> > DestroyWindow(hWnd);
> > break;
> > default:
> > return DefWindowProc(hWnd, message, wParam, lParam);
> > }
> > break;
> > case WM_PAINT:
> > hdc = BeginPaint(hWnd, &ps);
> > // TODO: Add any drawing code here...
> > RECT rt;
> > GetClientRect(hWnd, &rt);
> >
> > EndPaint(hWnd, &ps);
> > break;
> >
> > case WM_DESTROY:
> > PostQuitMessage(0);
> > break;
> > default:
> > return DefWindowProc(hWnd, message, wParam, lParam);
> > }
> > return 0;
> > }
> >
> > // Mesage handler for about box.
> > LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
> > {
> > switch (message)
> > {
> > case WM_INITDIALOG:
> > return TRUE;
> >
> > case WM_COMMAND:
> > if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
> > {
> > EndDialog(hDlg, LOWORD(wParam));
> > return TRUE;
> > }
> > break;
> > }
> > return FALSE;
> > }
> >
> >
> > http://totalpcone.free.fr
>
vendredi 30 mai 2003 à 17:09:24 | Re : PB EditBox

SfyLer

eeeee je rectifie la source:
> char *LePORT = NULL; <----- c'est pas sa, c'est ca:
char *LeText = NULL;

http://totalpc.free.fr


-------------------------------
Réponse au message :
-------------------------------

> merci beaucoup ! mais jai encore un blem pour le port:
> char *LePORT = NULL;
> unsigned int TextLen = 0;
> TextLen = GetWindowTextLength(EditHandle);
> LeText = new char[(TextLen + 2)];
> TextLen = GetWindowText(EditHandle, LeText, (TextLen + 1));
>
> Le pb c'est que sa, sa prend ce ke ya ecri dans le edit box et sa le met dans une variable char, et je narrive pas a ce ki prennent une variable int, pouvez vous juste modifier ce code pour ke sa marche ?
> http://totalpc.free.fr
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > GetWindowText(hedit, szbuff, lenbuff);
> > ou alors:
> > GetDlgItemText(hdlg, IDED_IP, szbuff, lenbuff);
> > donc si tu as char szIP[20]:
> > nbrcaracs = GetWindowText(hedit, szIP, 20);
> > BruNews, ciao...
> >
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Bonjour à tous !
> > > J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je ne sait pas comment les editbox peuvent ecrire dans les variables IP et PORT.
> > > Voici la source vous comprendrez mieu
> > >
> > >
> > > #include "stdafx.h"
> > > #include "resource.h"
> > > #include <stdio.h>
> > > #include <iostream.h>
> > > #include <time.h>
> > > #include <conio.h>
> > > #include <istream.h>
> > > #pragma comment(lib, "ws2_32.lib")
> > > #include <winsock2.h>
> > >
> > > #define MAX_LOADSTRING 100
> > > #define ID_BUTTON 100
> > > #define ID_EDITBOX 100
> > >
> > > // Global Variables:
> > > HINSTANCE hInst; // current instance
> > > TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
> > > TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
> > >
> > > // Foward declarations of functions included in this code module:
> > > ATOM MyRegisterClass(HINSTANCE hInstance);
> > > BOOL InitInstance(HINSTANCE, int);
> > > LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
> > > LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
> > >
> > > int APIENTRY WinMain(HINSTANCE hInstance,
> > > HINSTANCE hPrevInstance,
> > > LPSTR lpCmdLine,
> > > int nCmdShow)
> > > {
> > > // TODO: Place code here.
> > > MSG msg;
> > > HACCEL hAccelTable;
> > >
> > > // Initialize global strings
> > > LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
> > > LoadString(hInstance, IDC_SCANNERBYSFYLER, szWindowClass, MAX_LOADSTRING);
> > > MyRegisterClass(hInstance);
> > >
> > > // Perform application initialization:
> > > if (!InitInstance (hInstance, nCmdShow))
> > > {
> > > return FALSE;
> > > }
> > >
> > > hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SCANNERBYSFYLER);
> > >
> > > // Main message loop:
> > > while (GetMessage(&msg, NULL, 0, 0))
> > > {
> > > if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
> > > {
> > > TranslateMessage(&msg);
> > > DispatchMessage(&msg);
> > > }
> > > }
> > >
> > > return msg.wParam;
> > > }
> > >
> > >
> > >
> > > //
> > > // FUNCTION: MyRegisterClass()
> > > //
> > > // PURPOSE: Registers the window class.
> > > //
> > > // COMMENTS:
> > > //
> > > // This function and its usage is only necessary if you want this code
> > > // to be compatible with Win32 systems prior to the 'RegisterClassEx'
> > > // function that was added to Windows 95. It is important to call this function
> > > // so that the application will get 'well formed' small icons associated
> > > // with it.
> > > //
> > > ATOM MyRegisterClass(HINSTANCE hInstance)
> > > {
> > > WNDCLASSEX wcex;
> > >
> > > wcex.cbSize = sizeof(WNDCLASSEX);
> > >
> > > wcex.style = CS_HREDRAW | CS_VREDRAW;
> > > wcex.lpfnWndProc = (WNDPROC)WndProc;
> > > wcex.cbClsExtra = 0;
> > > wcex.cbWndExtra = 0;
> > > wcex.hInstance = hInstance;
> > > wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCANNERBYSFYLER);
> > > wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> > > wcex.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
> > > wcex.lpszMenuName = (LPCSTR)IDC_SCANNERBYSFYLER;
> > > wcex.lpszClassName = szWindowClass;
> > > wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
> > >
> > > return RegisterClassEx(&wcex);
> > > }
> > >
> > > //
> > > // FUNCTION: InitInstance(HANDLE, int)
> > > //
> > > // PURPOSE: Saves instance handle and creates main window
> > > //
> > > // COMMENTS:
> > > //
> > > // In this function, we save the instance handle in a global variable and
> > > // create and display the main program window.
> > > //
> > > BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
> > > {
> > > HWND hWnd;
> > >
> > > hInst = hInstance; // Store instance handle in our global variable
> > >
> > > hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
> > > CW_USEDEFAULT, CW_USEDEFAULT, 180, 250, HWND_DESKTOP, NULL, hInstance, NULL);
> > > HWND edithWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > > 10, 10, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > > SetWindowText(edithWnd, "IP");
> > >
> > > HWND edithWnd1 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > > 10, 50, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > > SetWindowText(edithWnd1, "PORT");
> > > // Création du bouton
> > > HWND cmdhWnd = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT,
> > > 10, 150, 150, 30, hWnd, (HMENU)ID_BUTTON, hInstance, NULL);
> > > SetWindowText(cmdhWnd, "Scan");
> > >
> > > if (!hWnd)
> > > {
> > > return FALSE;
> > > }
> > >
> > > ShowWindow(hWnd, nCmdShow);
> > > UpdateWindow(hWnd);
> > >
> > >
> > > return TRUE;
> > > }
> > >
> > > //
> > > // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
> > > //
> > > // PURPOSE: Processes messages for the main window.
> > > //
> > > // WM_COMMAND - process the application menu
> > > // WM_PAINT - Paint the main window
> > > // WM_DESTROY - post a quit message and return
> > > //
> > > //
> > > LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> > > {
> > > int wmId, wmEvent;
> > > PAINTSTRUCT ps;
> > > HDC hdc;
> > > TCHAR szHello[MAX_LOADSTRING];
> > > LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
> > >
> > > switch (message)
> > > {
> > > case WM_COMMAND:
> > > wmId = LOWORD(wParam);
> > > wmEvent = HIWORD(wParam);
> > > if ((LOWORD(wParam) == ID_BUTTON) && (HIWORD(wParam) == BN_CLICKED))
> > > {
> > > MessageBox(hWnd, "Scan en cours", "Scanner", MB_OK|MB_ICONINFORMATION);
> > >
> > > WSADATA WSAData; // tout les prog de
> > > WSAStartup(MAKEWORD(2,0),&WSAData);
> > >
> > > SOCKET sock;
> > >
> > > SOCKADDR_IN sin;
> > > //ICI JAIMERAIS QUE CE SOIT LES EDIT BOX QUI REMPLISSE IP ET PORT
> > > sin.sin_addr.s_addr = inet_addr(IP); // definit les propriétés
> > > sin.sin_family = AF_INET; // de la socket
> > > sin.sin_port = htons(PORT);
> > >
> > > sock = socket(AF_INET,SOCK_STREAM,0);
> > > n = connect(sock,(SOCKADDR *)&sin,sizeof(sin));
> > > if(n == 0) // si on peut se connecter (donc si le port est ouvert)
> > > {
> > > MessageBox(hWnd, "Le port est ouvert", "Scanner", MB_OK|MB_ICONINFORMATION);
> > > }
> > > else
> > > {
> > > MessageBox(hWnd, "Le port est fermé", "Scanner", MB_OK|MB_ICONINFORMATION);
> > >
> > > }
> > > closesocket(sock);
> > > WSACleanup();
> > >
> > >
> > > //execution du code
> > > }
> > > // Parse the menu selections:
> > > switch (wmId)
> > > {
> > > case IDM_ABOUT:
> > > DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
> > > break;
> > > case IDM_EXIT:
> > > DestroyWindow(hWnd);
> > > break;
> > > default:
> > > return DefWindowProc(hWnd, message, wParam, lParam);
> > > }
> > > break;
> > > case WM_PAINT:
> > > hdc = BeginPaint(hWnd, &ps);
> > > // TODO: Add any drawing code here...
> > > RECT rt;
> > > GetClientRect(hWnd, &rt);
> > >
> > > EndPaint(hWnd, &ps);
> > > break;
> > >
> > > case WM_DESTROY:
> > > PostQuitMessage(0);
> > > break;
> > > default:
> > > return DefWindowProc(hWnd, message, wParam, lParam);
> > > }
> > > return 0;
> > > }
> > >
> > > // Mesage handler for about box.
> > > LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
> > > {
> > > switch (message)
> > > {
> > > case WM_INITDIALOG:
> > > return TRUE;
> > >
> > > case WM_COMMAND:
> > > if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
> > > {
> > > EndDialog(hDlg, LOWORD(wParam));
> > > return TRUE;
> > > }
> > > break;
> > > }
> > > return FALSE;
> > > }
> > >
> > >
> > > http://totalpcone.free.fr
> >
>
vendredi 30 mai 2003 à 17:15:02 | Re : PB EditBox

BruNews

Administrateur CodeS-SourceS
ival = GetDlgItemInt(hdlg, IDED_IP, 0, 0);
je mets 0 sur desrnier, tu mets 1 si est nbr signe.
Sinon tu fais avec solution d'avant:
ival = atoi(szbuff);
BruNews, ciao...


-------------------------------
Réponse au message :
-------------------------------

> merci beaucoup ! mais jai encore un blem pour le port:
> char *LePORT = NULL;
> unsigned int TextLen = 0;
> TextLen = GetWindowTextLength(EditHandle);
> LeText = new char[(TextLen + 2)];
> TextLen = GetWindowText(EditHandle, LeText, (TextLen + 1));
>
> Le pb c'est que sa, sa prend ce ke ya ecri dans le edit box et sa le met dans une variable char, et je narrive pas a ce ki prennent une variable int, pouvez vous juste modifier ce code pour ke sa marche ?
> http://totalpc.free.fr
>
>
> -------------------------------
> Réponse au message :
> -------------------------------
>
> > GetWindowText(hedit, szbuff, lenbuff);
> > ou alors:
> > GetDlgItemText(hdlg, IDED_IP, szbuff, lenbuff);
> > donc si tu as char szIP[20]:
> > nbrcaracs = GetWindowText(hedit, szIP, 20);
> > BruNews, ciao...
> >
> >
> > -------------------------------
> > Réponse au message :
> > -------------------------------
> >
> > > Bonjour à tous !
> > > J'ai créé un scanner de port sous dos, et j'ai commencer a le faire sous windows, j'ai presque fini le seul pb que j'ai c'est que je ne sait pas comment les editbox peuvent ecrire dans les variables IP et PORT.
> > > Voici la source vous comprendrez mieu
> > >
> > >
> > > #include "stdafx.h"
> > > #include "resource.h"
> > > #include <stdio.h>
> > > #include <iostream.h>
> > > #include <time.h>
> > > #include <conio.h>
> > > #include <istream.h>
> > > #pragma comment(lib, "ws2_32.lib")
> > > #include <winsock2.h>
> > >
> > > #define MAX_LOADSTRING 100
> > > #define ID_BUTTON 100
> > > #define ID_EDITBOX 100
> > >
> > > // Global Variables:
> > > HINSTANCE hInst; // current instance
> > > TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
> > > TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text
> > >
> > > // Foward declarations of functions included in this code module:
> > > ATOM MyRegisterClass(HINSTANCE hInstance);
> > > BOOL InitInstance(HINSTANCE, int);
> > > LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
> > > LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
> > >
> > > int APIENTRY WinMain(HINSTANCE hInstance,
> > > HINSTANCE hPrevInstance,
> > > LPSTR lpCmdLine,
> > > int nCmdShow)
> > > {
> > > // TODO: Place code here.
> > > MSG msg;
> > > HACCEL hAccelTable;
> > >
> > > // Initialize global strings
> > > LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
> > > LoadString(hInstance, IDC_SCANNERBYSFYLER, szWindowClass, MAX_LOADSTRING);
> > > MyRegisterClass(hInstance);
> > >
> > > // Perform application initialization:
> > > if (!InitInstance (hInstance, nCmdShow))
> > > {
> > > return FALSE;
> > > }
> > >
> > > hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_SCANNERBYSFYLER);
> > >
> > > // Main message loop:
> > > while (GetMessage(&msg, NULL, 0, 0))
> > > {
> > > if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
> > > {
> > > TranslateMessage(&msg);
> > > DispatchMessage(&msg);
> > > }
> > > }
> > >
> > > return msg.wParam;
> > > }
> > >
> > >
> > >
> > > //
> > > // FUNCTION: MyRegisterClass()
> > > //
> > > // PURPOSE: Registers the window class.
> > > //
> > > // COMMENTS:
> > > //
> > > // This function and its usage is only necessary if you want this code
> > > // to be compatible with Win32 systems prior to the 'RegisterClassEx'
> > > // function that was added to Windows 95. It is important to call this function
> > > // so that the application will get 'well formed' small icons associated
> > > // with it.
> > > //
> > > ATOM MyRegisterClass(HINSTANCE hInstance)
> > > {
> > > WNDCLASSEX wcex;
> > >
> > > wcex.cbSize = sizeof(WNDCLASSEX);
> > >
> > > wcex.style = CS_HREDRAW | CS_VREDRAW;
> > > wcex.lpfnWndProc = (WNDPROC)WndProc;
> > > wcex.cbClsExtra = 0;
> > > wcex.cbWndExtra = 0;
> > > wcex.hInstance = hInstance;
> > > wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_SCANNERBYSFYLER);
> > > wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
> > > wcex.hbrBackground = (HBRUSH)GetStockObject(LTGRAY_BRUSH);
> > > wcex.lpszMenuName = (LPCSTR)IDC_SCANNERBYSFYLER;
> > > wcex.lpszClassName = szWindowClass;
> > > wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
> > >
> > > return RegisterClassEx(&wcex);
> > > }
> > >
> > > //
> > > // FUNCTION: InitInstance(HANDLE, int)
> > > //
> > > // PURPOSE: Saves instance handle and creates main window
> > > //
> > > // COMMENTS:
> > > //
> > > // In this function, we save the instance handle in a global variable and
> > > // create and display the main program window.
> > > //
> > > BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
> > > {
> > > HWND hWnd;
> > >
> > > hInst = hInstance; // Store instance handle in our global variable
> > >
> > > hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
> > > CW_USEDEFAULT, CW_USEDEFAULT, 180, 250, HWND_DESKTOP, NULL, hInstance, NULL);
> > > HWND edithWnd = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > > 10, 10, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > > SetWindowText(edithWnd, "IP");
> > >
> > > HWND edithWnd1 = CreateWindowEx(WS_EX_OVERLAPPEDWINDOW, "EDIT", "", WS_VISIBLE|WS_CHILD|ES_AUTOHSCROLL|ES_NOHIDESEL,
> > > 10, 50, 150, 25, hWnd, (HMENU)ID_EDITBOX, hInstance, NULL);
> > > SetWindowText(edithWnd1, "PORT");
> > > // Création du bouton
> > > HWND cmdhWnd = CreateWindowEx(0, "BUTTON", "", WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_NOTIFY|BS_TEXT,
> > > 10, 150, 150, 30, hWnd, (HMENU)ID_BUTTON, hInstance, NULL);
> > > SetWindowText(cmdhWnd, "Scan");
> > >
> > > if (!hWnd)
> > > {
> > > return FALSE;
> > > }
> > >
> > > ShowWindow(hWnd, nCmdShow);
> > > UpdateWindow(hWnd);
> > >
> > >
> > > return TRUE;
> > > }
> > >
> > > //
> > > // FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
> > > //
> > > // PURPOSE: Processes messages for the main window.
> > > //
> > > // WM_COMMAND - process the application menu
> > > // WM_PAINT - Paint the main window
> > > // WM_DESTROY - post a quit message and return
> > > //
> > > //
> > > LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
> > > {
> > > int wmId, wmEvent;
> > > PAINTSTRUCT ps;
> > > HDC hdc;
> > > TCHAR szHello[MAX_LOADSTRING];
> > > LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
> > >
> > > switch (message)
> > > {
> > > case WM_COMMAND:
> > > wmId = LOWORD(wParam);
> > > wmEvent = HIWORD(wParam);
> > > if ((LOWORD(wParam) == ID_BUTTON) && (HIWORD(wParam) == BN_CLICKED))
> > > {
> > > MessageBox(hWnd, "Scan en cours", "Scanner", MB_OK|MB_ICONINFORMATION);
> > >
> > > WSADATA WSAData; // tout les prog de
> > > WSAStartup(MAKEWORD(2,0),&WSAData);
> > >
> > > SOCKET sock;
> > >
> > > SOCKADDR_IN sin;
> > > //ICI JAIMERAIS QUE CE SOIT LES EDIT BOX QUI REMPLISSE IP ET PORT
> > > sin.sin_addr.s_addr = inet_addr(IP); // definit les propriétés
> > > sin.sin_family = AF_INET; // de la socket
> > > sin.sin_port = htons(PORT);
> > >
> > > sock = socket(AF_INET,SOCK_STREAM,0);
> > > n = connect(sock,(SOCKADDR *)&sin,sizeof(sin));
> > > if(n == 0) // si on peut se connecter (donc si le port est ouvert)
> > > {
> > > MessageBox(hWnd, "Le port est ouvert", "Scanner", MB_OK|MB_ICONINFORMATION);
> > > }
> > > else
> > > {
> > > MessageBox(hWnd, "Le port est fermé", "Scanner", MB_OK|MB_ICONINFORMATION);
> > >
> > > }
> > > closesocket(sock);
> > > WSACleanup();
> > >
> > >
> > > //execution du code
> > > }
> > > // Parse the menu selections:
> > > switch (wmId)
> > > {
> > > case IDM_ABOUT:
> > > DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
> > > break;
> > > case IDM_EXIT:
> > > DestroyWindow(hWnd);
> > > break;
> > > default:
> > > return DefWindowProc(hWnd, message, wParam, lParam);
> > > }
> > > break;
> > > case WM_PAINT:
> > > hdc = BeginPaint(hWnd, &ps);
> > > // TODO: Add any drawing code here...
> > > RECT rt;
> > > GetClientRect(hWnd, &rt);
> > >
> > > EndPaint(hWnd, &ps);
> > > break;
> > >
> > > case WM_DESTROY:
> > > PostQuitMessage(0);
> > > break;
> > > default:
> > > return DefWindowProc(hWnd, message, wParam, lParam);
> > > }
> > > return 0;
> > > }
> > >
> > > // Mesage handler for about box.
> > > LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
> > > {
> > > switch (message)
> > > {
> > > case WM_INITDIALOG:
> > > return TRUE;
> > >
> > > case WM_COMMAND:
> > > if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
> > > {
> > > EndDialog(hDlg, LOWORD(wParam));
> > > return TRUE;
> > > }
> > > break;
> > > }
> > > return FALSE;
> > > }
> > >
> > >
> > > http://totalpcone.free.fr
> >
>


Cette discussion est classée dans : hwnd, wparam, return, hinstance, wcex


Répondre à ce message

Sujets en rapport avec ce message

Pb sur un ptit bout de prog en DirectX.... [ par Haldwin ] Salut a tous....Voila j'ai deux ptits pbs quand je lance cette appli ci-dessous... (VC++)La première est q'une fois sur deux ma variable hWnd apres le crer "dialog non modal" [ par comfm ] BonjourJe n'arrive pas à créer une boite de dialogue non modal, c'est à dire celle qui permet d'être tjs affichée et on peut cliquer derriere sans pro Problème de linker dans programme de base. [ par vith17 ] Bonjour,J'ai tapé le code suivant sous Dev-C++. Lorsque je lance la compilation, il me revoie l'erreur suivante :    [Linker error] undefined referenc Je trouve pas le bon code [ par vah bi ] Bonjour à tous , voilà je débute en c et comme editeur j'ai le visual c++.Je  fais actuellement une application avec l'api de visual c++  mais en lang WIN32 : Editbox non editable avec une boite de dialogue CHILD [ par Pistol_Pete ] BonjourVoila mon problème: J'ai créé une fenêtre et dans cette fenêtre j'ai une boite de dialogue avec le style WS_CHILD. Tous mes contrôles de cette Probleme de socket [ par alphaone ] // tcp_client.cpp*: définit le point d'entrée pour l'appli Problème graphique avec C [ par le1scorpion1noir ] salut a tous je peux savoir c'est quoi le meilleur logiciel pour programmer en C puis y t il une différence entre le C et le C++ ? je débute et j ess Hook WH_MOUSE_LL [ par vecchio56 ] Bonjour,J'utilise un hook bas niveau de type WH_MOUSE_LL, et j'ai un problème lorque je cherche a fermer ma fenêtre principale (la souris se bloque). Dialog fenetre enfant qui bloque [ par NairodDorian ] Bonjour,Mon probleme est le suivant, j'utilises les resources avec des dialog et je voudrai affiche un dialogue defini par Child dans les proprietes d lire un fichier wav [ par youma85 ] salut tous le monde lorsque j'execute ce programme on me donne ses erreur#include #include #include "resource.h"HINSTANCE hInst;LRESULT CALLBACK MainP


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 4,805 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales