Click here to Skip to main content
15,895,606 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: MFC - CAsyncSocket class Pin
Cool_Dev11-Jan-10 19:21
Cool_Dev11-Jan-10 19:21 
GeneralRe: MFC - CAsyncSocket class Pin
liz311-Jan-10 21:56
liz311-Jan-10 21:56 
GeneralRe: MFC - CAsyncSocket class Pin
Moak11-Jan-10 22:37
Moak11-Jan-10 22:37 
GeneralRe: MFC - CAsyncSocket class Pin
liz312-Jan-10 19:03
liz312-Jan-10 19:03 
QuestionC++ CODE FOR VENDING MACHINE Pin
queenzz11-Jan-10 16:19
queenzz11-Jan-10 16:19 
AnswerRe: C++ CODE FOR VENDING MACHINE Pin
Richard MacCutchan12-Jan-10 0:45
mveRichard MacCutchan12-Jan-10 0:45 
QuestionRe: C++ CODE FOR VENDING MACHINE Pin
David Crow12-Jan-10 3:14
David Crow12-Jan-10 3:14 
QuestionDetecting whether a modal dialog has displayed Pin
Kenneth Ballard11-Jan-10 13:52
Kenneth Ballard11-Jan-10 13:52 
Inside a message handler for WM_LBUTTONDOWN, several functions are being called, one of which is known to display a dialog box under certain circumstances. Prior to this function being called, the mouse is captured using SetCapture(). However when that dialog is shown, the WM_LBUTTONUP appears to be getting swallowed by that dialog, and as such, to the underlying control that spawned the dialog, the mouse still appears to be down.

In looking for a passive method of detecting whether the dialog has been displayed, the code will call GetCapture() to retrieve the handle to the current window with the capture and check it against the handle to which the capture had been previously set. If the handles are different, it will post a WM_LBUTTONUP message to the message queue to "complete the click". Sample code:

::SetCapture(hWnd);

// ...several lines later

FunctionThatCouldDisplayADialog();

HWND hWndCapture = ::GetCapture();
if(hWnd != hWndCapture)
{
    ::PostMessage(hWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
}


With some testing of various scenarios (with more to come), this appears to be a reliable method to determine if a dialog was displayed during the current line of execution. To quote the manager of my team, this wreaks of being a hack, and as such, we're still mildly skeptical on the reliability of this method. I'm looking for feedback on this and whether anyone can see any potential pitfalls, issues or concerns for which we should be accounting.

Thanks.
AnswerRe: Detecting whether a modal dialog has displayed Pin
KingsGambit11-Jan-10 19:02
KingsGambit11-Jan-10 19:02 
GeneralRe: Detecting whether a modal dialog has displayed Pin
Kenneth Ballard12-Jan-10 5:04
Kenneth Ballard12-Jan-10 5:04 
QuestionHelp on error Pin
siyuanfang11-Jan-10 6:52
siyuanfang11-Jan-10 6:52 
AnswerRe: Help on error Pin
Nelek11-Jan-10 6:58
protectorNelek11-Jan-10 6:58 
QuestionRe: Help on error Pin
CPallini11-Jan-10 7:00
mveCPallini11-Jan-10 7:00 
AnswerRe: Help on error Pin
Nelek11-Jan-10 7:12
protectorNelek11-Jan-10 7:12 
GeneralRe: Help on error Pin
CPallini11-Jan-10 7:32
mveCPallini11-Jan-10 7:32 
JokeOT Pin
Nelek11-Jan-10 7:39
protectorNelek11-Jan-10 7:39 
GeneralRe: OT Pin
CPallini11-Jan-10 7:43
mveCPallini11-Jan-10 7:43 
GeneralRe: OT Pin
Cedric Moonen11-Jan-10 7:55
Cedric Moonen11-Jan-10 7:55 
GeneralRe: OT Pin
CPallini11-Jan-10 7:59
mveCPallini11-Jan-10 7:59 
AnswerRe: Help on error Pin
Richard MacCutchan11-Jan-10 8:44
mveRichard MacCutchan11-Jan-10 8:44 
JokeHey Richard Pin
CPallini11-Jan-10 8:53
mveCPallini11-Jan-10 8:53 
GeneralRe: Hey Richard Pin
Richard MacCutchan11-Jan-10 8:58
mveRichard MacCutchan11-Jan-10 8:58 
JokeRe: Hey Richard Pin
CPallini11-Jan-10 9:39
mveCPallini11-Jan-10 9:39 
GeneralRe: Hey Richard Pin
Richard MacCutchan11-Jan-10 11:35
mveRichard MacCutchan11-Jan-10 11:35 
Questionhow to write a function in a file at binary level (after compilation) Pin
Joseph Marzbani11-Jan-10 6:15
Joseph Marzbani11-Jan-10 6:15 

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.