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

C / C++ / MFC

 
QuestionDirect creation of CWnd Object Pin
al250027-Jun-17 5:16
al250027-Jun-17 5:16 
AnswerRe: Direct creation of CWnd Object Pin
Victor Nijegorodov27-Jun-17 6:17
Victor Nijegorodov27-Jun-17 6:17 
AnswerRe: Direct creation of CWnd Object Pin
Victor Nijegorodov27-Jun-17 6:27
Victor Nijegorodov27-Jun-17 6:27 
GeneralRe: Direct creation of CWnd Object Pin
leon de boer27-Jun-17 6:49
leon de boer27-Jun-17 6:49 
GeneralRe: Direct creation of CWnd Object Pin
Victor Nijegorodov27-Jun-17 10:45
Victor Nijegorodov27-Jun-17 10:45 
GeneralRe: Direct creation of CWnd Object Pin
leon de boer27-Jun-17 19:49
leon de boer27-Jun-17 19:49 
GeneralRe: Direct creation of CWnd Object Pin
al250029-Jun-17 5:23
al250029-Jun-17 5:23 
GeneralRe: Direct creation of CWnd Object Pin
leon de boer29-Jun-17 6:25
leon de boer29-Jun-17 6:25 
This is why I dislike MFC it mystifies what is actually a simple process. On the windows API itself there is a visibility flag it goes under the name WS_VISIBLE and it tells windows whether to draw a window or not. So a window can exist and even be position on screen but not be visible. There are a number of invisible windows actually at play on the desktop of Windows itself. A hint is what do you think the desktop icons are sitting in.

The rule goes if you create a new window which is visible and it is inserted into a parent that is visible, the standard windows system handlers will issue an initial WM_PAINT message. So it is the act of creating the window with a visible parent that for most windows makes it visible. Windows doesn't care about it being a frame or a window it simply cares what the WS_VISIBLE flag of a child and it's parent.

So you can create an invisible window easy as hell just don't set the WS_VISIBLE flag (try it on your window). Then you will need to use something like the API call ShowWindow to change it to visible.
ShowWindow function (Windows)[^]
That call can also be used to make a visible window go invisible and yes the window will still be there just not visible Smile | :)

You can also upset visibility by fouling up the message handler so it no longer does the default behaviour correctly and you always know that because you will find your paint behaviour is no longer as it should be.

So being visible has absolutely nothing to do with a window existing and invisible windows still exists to the message handlers and you can send message to invisible windows. An invisible window is simply a window that doesn't draw because the visibility flag is wrong or the handler stops it.

The only way to destroy a window is via
DestroyWindow function (Windows)[^]

All the close icons, ALT F4 etc lead to that call if they destroy the window (with the exception an application main window .. it is special and posts a quit message).

So a big difference between a window not being visible and a window being destroyed and don't ever think the two things are the same.

Now the MFC system just puts wrappers around that to try and break it up into a more layman friendly easier to use way. The downside is it sort of obviscates what is really going on with the Windows API.
In vino veritas


modified 29-Jun-17 12:38pm.

QuestionHow to proceed and execute LDPC decoding using Data Structure in C Pin
Member 1326117526-Jun-17 21:15
Member 1326117526-Jun-17 21:15 
AnswerRe: How to proceed and execute LDPC decoding using Data Structure in C Pin
Richard MacCutchan26-Jun-17 22:59
mveRichard MacCutchan26-Jun-17 22:59 
AnswerRe: How to proceed and execute LDPC decoding using Data Structure in C Pin
leon de boer27-Jun-17 5:36
leon de boer27-Jun-17 5:36 
GeneralRe: How to proceed and execute LDPC decoding using Data Structure in C Pin
Member 1326117527-Jun-17 19:19
Member 1326117527-Jun-17 19:19 
QuestionDisecting a PE File, Revisited Pin
Bram van Kampen26-Jun-17 14:56
Bram van Kampen26-Jun-17 14:56 
Questionhow to use memset to fill a char array with space key? Pin
focusdoit25-Jun-17 3:01
focusdoit25-Jun-17 3:01 
AnswerRe: how to use memset to fill a char array with space key? Pin
leon de boer25-Jun-17 3:12
leon de boer25-Jun-17 3:12 
GeneralRe: how to use memset to fill a char array with space key? Pin
focusdoit25-Jun-17 3:53
focusdoit25-Jun-17 3:53 
GeneralRe: how to use memset to fill a char array with space key? Pin
harold aptroot25-Jun-17 4:03
harold aptroot25-Jun-17 4:03 
GeneralRe: how to use memset to fill a char array with space key? Pin
focusdoit25-Jun-17 4:11
focusdoit25-Jun-17 4:11 
GeneralRe: how to use memset to fill a char array with space key? Pin
harold aptroot25-Jun-17 4:23
harold aptroot25-Jun-17 4:23 
GeneralRe: how to use memset to fill a char array with space key? Pin
Rick York26-Jun-17 7:50
mveRick York26-Jun-17 7:50 
GeneralRe: how to use memset to fill a char array with space key? Pin
leon de boer26-Jun-17 8:05
leon de boer26-Jun-17 8:05 
QuestionC programming Determine Students grade Pin
hoangtrungl22-Jun-17 22:47
hoangtrungl22-Jun-17 22:47 
AnswerRe: C programming Determine Students grade Pin
OriginalGriff22-Jun-17 22:54
mveOriginalGriff22-Jun-17 22:54 
AnswerRe: C programming Determine Students grade Pin
Jochen Arndt22-Jun-17 23:12
professionalJochen Arndt22-Jun-17 23:12 
QuestionRe: C programming Determine Students grade Pin
David Crow23-Jun-17 4:05
David Crow23-Jun-17 4:05 

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.