Click here to Skip to main content
15,883,734 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: want to make circular progress bar on the dialog?? Give some tips! Pin
Soumyajit Satpathy10-Jul-13 4:57
Soumyajit Satpathy10-Jul-13 4:57 
QuestionTab control with custom draw? Pin
JoneLe866-Jul-13 7:35
JoneLe866-Jul-13 7:35 
Questionhow to set entire console window background color with given RGB(SetConsoleScreenBufferInfoEx)? Pin
Falconapollo6-Jul-13 2:33
Falconapollo6-Jul-13 2:33 
AnswerRe: how to set entire console window background color with given RGB(SetConsoleScreenBufferInfoEx)? Pin
Richard MacCutchan6-Jul-13 4:46
mveRichard MacCutchan6-Jul-13 4:46 
GeneralRe: how to set entire console window background color with given RGB(SetConsoleScreenBufferInfoEx)? Pin
Falconapollo6-Jul-13 6:35
Falconapollo6-Jul-13 6:35 
GeneralRe: how to set entire console window background color with given RGB(SetConsoleScreenBufferInfoEx)? Pin
Richard MacCutchan6-Jul-13 7:12
mveRichard MacCutchan6-Jul-13 7:12 
QuestionModeless Dialog with Message Loop Pin
Manish K. Agarwal4-Jul-13 21:32
Manish K. Agarwal4-Jul-13 21:32 
AnswerRe: Modeless Dialog with Message Loop Pin
pasztorpisti5-Jul-13 14:50
pasztorpisti5-Jul-13 14:50 
Here is my guess:
Message order can be different with different window managers. Even on the same windows installation the window manager and the message order can be different if you change between aero/oldschool/whatever look.
One possible reason can be the following: when you press X the window receives WM_SYSCOMMAND/SC_CLOSE that triggers a WM_CLOSE that triggers WM_DESTROY that finally executes a PostQuitMessage() in a usual windows program. Pressing the Exit menuitem usually skips the first step of the chain and sends WM_CLOSE directly to the window. I think here the problem can be that your loop consumes the WM_QUIT message placed by PostQuitMessage() to the message queue (when your GetMessage call returns FALSE) so when you return from your loop the message loop of IE doesn't have any quit message to process. I'm not exactly sure about this (haven't tried it) because WM_QUIT isn't really a message in the message queue of your thread, its rather a bit that tells GetMessage()/PeekMessage() to return WM_QUIT when there are no more messages left in the queue, maybe this flag remains set but who knows... If the flag doesn't remain set (that can be windows version specific) then the problem can be what I described. When your main loop ends (GetMessage returns false) try to repost the quit message by calling PostQuitMessage((int)Msg.wParam) a the end of your OnBnClickedTest() function to place a WM_QUIT message (flag) in the queue for the main loop of IE. Try it and good luck with this.

Of course this disaster can happen only if the WM_QUIT is consumed and if WM_QUIT comes before the bClosed flag of your dialog becomes true. You can check that by placing a log into your bClosed checking if block and after the end of your loop.

EDIT: Another even better solution if you know the HWND of the main window: after checking the m_MainDialog.bClosed flag of your dialog put in another if block that checks whether this message is a WM_CLOSE message sent to the main window and in that case break out of your loop. An even better version of this: in your loop you should call PeekMessage() before every GetMessage() call just to look ahead in the queue (without removing the message) and if its a suspicious message sent to the main window (WM_SYSCOMMAND/SC_CLOSE or WM_CLOSE) then you break out your loop immediately without processing the message and you let the message loop of IE to process it. What is nice about this solution is that it would work even if the main loop of IE wanted to act on the WM_SYSCOMMAND/SC_CLOSE or WM_CLOSE message of the main window - putting such handlers into the main loop is not a good practice (you should handle that in the windowproc of the specified hwnd) but maybe MS guys committed that hack...

briefly:
C++
for (;;)
{
   WaitMessage();
   PeekMessage();
   if (WM_SYSCOMMAND/SC_CLOSE or WM_CLOSE sent to the main window)
      break;

   BOOL bRet = !GetMessage();
   if (!bRet)
      break;

   // original code from your while loop
}


EDIT: of course you know the HWND of the main window because you just have to call GetParent() on the HWND of the activex control or its window in a loop (or recursively) until it returns NULL HWND and the HWND before the NULL result is the top level window.

modified 7-Jul-13 21:13pm.

GeneralRe: Modeless Dialog with Message Loop Pin
Manish K. Agarwal5-Jul-13 18:42
Manish K. Agarwal5-Jul-13 18:42 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti6-Jul-13 1:55
pasztorpisti6-Jul-13 1:55 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti6-Jul-13 2:08
pasztorpisti6-Jul-13 2:08 
GeneralRe: Modeless Dialog with Message Loop Pin
Manish K. Agarwal7-Jul-13 21:17
Manish K. Agarwal7-Jul-13 21:17 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti7-Jul-13 22:11
pasztorpisti7-Jul-13 22:11 
GeneralRe: Modeless Dialog with Message Loop Pin
Manish K. Agarwal7-Jul-13 22:53
Manish K. Agarwal7-Jul-13 22:53 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti8-Jul-13 2:24
pasztorpisti8-Jul-13 2:24 
AnswerRe: Modeless Dialog with Message Loop Pin
Erudite_Eric7-Jul-13 23:26
Erudite_Eric7-Jul-13 23:26 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti8-Jul-13 8:40
pasztorpisti8-Jul-13 8:40 
GeneralRe: Modeless Dialog with Message Loop Pin
Erudite_Eric9-Jul-13 0:20
Erudite_Eric9-Jul-13 0:20 
GeneralRe: Modeless Dialog with Message Loop Pin
Erudite_Eric10-Jul-13 2:14
Erudite_Eric10-Jul-13 2:14 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti10-Jul-13 2:25
pasztorpisti10-Jul-13 2:25 
GeneralRe: Modeless Dialog with Message Loop Pin
Erudite_Eric10-Jul-13 4:25
Erudite_Eric10-Jul-13 4:25 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti10-Jul-13 5:17
pasztorpisti10-Jul-13 5:17 
GeneralRe: Modeless Dialog with Message Loop Pin
Erudite_Eric10-Jul-13 23:18
Erudite_Eric10-Jul-13 23:18 
GeneralRe: Modeless Dialog with Message Loop Pin
pasztorpisti11-Jul-13 0:21
pasztorpisti11-Jul-13 0:21 
GeneralRe: Modeless Dialog with Message Loop Pin
Erudite_Eric11-Jul-13 2:07
Erudite_Eric11-Jul-13 2:07 

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.