14 Ekim 2008 Salı

Form Oluşturma

#include
#include
#include
#include
#define BUTTON1 100
#define BUTTON2 200
#define BUTTON3 300
#define BUTTON4 400
#define BUTTON5 500


HANDLE ghInstance;

RECT rect;
short cxChar, cyChar,
LineCount, MaxLineCount;
BOOL ScrollFlag;

LRESULT CALLBACK
MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam);


int pascal
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpszArgument,int nCmdShow)

{

HWND hwndMain;
MSG msg;
WNDCLASS wndclass;
char* szMainWndClass = "Form Application (no mouse)";
ghInstance= hInstance;

memset (&wndclass, 0, sizeof(WNDCLASS));

wndclass.lpszClassName = szMainWndClass;

wndclass.style = CS_HREDRAW | CS_VREDRAW;

wndclass.lpfnWndProc = MainWndProc;

wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION);

wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

RegisterClass (&wndclass);

hwndMain = CreateWindow (
szMainWndClass,
"Form Project-Don't use mouse",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);

ShowWindow (hwndMain,nCmdShow);
UpdateWindow (hwndMain);

while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}


LRESULT CALLBACK
MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
static HWND hButton1, hButton2,hButton3, hButton4,hButton5;
int OemScanCode;
HDC hDC;
TEXTMETRIC tm;

switch (nMsg) {


case WM_CREATE: hButton1= CreateWindow ("BUTTON", "buton1 " ,
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
40, 40, 160, 160, hwnd,(HMENU) BUTTON1,
ghInstance, NULL);
ShowWindow (hButton1, SW_SHOW);



hButton2= CreateWindow ("BUTTON", "buton2",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
40, 250,160,160, hwnd,(HMENU) BUTTON2,
ghInstance, NULL);
ShowWindow (hButton2, SW_SHOW);

hButton3= CreateWindow ("BUTTON", "buton3",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
300, 40, 160, 160, hwnd,(HMENU) BUTTON3,
ghInstance, NULL);
ShowWindow (hButton3, SW_SHOW);

hButton4= CreateWindow ("BUTTON", "buton4",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
300, 250, 160, 160, hwnd,(HMENU) BUTTON4,
ghInstance, NULL);
ShowWindow (hButton4, SW_SHOW);

hButton5= CreateWindow ("BUTTON", "buton5",
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
560,150,160,160, hwnd,(HMENU) BUTTON5,
ghInstance, NULL);
ShowWindow (hButton5, SW_SHOW);



hDC= GetDC (hwnd);
SelectObject (hDC, GetStockObject (SYSTEM_FIXED_FONT));
GetTextMetrics (hDC, &tm);
cxChar= tm.tmAveCharWidth;
cyChar= tm.tmHeight;
ReleaseDC (hwnd, hDC);
rect.top= cyChar / 2;
break;



case WM_KEYDOWN: OemScanCode= HIWORD (lParam) & 0x00ff;
switch (OemScanCode) {

case 0x48: SendMessage (hButton1, BM_SETSTATE, 1, 0l); /*make a mission*/ break;
case 0x4D: SendMessage (hButton3, BM_SETSTATE, 1, 0l); /*make a mission*/ break;
case 0x1D: SendMessage (hButton4, BM_SETSTATE, 1, 0l); /*make a mission*/ break;
case 0x4B: SendMessage (hButton2, BM_SETSTATE, 1, 0l); /*make a mission*/ break;
case 0x15: SendMessage (hButton5, BM_SETSTATE, 1, 0l);/*make a mission*/ break;
} break;


case WM_KEYUP: OemScanCode= HIWORD (lParam) & 0x00ff;
switch (OemScanCode) {
case 0x48: SendMessage (hButton1, BM_SETSTATE, 0, 0l); break;
case 0x4D: SendMessage (hButton3, BM_SETSTATE, 0, 0l); break;
case 0x1D: SendMessage (hButton4, BM_SETSTATE, 0, 0l); break;
case 0x4B: SendMessage (hButton2, BM_SETSTATE, 0, 0l); break;
case 0x15: SendMessage (hButton5, BM_SETSTATE, 0, 0l); break;
}
break;


case WM_DESTROY: PostQuitMessage (0);
return (0);
}
return (DefWindowProc (hwnd, nMsg, wParam, lParam));
}

0 Yorum: