/* Author : Willie Tang * Compiler : MS Visual C++ 6.0 * Created : December 02, 2001 * Modified : January 03, 2002 * Website : http://nomad.openglforums.com * * Notes : The code below works as a Win32 Application. * To run the code, create a new project (File->New). * In the Projects Tab, select "Win32 Application", * give the project a name them click OK. Then select * the "An Empty Project" radio button, click Finish. * * To insert the code to the project. Click on the * Project menu->Add to Project->New. On the Files * Tab, select "C++ Source File", give any name to * the file, then click OK. After that, copy and paste * the code below to the editor. ************************************************************/ #include LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_CREATE: // window is created //--[ DO STUFFS HERE...] break; case WM_DESTROY: // window is destroyed //--[ DO STUFFS HERE...] PostQuitMessage(0); // add "quit" to msg queue break; case WM_SIZE: // window is resized //--[ DO STUFFS HERE...] break; default: return(DefWindowProc(hWnd, message, wParam, lParam)); } return(0L); // return a zero } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { WNDCLASS wndclass; HWND hWindow; MSG msg; // Initialize values of wndclass' fields wndclass.style = CS_HREDRAW | CS_VREDRAW; // window's style wndclass.lpfnWndProc = (WNDPROC)WndProc; // pointer to WndProc wndclass.cbClsExtra = 0; // disregard... wndclass.cbWndExtra = 0; // disregard... wndclass.hInstance = hInstance; // copy from WinMain() wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); // window icon // IDI_ASTERISK // IDI_EXCLAMATION // IDI_HAND // IDI_QUESTION // IDI_WINLOGO wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); // window's mouse cursor // IDC_CROSS // a...'cross'...:) // IDC_NO // slashed circle // IDC_WAIT // hourglass // IDC_HELP // arrow with question mark // IDC_UPARROW // arrow pointing up wndclass.hbrBackground = NULL; // handle to bground brush wndclass.lpszMenuName = NULL; // window's menu name wndclass.lpszClassName = "MyWindowName"; // window's name // Register wndclass if(RegisterClass(&wndclass) == 0) return FALSE; // Create our window and get its handle hWindow = CreateWindow ("MyWindowName", // from wndclass.lpszClassName "My Title Bar", // this will show on title bar WS_OVERLAPPEDWINDOW, // border, title, min-max-close button // WS_OVERLAPPED // border, title // WS_POPUP // no title, no button, no border // WS_VISIBLE // window is visible from start // WS_VSCROLL // window has vertical scroll bar // WS_HSCROLL // window has horizontal scroll bar // WS_MAXIMIZE // create window in maximized state // WS_MINIMIZE // create window in minimized state 0, // starting x-coord (upper-left) 0, // starting y-coord (upper-left) CW_USEDEFAULT, // window's x-size CW_USEDEFAULT, // window's y-size NULL, // parent window's handle NULL, // handle to a menu hInstance, // copy from WinMain()'s parameter NULL); // disregard... // Check if window was created if(hWindow == NULL) return FALSE; // Show our window ShowWindow(hWindow, SW_SHOW); // show created window // SW_HIDE // hide created window // SW_RESTORE // show window in restored state // SW_MAXIMIZE // show window in maximized state // SW_MINIMIZE // show window in minimized state // Keep on grabbing messages while(GetMessage(&msg, hWindow, 0,0)) // keep on getting msgs { TranslateMessage(&msg); // convert to "known" msg DispatchMessage(&msg); // send to msg queue } return 0; }