Click here to Skip to main content
15,885,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionError occure when destructor is not virtual ? Pin
vikas amin24-Jan-06 1:28
vikas amin24-Jan-06 1:28 
AnswerRe: Error occure when destructor is not virtual ? Pin
Cedric Moonen24-Jan-06 2:51
Cedric Moonen24-Jan-06 2:51 
GeneralRe: Error occure when destructor is not virtual ? Pin
vikas amin24-Jan-06 19:22
vikas amin24-Jan-06 19:22 
AnswerRe: Error occure when destructor is not virtual ? Pin
sunit524-Jan-06 6:47
sunit524-Jan-06 6:47 
QuestionInstaller pack of MFC app. Pin
Aryan S24-Jan-06 1:26
Aryan S24-Jan-06 1:26 
QuestionStatic WndProc() Pin
virtualrush24-Jan-06 1:25
virtualrush24-Jan-06 1:25 
AnswerRe: Static WndProc() Pin
Vipin Aravind24-Jan-06 2:55
Vipin Aravind24-Jan-06 2:55 
AnswerRe: Static WndProc() Pin
Cedric Moonen24-Jan-06 3:02
Cedric Moonen24-Jan-06 3:02 
It is a little bit tricky to explain. First important point: the window procedure has to be static because static member functions and standard member functions behave differently (and don't have the same prototype). Standard member functions are kind of 'attached' to an instance of your class (so when they are called they 'know' to which instance they belong). In fact this is done by passing an additional parameter to your function, which the this parameter of the instance (and thus the pointer to the instance). This is done implicitely and the user doesn't know about it (it's hidden).
Now if you take a static member function, the behavior is different: for a static member function, it is shared among all instances of the class and thus, doesn't belong to any particular instance of the class. This has two consequences: first, there is no need for the implicit 'this' parameter (because the function doesn't blong to an instance) and second, the function doesn't have access to data from a particular instance: in a static function, you cannot access non-static member, you can only access to static member variables and functions (which are then shared among all instances).

For the windows procedure, it accept only a certain type of functions prototypes which are not member functions, thus the only way to have it in your class is to declare it static. The consequence is that it doesn't which instance it belongs to, so the need to 'save' first the this parameter associated with the specific window handle. This will allow you to get the 'this' parameter later and to be able to call the non-static window procedure of a particular instance.

Hope this helps, if you need some more precisions, don't hesitate to ask
QuestionCFormView in MDI Pin
anandforu24-Jan-06 0:14
anandforu24-Jan-06 0:14 
AnswerRe: CFormView in MDI Pin
Vipin Aravind24-Jan-06 2:51
Vipin Aravind24-Jan-06 2:51 
GeneralRe: CFormView in MDI Pin
anand_dayalans24-Jan-06 5:40
anand_dayalans24-Jan-06 5:40 
GeneralRe: CFormView in MDI Pin
anand_dayalans24-Jan-06 5:49
anand_dayalans24-Jan-06 5:49 
QuestionCreate TabView for IShellPropSheetExt Pin
souso2024-Jan-06 0:12
souso2024-Jan-06 0:12 
QuestionRemote Task manager Pin
SatyaDY24-Jan-06 0:03
SatyaDY24-Jan-06 0:03 
AnswerRe: Remote Task manager Pin
NarasimhuluM24-Jan-06 0:31
NarasimhuluM24-Jan-06 0:31 
AnswerRe: Remote Task manager Pin
Robsori24-Jan-06 0:33
Robsori24-Jan-06 0:33 
GeneralRe: Remote Task manager Pin
SatyaDY24-Jan-06 2:50
SatyaDY24-Jan-06 2:50 
QuestionSetParent Pin
heajinkim23-Jan-06 23:55
heajinkim23-Jan-06 23:55 
AnswerRe: SetParent Pin
domehead24-Jan-06 6:51
domehead24-Jan-06 6:51 
Questionhow to launch a notepad with the supplied information Pin
rampaul23-Jan-06 23:41
rampaul23-Jan-06 23:41 
AnswerRe: how to launch a notepad with the supplied information Pin
toxcct23-Jan-06 23:50
toxcct23-Jan-06 23:50 
AnswerRe: how to launch a notepad with the supplied information Pin
Owner drawn24-Jan-06 0:17
Owner drawn24-Jan-06 0:17 
AnswerRe: how to launch a notepad with the supplied information Pin
Prakash Nadar24-Jan-06 0:30
Prakash Nadar24-Jan-06 0:30 
GeneralRe: how to launch a notepad with the supplied information Pin
rampaul27-Jan-06 2:41
rampaul27-Jan-06 2:41 
QuestionDrag and Drop Pin
Anil_vvs23-Jan-06 23:38
Anil_vvs23-Jan-06 23:38 

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.