Red de conocimiento informático - Material del sitio web - Cómo escribir un botón en lenguaje C

Cómo escribir un botón en lenguaje C

#include

typedef _Bool bool;

#define false ((bool)0)

#define true ((bool)1)

HWND ChuangJianChuangKou(char *a,bool(*b)(HWND hwnd,mensaje UINT,WPARAM wParam,LPARAM lParam),bool c,int x,int y)

{

HWND hwnd;

static TCHAR szAppName[] = TEXT("Mz Game") ;

WNDCLASS wndclass ;

p>

wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC ;

wndclass.lpszClassName = szAppName ;

wndclass.lpszMenuName = NULL ;

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

wndclass.lpfnWndProc = (WNDPROC)b;

wndclass.cbWndExtra = 0;

wndclass.cbClsExtra = 0 ;

wndclass.hInstance = 0;

wndclass.hIcon = LoadIcon( NULL, IDI_APPLICATION ) ;

wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );

if(!RegisterClass(&wndclass))

{

return (HWND)0;

}

hwnd=CreateWindow(

szAppName,

a,

c?WS_OVERLAPPEDWINDOW:WS_POPUP,

(GetSystemMetrics (SM_CXSCREEN)-x)/2,

(GetSystemMetrics (SM_CYSCREEN)-y)/2,

x,

y,

0,

0,

0,

);

ShowWindow(hwnd,1);

UpdateWindow(hwnd);

return hwnd;

}

bool GengXinChuangKou()

{

mensaje MSG estático;

if(GetMessage(&msg,NULL,0,0))

{

TranslateMessage(&msg);

DispatchMessage(&msg);

devuelve verdadero;

}

else

{

devuelve falso;

}

}

bool WndProc(HWND hwnd,UIN

Mensaje T,WPARAM wParam,LPARAM lParam)

{

return MoRenChuLi(hwnd,message,wParam,lParam,0);

}

WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)

{

ChuangJianChuangKou("sss",WndProc,true,KongJianDaXiao(0).x/ 2,KongJianDaXiao(0).y/2);

mientras(GengXinChuangKou());

}