Code:
/****************************************************************************/
/* created by:adam *
/* on 2-21-02 *
/* *
/* *
/* *
/* *
/* *
/* *
/****************************************************************************/
#include <windows.h>
#include <stdio.h>
#define ID_CONNECT 2556;
#define ID_SEND 2557
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof (wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL,NULL);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "client";
wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
RegisterClassEx (&wndclass);
hwnd = CreateWindow ("client",
"client",
WS_POPUP,
200,
150,
600,
400,
NULL,
NULL,
hInstance,
NULL);
HWND hWndConnect = CreateWindow(TEXT("BUTTON"),
TEXT("Connect"),
BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE,
10,
10,
65,
15,
hwnd,
(HMENU)ID_CONNECT,
hInstance,
NULL ) ;
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg)
{
case WM_LBUTTONDOWN:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(wParam)
{
case ID_CONNECT:
MessageBox(hWnd, "Button was clicked!!!", "Event...", MB_OK);
PostQuitMessage(0);
break;
}
break;
}
return DefWindowProc (hwnd, iMsg, wParam, lParam);
}