Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Abob

How to kill a window

This topic is 5760 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am trying to make a little window with a logo pop up before my program starts So what I am doing is this at the top of WinMain
      

  WNDCLASSEX wcl;
  wcl.cbSize = sizeof(WNDCLASSEX); 

  wcl.hInstance = hThisInst; 
  wcl.lpszClassName = szWinName; 
  wcl.lpfnWndProc = WindowFunc; 
  wcl.style = 0; 

  wcl.hIcon = NULL; 
  wcl.hIconSm = NULL; 
  wcl.hCursor = NULL;

 
  wcl.lpszMenuName = NULL;
  wcl.cbClsExtra = 0; 
  wcl.cbWndExtra = 0; 

  wcl.hbrBackground = NULL;

  
  if(!RegisterClassEx(&wcl)) return 0;

//Create the window

 HWND hwnd = CreateWindow(
    szWinName, 
    "Welcom to EP Edit", 
    WS_POPUP, 
    300, 
    300, 
    500, 
    300, 
    HWND_DESKTOP, 
    NULL, 
    hThisInst, 
    NULL 
  );
  
  
  
  SetTimer(hwnd, 1, 4000, NULL); 
  ShowWindow(hwnd, nWinMode);
  UpdateWindow(hwnd);
  
  
 MSG msg;
  while(GetMessage(&msg, NULL, 0, 0))
  {
    TranslateMessage(&msg); 
     DispatchMessage(&msg); 
  }
  KillTimer(hwnd, 1);
  



  
Here is the Message handler
  
LRESULT CALLBACK WindowFunc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
  
  
  
  switch(message) {

  case WM_PAINT:
	  
	  HBITMAP bitmap;

	  bitmap = LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP3));
	  
	  PAINTSTRUCT ps;
	  HDC hdc;
	  HDC memDC;
	  hdc = BeginPaint( hwnd, &ps );
              memDC = CreateCompatibleDC(hdc);
	  SelectObject(memDC, bitmap);
              BitBlt(hdc, 0, 0, 500, 300, memDC, 0, 0, SRCCOPY);
	 
	  EndPaint( hwnd, &ps );
	  DeleteDC(memDC);
	  DeleteObject(bitmap);
	  break;
  case WM_TIMER:
	  //MessageBox(hwnd, "Timer", "Timer", MB_OK);

	  PostQuitMessage(0);
              break;
  
  
        default:
      /* Let Windows 98 process any messages not specified in
         the preceding switch statement. */
      return DefWindowProc(hwnd, message, wParam, lParam);
  }
  return 0;
}
 
       
So when it gets the timer message it drops though to the rest of the program in WinMain. But the logo window dos not disappear until the Program ends. Thanks for any help [edited by - Abob on September 13, 2002 2:34:25 PM] [edited by - Abob on September 13, 2002 2:36:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
Don''t do a PostQuitMessage from the WndProc of the BMP window.

On the WM_TIMER message, you need to call DestroyWindow(hWnd);
which will destroy the BMP window and clean up any resources associated with it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!