Click here to Skip to main content
16,005,206 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: GetClassName - Determine if "Edit" window class Pin
bob1697230-Jul-09 12:10
bob1697230-Jul-09 12:10 
GeneralRe: GetClassName - Determine if "Edit" window class Pin
Richard Andrew x6430-Jul-09 12:15
professionalRichard Andrew x6430-Jul-09 12:15 
GeneralRe: GetClassName - Determine if "Edit" window class Pin
bob1697231-Jul-09 3:40
bob1697231-Jul-09 3:40 
AnswerRe: GetClassName - Determine if "Edit" window class Pin
«_Superman_»30-Jul-09 14:35
professional«_Superman_»30-Jul-09 14:35 
QuestionSize Of Control Objects Pin
ForNow30-Jul-09 6:34
ForNow30-Jul-09 6:34 
AnswerRe: Size Of Control Objects Pin
Bacon Ultimate Cheeseburger1-Aug-09 17:57
Bacon Ultimate Cheeseburger1-Aug-09 17:57 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 19:39
ForNow1-Aug-09 19:39 
GeneralRe: Size Of Control Objects (Part 1) Pin
Bacon Ultimate Cheeseburger1-Aug-09 23:57
Bacon Ultimate Cheeseburger1-Aug-09 23:57 
ForNow wrote:
The Sublassing concept I thought refers to messages that were sent to a Control/window by specfying a Window/CWnd object as the 3rd parm of the DDX_CONTROL macro


Yes but it's much more than that. MFC contains it's own message pump and special handling when creating a window. In order for MFC to intercept messages sent to a window it's own internal window procedure must be called. Anytime you call the Create() method of a CWnd or derived object the window is first created and then automatically subclassed. This eliminates two things; the need for you register a window class (e.g. WNDCLASS) and having to supply a [custom] window procedure.

Dialogs however are a bit different. When you create a dialog it automatically creates all of it's child controls when it receives a WM_INITDIALOG message. This completely bypasses the internal window creation handler preventing MFC from processing messages for that window. Even if you make a call to CWnd::Attach() MFC will not receive the messages for those controls (see below). This also applies to windows created by directly calling Windows API functions such as CreateWindowEx() and CreateDialog().

To solve this problem explicit subclassing must be used. This does three things...first it associates the object with the specified window handle by calling Attach(), second it calls the PreSubclassWindow() method of the object and finally it subclasses the window by replacing the original window procedure with the one internal to MFC. It also does some error checking to prevent a window from being subclassed more than once (the debug build will assert if you attempt this). From that point on the object will receive all window message before the original window procedure is called.

This is important if you wish to provide custom functionality in a derived control class. For instance if you wanted to display a context menu when the user right clicks on a list box item you would need to create a class derived from CListBox and add a message handler for WM_RBUTTONDOWN. If the window control is not subclassed the message handler would never be called.


... to be continue ...

1300 calories of pure beef goodness can't be wrong!

GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger1-Aug-09 23:58
Bacon Ultimate Cheeseburger1-Aug-09 23:58 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 1:31
ForNow2-Aug-09 1:31 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 3:02
Bacon Ultimate Cheeseburger2-Aug-09 3:02 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 5:02
ForNow2-Aug-09 5:02 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 14:57
Bacon Ultimate Cheeseburger2-Aug-09 14:57 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 5:15
ForNow2-Aug-09 5:15 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 15:04
Bacon Ultimate Cheeseburger2-Aug-09 15:04 
GeneralRe: Size Of Control Objects (part 2) Pin
ForNow2-Aug-09 15:17
ForNow2-Aug-09 15:17 
GeneralRe: Size Of Control Objects (part 2) Pin
Bacon Ultimate Cheeseburger2-Aug-09 15:38
Bacon Ultimate Cheeseburger2-Aug-09 15:38 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 20:49
ForNow1-Aug-09 20:49 
GeneralRe: Size Of Control Objects Pin
Bacon Ultimate Cheeseburger1-Aug-09 21:36
Bacon Ultimate Cheeseburger1-Aug-09 21:36 
GeneralRe: Size Of Control Objects Pin
ForNow1-Aug-09 21:49
ForNow1-Aug-09 21:49 
Questionvoid pointer? Pin
sam_psycho30-Jul-09 6:21
sam_psycho30-Jul-09 6:21 
AnswerRe: void pointer? Pin
molesworth30-Jul-09 7:49
molesworth30-Jul-09 7:49 
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 8:06
sam_psycho30-Jul-09 8:06 
GeneralRe: void pointer? [modified] Pin
Joe Woodbury30-Jul-09 8:20
professionalJoe Woodbury30-Jul-09 8:20 
GeneralRe: void pointer? Pin
sam_psycho30-Jul-09 8:30
sam_psycho30-Jul-09 8:30 

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.