Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


MessageBox doesn't appear

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Fri Nov 18, 2011 8:28 pm    Post subject: MessageBox doesn't appear Reply with quote

Whenever I call MessageBox at the end of my WinMain function (after the message loop) the message box just refuses to show. Although I can hear the sound of the message box just fine...
It works fine as long as it is called _before_ and inside the message loop but not after :/.

I have debugged it using F11 (visual studio) and everything seems fine. It calls the API just fine like always.

Here's my WinMain code:
Code:
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   WNDCLASSEX WcEx;
   memset(&WcEx, 0, sizeof(WNDCLASSEX));

   WcEx.cbSize         = sizeof(WNDCLASSEX);
   WcEx.hCursor      = LoadCursor(NULL, IDC_ARROW);
   WcEx.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
   WcEx.hInstance      = hInstance;
   WcEx.lpfnWndProc   = WndProc;
   WcEx.lpszClassName   = g_lpWindowName;
   WcEx.style         = CS_OWNDC;

   if(!RegisterClassEx(&WcEx))
   {
      ShowWinError("RegisterClassEx");
      return EXIT_FAILURE;
   }

   RECT rcWindow;
   SIZE szViewport;
   memset(&rcWindow, 0, sizeof(RECT));

   rcWindow.right   = 1280;
   rcWindow.bottom   =  720;

   szViewport.cx   = rcWindow.right;
   szViewport.cy   = rcWindow.bottom;

   AdjustWindowRect(&rcWindow, WS_OVERLAPPEDWINDOW, FALSE);

   HWND hWnd = CreateWindowEx(0, g_lpWindowName, g_lpWindowName, WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, rcWindow.right, rcWindow.bottom, NULL, NULL, hInstance, NULL);
   if(!hWnd)
   {
      ShowWinError("CreateWindowEx");
      goto Shutdown;
   }

   if(!InitializeGL(hWnd))
      goto Shutdown;

   if(!Input.Initialize(hWnd))
   {
      ShowWinError("Failed to initialize input! RegisterRawInputDevices");
      goto Shutdown;
   }

   Input.SetKeyboardFunc(KeyboardInput);
   
   UpdateWindow(hWnd);
   ShowWindow(hWnd, nCmdShow);

   SetupRC();
   Resize(szViewport.cx, szViewport.cy);
   
   MSG Message;
   while(!g_bQuit)
   {      
      if(PeekMessage(&Message, NULL, 0, 0, PM_REMOVE))
      {
         TranslateMessage(&Message);
         DispatchMessage(&Message);
      }
      
      Input.Update(Message);
      Input.ProcessInput(Timer.GetElapsedSeconds());
      
      RenderFrame();
   //   Sleep(1);
   }

Shutdown:
   Input.Shutdown();
   ShutdownGL(hWnd, hInstance);

   MessageBox(NULL, "Message", "Yay", MB_OK | MB_ICONWARNING); // This refuses to show... This is just for testing, it won't really be here
// Inside Input.Shutdown() there is a message box describing the error(if any) but that will not show as well ...

   return 0;
}
Back to top
View user's profile Send private message
OmegaCES
Cheater
Reputation: 1

Joined: 02 Jul 2011
Posts: 44

PostPosted: Sat Nov 19, 2011 4:32 am    Post subject: Reply with quote

Code:
   Input.Shutdown();
   ShutdownGL(hWnd, hInstance);

Isn't this calling a shutdown before you display the messagebox? try putting it after. (Unless it has to be there ofcourse).

I don't code in c, hope I have helped a little Razz
Back to top
View user's profile Send private message
NoMercy
Master Cheater
Reputation: 1

Joined: 09 Feb 2009
Posts: 289

PostPosted: Sat Nov 19, 2011 11:33 am    Post subject: Reply with quote

Code:

Shutdown:
   Input.Shutdown();
   ShutdownGL(hWnd, hInstance);


What is this?

Are you sure if you set a bp on MB, it gets hitted?
Back to top
View user's profile Send private message
TraxMate
Master Cheater
Reputation: 0

Joined: 01 Mar 2008
Posts: 363

PostPosted: Sat Nov 19, 2011 1:19 pm    Post subject: Reply with quote

Found the problem. The problem was that I was calling DestroyWindow() twice. Once in the window procedure and once in the ShutdownGL() function. Though I don't know why that would matter since I'm not passing a HWND to the message box :s.

@NoMercy: Input.Shutdown() removes the raw input devices and ShutdownGL() destroys the window and the OpenGL rendering context.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites