1.must have an entrypoint: WinMain
2.must have a function to solve message loop.
//sothing.c
#include <windows.h>
int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,INT);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE hInst;
char szAppName[]=“....“;
char szAppTitle[]=“...“;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpszCmdParam,INT nCmdShow)
{
HWND hWnd;
MSG message;
WNDCLASS wc;
if(!hPreInstance)
{
wc.style=......
wc.lpfnWndProc=WndProc;
RegisterClass(&wc);
}
hWnd=CreateWindow(
.....
);
ShowWindow(hWnd,....);
UpdateWindow(hWnd);
while(GetMessage(&message,NULL,0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWndMain,
UNIT message,
WPARAM wParam,
LPARAM lParam)
{
...
switch(message)
{
case WM_DESTROY:
....
}
return DefWindowProc(hWndMain,message,wParam,lParam);
}
2.must have a function to solve message loop.
//sothing.c
#include <windows.h>
int PASCAL WinMain(HINSTANCE,HINSTANCE,LPSTR,INT);
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
HINSTANCE hInst;
char szAppName[]=“....“;
char szAppTitle[]=“...“;
int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPreInstance,LPSTR lpszCmdParam,INT nCmdShow)
{
HWND hWnd;
MSG message;
WNDCLASS wc;
if(!hPreInstance)
{
wc.style=......
wc.lpfnWndProc=WndProc;
RegisterClass(&wc);
}
hWnd=CreateWindow(
.....
);
ShowWindow(hWnd,....);
UpdateWindow(hWnd);
while(GetMessage(&message,NULL,0,0))
{
TranslateMessage(&message);
DispatchMessage(&message);
}
return message.wParam;
}
LRESULT CALLBACK WndProc(HWND hWndMain,
UNIT message,
WPARAM wParam,
LPARAM lParam)
{
...
switch(message)
{
case WM_DESTROY:
....
}
return DefWindowProc(hWndMain,message,wParam,lParam);
}