Chat on IRC |
trying to make a window
Posted by putang1080 [send private reply] at June 23, 2001, 06:53:17 PM
i'm trying to make a window in windows. i use msvc++ 6.0. I'm reading game programming for dummies. i've already done the Hello World! program, that's just a little box. I looked/read at how to make a windows and register it, but i'm confused. i do the command HWND CreateWindow. But in the book there are two examples, one that has: handles and pointers and etc. using the hungarian notation; the other just, i wanna say describes the handles, pointers, dword, int, etc. I don't know which one to use, the one that tell the window the positions of it and the window name, or the first one with all the parameters.
Next, when displaying it, where do i put the BOOL ShowWindow? and the BOOL UpdateWindow? thanx
Posted by shroomrefic29 [send private reply] at June 24, 2001, 03:40:16 AM
Hmm seems to me that the second listing of the window source code
is simply the explanation of the process in invoking a window. I would go with the first example. As for the ShowWindow and UpdateWindow function. Use Showindow first then UpdateWindow.
Posted by Psion [send private reply] at June 24, 2001, 08:21:30 AM
Check out http://www.winprog.org/tutorial/
Posted by CHollman82 [send private reply] at June 24, 2001, 01:45:32 PM
#include <windows.h>
const char *CLASSNAME = "MyClass", *WINNAME = "Chris Hollman"; LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam); HDC hdc; int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) { HWND hWnd; MSG Message; WNDCLASS WndClass; memset(&WndClass, 0, sizeof(WndClass)); WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); WndClass.hCursor = LoadCursor(NULL, IDC_ARROW); WndClass.hIcon = LoadIcon(hInstance, NULL); WndClass.hInstance = hInstance; WndClass.lpfnWndProc = WndProc; WndClass.lpszClassName = CLASSNAME; WndClass.style = CS_HREDRAW | CS_VREDRAW; if(!RegisterClass(&WndClass)) return(0); hWnd = CreateWindow(CLASSNAME, WINNAME, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 300, 100, NULL, NULL, hInstance, NULL); ShowWindow(hWnd, nCmdShow); while(GetMessage(&Message, hWnd, 0, 0)) { TranslateMessage(&Message); DispatchMessage(&Message); } return Message.wParam; } LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch(iMessage) { case WM_CLOSE: if(hdc)ReleaseDC(hWnd, hdc); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, iMessage, wParam, lParam); } return(0); } there you go, defining a window, drawing a window, setting up message handling, you really dont need the hdc though (it's for graphics, which, as a newbie, you probably don't need to mess with right now)
Register as a new user | ||||||