LRESULT CALLBACK MainWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam)
送られてくるメッセージはWM_という名前です。これはMessageに入っていますので、この値をswitch文で分岐して対応する処理をします。よく使うメッセージを示します。対応する関数名もその引数も勝手です。ここではメッセージの名前を用います。
LRESULT CALLBACK
MainWndProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM lParam) |
{ |
|
|
|
|
switch(Message){ |
|
|
|
case WM_CREATE: |
|
|
|
|
OnCreate(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_PAINT: |
|
|
|
|
OnPaint(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_COMMAND: |
|
|
|
|
OnCommand(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_ERASEBKGND: //ここは必ず背景色の色を指定します。 |
|
|
|
|
if(OnErasebkgnd(hWnd,
Message, wParam, lParam)){ |
|
|
|
|
|
return TRUE;
//背景色の色を指定しました。 |
|
|
|
|
} |
|
|
|
|
else{ |
|
|
|
|
|
return DefWindowProc(hWnd, Message,
wParam, lParam); |
|
|
|
|
} |
|
|
|
case WM_CLOSE: |
|
|
|
|
OnClose(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_DESTROY: |
|
|
|
|
PostQuitMessage(0); |
|
|
|
|
break; |
|
|
|
case WM_TIMER: |
|
|
|
|
OnTimer(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_SIZE: |
|
|
|
|
OnSize(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_SYSKEYDOWN: |
|
|
|
|
OnSyskeyDown(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_SYSKEYUP: |
|
|
|
|
OnSyskeyUp(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case
WM_KEYDOWN: |
|
|
|
|
OnKeyDown(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_KEYUP: |
|
|
|
|
OnKeyUp(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_MOVE: |
|
|
|
|
OnMove(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_DRAWITEM: |
|
|
|
|
OnDrawItem(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_DROPFILES: |
|
|
|
|
OnDropFile(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_MENUSELECT: |
|
|
|
|
OnMenuSelect(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_CHAR: |
|
|
|
|
OnChar(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_MOUSEMOVE: |
|
|
|
|
OnMouseMove(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_RBUTTONDBLCLK: |
|
|
|
|
OnRbuttonDblclk(hWnd,
Message, wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_LBUTTONDBLCLK: |
|
|
|
|
OnLbuttonDblclk(hWnd,
Message, wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_RBUTTONUP: |
|
|
|
|
OnRbuttonUp(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_LBUTTONUP: |
|
|
|
|
OnLbuttonUp(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_RBUTTONDOWN: |
|
|
|
|
OnRbuttonDown(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_LBUTTONDOWN: |
|
|
|
|
OnLbuttonDown(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_HSCROLL: |
|
|
|
|
OnHscroll(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
case WM_VSCROLL: |
|
|
|
|
OnVscroll(hWnd, Message,
wParam, lParam); |
|
|
|
|
break; |
|
|
|
default: |
|
|
|
|
return DefWindowProc(hWnd,
Message, wParam, lParam); |
|
|
} |
|
|
|
|
|
|
return FALSE; |
|
} |
|