Created
June 27, 2010 05:57
-
-
Save 0mg/454688 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <windows.h> | |
| // | |
| // メインウィンドウプロシージャ | |
| // | |
| LRESULT CALLBACK mainWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp){ | |
| HDC hdc; | |
| char c[512]; | |
| switch(msg){ | |
| case WM_MOUSEMOVE: | |
| hdc = GetDC(hwnd); | |
| wsprintf(c, "%s", "★"); | |
| SelectObject(hdc, GetStockObject(DEFAULT_GUI_FONT)); | |
| SetTextColor(hdc, RGB(rand(), rand(), rand())); | |
| TextOut(hdc, LOWORD(lp), HIWORD(lp), c, lstrlen(c)); | |
| TextOut(hdc, HIWORD(lp), LOWORD(lp), c, lstrlen(c)); | |
| ReleaseDC(hwnd, hdc); | |
| return 0; | |
| case WM_RBUTTONUP: | |
| InvalidateRect(hwnd, NULL, TRUE); | |
| return 0; | |
| case WM_DESTROY: | |
| PostQuitMessage(0); | |
| break; | |
| } | |
| return DefWindowProc(hwnd, msg, wp, lp); | |
| } | |
| // | |
| // プログラムスタート | |
| // | |
| int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ | |
| MSG msg; | |
| WNDCLASS wc; | |
| HWND hwnd; | |
| //メインウィンドウのクラス登録 | |
| wc.style = CS_HREDRAW | CS_VREDRAW; | |
| wc.lpfnWndProc = mainWndProc; | |
| wc.cbClsExtra = 0; | |
| wc.cbWndExtra = sizeof(DWORD); | |
| wc.hInstance = hInstance; | |
| wc.hIcon = NULL; | |
| wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
| wc.hbrBackground = (HBRUSH)GetSysColorBrush(COLOR_WINDOW); | |
| wc.lpszMenuName = NULL; | |
| wc.lpszClassName = TEXT("MainWindowClass"); | |
| if(! RegisterClass(&wc) ) return 0; | |
| //メインウィンドウを作成 | |
| hwnd = CreateWindow( | |
| TEXT("MainWindowClass"), TEXT(""), | |
| WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE, | |
| 0, 0, | |
| 800, 1000, | |
| NULL, NULL, | |
| hInstance, NULL | |
| ); | |
| if(hwnd == NULL ) return 0; | |
| //メインループ | |
| while(GetMessage(&msg, NULL, 0, 0)){ | |
| TranslateMessage(&msg);// Altキーでのメニューポップアップ有効 | |
| DispatchMessage(&msg); | |
| } | |
| return msg.wParam; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment