Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

111 Neutral

About Erlex

  • Rank
  1. That worked Endurion, thanks a lot.
  2. Sure thing. [source lang="java"]LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){ switch(msg){ case WM_DESTROY: gameover = true; PostQuitMessage(0); return 0; } return DefWindowProc(hWnd, msg, wParam, lParam); }[/source]
  3. Thanks for everyone's help. Khatharr, I tried both zeroing the struct, and messing around with the brush types, unfortunately to no avail.
  4. Reaquiring the keyboard at the beginning of the game loop did the trick! Thanks Khatharr. And here is my WinMain. Keep in mind that this is the same code from the book, and that I have only a surface knowledge of windows. Thanks again for the help. [source lang="cpp"]int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow){ //set the new window's properties WNDCLASSEX wc; //create window class structure wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW|CS_VREDRAW; wc.lpfnWndProc = (WNDPROC)WinProc; wc.cbClsExtra = 0; wc.cbWndExtra= 0; wc.hInstance = hInstance; wc.hIcon = NULL; wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = APPTITLE.c_str(); wc.hIconSm = NULL; RegisterClassEx(&wc); //create new window HWND window = CreateWindow( APPTITLE.c_str(), APPTITLE.c_str(), WS_OVERLAPPED, CW_USEDEFAULT, CW_USEDEFAULT, SCREENW, SCREENH, NULL, NULL, hInstance, NULL); //check if window could be created if(!window){ MessageBox(window, "Cannot create window", "Error", MB_OK); return 0; } //display the window ShowWindow(window,nCmdShow); UpdateWindow(window); //initialize the game if(!gameInit(window)){ MessageBox(window, "Cannot initialize game", "Error", MB_OK); return 0; } //main message loop MSG message; while(!gameover){ if(PeekMessage(&message, NULL, 0, 0, PM_REMOVE)){ TranslateMessage(&message); DispatchMessage(&message); } gameRun(window); } gameEnd(); return message.wParam; }[/source]
  5. Hello, I am fairly new to game programming, especially with DirectX. I am an experienced programmer, but not with DirectX or Windows. Like so many, I am going through Beginning Game Programming 3rd, and I have run into a few recurring problems. But before just posting a giant block of code, I thought I would at least ask if anyone has encountered similar problems. 1. I am unable to get my program to read key presses after the program window is back grounded. Everything works until I bring one window up to the front, and bring my program back. Perhaps there is something wrong with my WinProc function? 2. Not a serious problem, but a rather annoying one; the minimize, maximize, and exit buttons that are supposed to be at the top right of the window are not showing up. My WinMain is consistent with the book's. I haven't a clue on this one. Any help would be very much appreciated. Thank you in advance!
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!