Click here to Skip to main content
15,887,585 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,


I have problem with bringing together WinApi GUI and SDL2.

What I have:

I'm making by SDL2 a normal window, then (except other things I do) I retriving that sdl window hwnd and use it tomake winapi menu and other stuff. Everything works fine. I even making the new window only in winapi and it is also working.

Problem/Question:

When I try to handle menu, by using WM_COMMAND, then nothing happends. How I should do that?
Other message like WM_Devicechange is working now (see in the code)

I tryed to get the native events, by enabling the SDL_SYSWMEVENT and retriving wParam, lParam and the rest of that stuff. Only sysevent is working and inside it the wm_devicechange (for test only I don't need that event).

Ofcourse I also defined the winapi new events like that:
#define ID_MENU_NEW FILE 9001

Can someone point me in the right direction how to handle WM_COMMAND from this menu?


Thanks for any kind of help!

C++
void WinGUI::MenuUpd(SDL_Event &e) 
{ 
    
    

if(e.type==SDL_SYSWMEVENT) 
   { 
             
   Logger::Instance()->write2console("SDL_SYSWMEVENT"); 
                  UINT Message = e.syswm.msg->msg.win.msg; 
                  WPARAM wParam = e.syswm.msg->msg.win.wParam; 
                  LPARAM lParam = e.syswm.msg->msg.win.lParam; 
                  HWND hwnd = e.syswm.msg->msg.win.hwnd; 

                
                  if (e.syswm.msg->msg.win.msg == WM_DEVICECHANGE) 
                  { 
                     //This event is actualy working 
                      
                     Logger::Instance()->write2console("Pen"); 
                  } 


                  if (e.syswm.msg->msg.win.msg == WM_COMMAND) 
                  { 
                     // ...and that is not working 
                     Logger::Instance()->write2console("WM_COMMAND Event"); 

                     switch(LOWORD(wParam)) 
                     { 
                        case ID_FILE_EXIT: 
                           Logger::Instance()->write2console("ID_FILE_EXIT"); 
                           PostMessage(mainhwnd, WM_CLOSE, 0, 0); 
                           break; 
                        case ID_INFO_ABOUT: 
                           Logger::Instance()->write2console("ID_INFO_ABOUT"); 
                           MessageBox( NULL, "To jeszcze nie działa!", "Info", MB_ICONINFORMATION ); 

                           break; 
                     } 
                  } 
Posted
Updated 31-Jul-14 1:00am
v3
Comments
KarstenK 31-Jul-14 13:44pm    
Is the message proper enqueued in your message queue. Check which window (handle) get the message.

=> http://msdn.microsoft.com/library/windows/desktop/ms647591(v=vs.85).aspx

1 solution

Sorry for late answer.
Yes this msg is in right place. I' wos trying with hwnd too, but it didn't help me.
I'm afraid that SDL is handling that WM_COMMAND inside his guts, but I don't have access there.
Maybe I will learn how to use SDL filter events and that will handle this menu.
What do you think?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900