Click here to Skip to main content
15,889,200 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralWinExec Pin
cupdoze16-Aug-05 17:19
cupdoze16-Aug-05 17:19 
GeneralRe: WinExec Pin
Christian Graus16-Aug-05 18:04
protectorChristian Graus16-Aug-05 18:04 
GeneralRe: WinExec Pin
ThatsAlok16-Aug-05 19:49
ThatsAlok16-Aug-05 19:49 
GeneralServer and client programming Pin
Member 216100416-Aug-05 15:45
Member 216100416-Aug-05 15:45 
GeneralRe: Server and client programming Pin
Christian Graus16-Aug-05 16:24
protectorChristian Graus16-Aug-05 16:24 
GeneralRe: Server and client programming Pin
Member 216100416-Aug-05 23:24
Member 216100416-Aug-05 23:24 
GeneralRe: Server and client programming Pin
Christian Graus17-Aug-05 11:42
protectorChristian Graus17-Aug-05 11:42 
GeneralMenu Question (fixed) Pin
LighthouseJ16-Aug-05 15:42
LighthouseJ16-Aug-05 15:42 
It's the inevitable...

I wrote a menu in the resource file and I entered it into the CreateWindowEx function call and it shows up. I also added code to the message handler to catch clicks. However, when I click items, nothing happens. Here's the handler:
switch (Msg) {<br />
     case WM_COMMAND: {<br />
          HandleMenuFunctions (hWnd, wParam);<br />
          return 0;<br />
     } break;<br />
     default: {<br />
          return DefWindowProc (hWnd, Msg, wParam, lParam);<br />
     } break;<br />
}

HandleMenuFunctions is just a function that has another switch to do different things based on the menu item selected:
void HandleMenuFunctions (HWND hWnd, WPARAM wParam) {<br />
     switch (LOWORD(wParam)) {<br />
          case ID_FILE_QUIT: {<br />
               MessageBox (hWnd, "Posting Quit Message now", "Notice", MB_ICONINFORMATION);<br />
               PostQuitMessage(0);<br />
          } break;<br />
          default: { MessageBox (hWnd, "Encountered unknown menu ID", "Notice", MB_ICONSTOP); } break;<br />
     }<br />
}

(excuse that smiley face, that should be a PostQuitMessage(0); call.)

Also, when I go to click the menu, it only shows me the popup menu under File every other time. The other times I click, the menu just loses focus. I don't know if that's important or not. Thanks in advance.

edit: I put breakpoints on that first WM_COMMAND case to see if the message is ever captured and it isn't. Either I'm catching the wrong message or something is wrong with the menu. I noticed that there are ways to declare a menu when I register the class in WNDCLASSEX and also when I call CreateWindowEx. I tried only declaring the menu when I register the class and the menu doesn't show, but when I declare it only in CreateWindowEx, it shows up. That might be important too.

solution: I fixed the problem, it had to do with my main message loop, it also fixed the thing where the menu loses focus. I removed the PeekMessage call and just let GetMessage get the message. Here's what I ended up with:
while (GetMessage(msg, NULL, 0, 0)) {<br />
     if (msg->message == WM_QUIT) {		// exit main loop on WM_QUIT<br />
          return ((int) msg->wParam);<br />
     }<br />
     TranslateMessage(msg);<br />
     DispatchMessage(msg);<br />
}<br />

GeneralError Pin
Member 216100416-Aug-05 15:23
Member 216100416-Aug-05 15:23 
GeneralRe: Error Pin
Weiye Chen16-Aug-05 16:02
Weiye Chen16-Aug-05 16:02 
GeneralRe: Error Pin
Christian Graus16-Aug-05 16:26
protectorChristian Graus16-Aug-05 16:26 
Questionhow to accessing Paradox use ADO Pin
ebinaini16-Aug-05 14:56
ebinaini16-Aug-05 14:56 
AnswerRe: how to accessing Paradox use ADO Pin
S Douglas16-Aug-05 21:52
professionalS Douglas16-Aug-05 21:52 
GeneralRe: how to accessing Paradox use ADO Pin
ebinaini17-Aug-05 15:07
ebinaini17-Aug-05 15:07 
Generalchanging what a pushbutton looks like Pin
Tim Zorn16-Aug-05 14:28
Tim Zorn16-Aug-05 14:28 
GeneralRe: changing what a pushbutton looks like Pin
Christian Graus16-Aug-05 15:03
protectorChristian Graus16-Aug-05 15:03 
GeneralRe: changing what a pushbutton looks like Pin
ebinaini16-Aug-05 19:30
ebinaini16-Aug-05 19:30 
GeneralRe: changing what a pushbutton looks like Pin
Christian Graus16-Aug-05 19:35
protectorChristian Graus16-Aug-05 19:35 
GeneralRe: changing what a pushbutton looks like Pin
ebinaini16-Aug-05 20:39
ebinaini16-Aug-05 20:39 
GeneralRe: changing what a pushbutton looks like Pin
Christian Graus17-Aug-05 11:39
protectorChristian Graus17-Aug-05 11:39 
GeneralRe: changing what a pushbutton looks like Pin
Tim Zorn20-Aug-05 12:28
Tim Zorn20-Aug-05 12:28 
GeneralRe: changing what a pushbutton looks like Pin
normanS16-Aug-05 21:32
normanS16-Aug-05 21:32 
GeneralRe: changing what a pushbutton looks like Pin
Tim Zorn20-Aug-05 8:41
Tim Zorn20-Aug-05 8:41 
GeneralRe: changing what a pushbutton looks like Pin
normanS21-Aug-05 19:27
normanS21-Aug-05 19:27 
GeneralRe: changing what a pushbutton looks like Pin
normanS22-Aug-05 5:37
normanS22-Aug-05 5:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.