Click here to Skip to main content
15,907,000 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Closing an application Pin
Jim Crafton6-Feb-04 13:05
Jim Crafton6-Feb-04 13:05 
GeneralSerial implementation deadlock problem Pin
rmnowick6-Feb-04 11:25
rmnowick6-Feb-04 11:25 
QuestionHelp converting a demo project? Pin
DanYELL6-Feb-04 11:09
DanYELL6-Feb-04 11:09 
GeneralWINHTTP Pin
Jack Reed6-Feb-04 10:53
Jack Reed6-Feb-04 10:53 
GeneralRe: WINHTTP Pin
Gerald Schwab6-Feb-04 11:18
Gerald Schwab6-Feb-04 11:18 
GeneralRe: WINHTTP Pin
Jack Reed6-Feb-04 11:33
Jack Reed6-Feb-04 11:33 
GeneralCallback function within a class Pin
Cael6-Feb-04 9:58
Cael6-Feb-04 9:58 
GeneralRe: Callback function within a class Pin
Antti Keskinen6-Feb-04 11:12
Antti Keskinen6-Feb-04 11:12 
The most easiest approach to this problem is not by following Mellertson's article.

Like you stated, you are creating a class that manages a custom button control. What you are doing, infact, is much similar to MFC: a wrapper class for a Win32 API routine. MFC, although, implements everything based on the window-thinking: every control is derived from CWnd.

Instead of using Mellertson's article, consider the following approach:
1. In your program, create a new instance of the class. When this instance is created, all member functions and variables of the class become valid.
2. Call a 'second-phase' constructor that creates the actual Windows button control. As all member functions are properly initialized in step 1, you can refer to a non-static member function to handle the WNDPROC's job.

This approach allows each instance of the button class to function independently, ESPECIALLY if you use dynamic creation of the objects. Just remember that the clean-up work must be implemented very carefully to avoid memory leaks.

In the 'second-phase' constructor, you can use the Win32 API routines to create the button control, and the returned HWND to replace the window procedure function.

-Antti Keskinen

----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralRe: Callback function within a class Pin
Cael6-Feb-04 13:20
Cael6-Feb-04 13:20 
GeneralRe: Callback function within a class Pin
Antti Keskinen8-Feb-04 9:59
Antti Keskinen8-Feb-04 9:59 
GeneralRe: Callback function within a class Pin
Cael8-Feb-04 16:32
Cael8-Feb-04 16:32 
GeneralHelp with MFC forms Pin
iboux6-Feb-04 9:52
iboux6-Feb-04 9:52 
GeneralRe: Help with MFC forms Pin
David Crow6-Feb-04 10:52
David Crow6-Feb-04 10:52 
QuestionUse CreateThread or _beginthreadex? Pin
xatanu6-Feb-04 9:41
xatanu6-Feb-04 9:41 
AnswerRe: Use CreateThread or _beginthreadex? Pin
Andrew Walker6-Feb-04 17:48
Andrew Walker6-Feb-04 17:48 
AnswerRe: Use CreateThread or _beginthreadex? Pin
Alexander M.,7-Feb-04 3:04
Alexander M.,7-Feb-04 3:04 
GeneralCMainFrame in DLL Pin
sjcomp6-Feb-04 9:04
sjcomp6-Feb-04 9:04 
GeneralImage processing! Pin
tuantt6-Feb-04 8:42
tuantt6-Feb-04 8:42 
GeneralRe: Image processing! Pin
sjcomp6-Feb-04 9:11
sjcomp6-Feb-04 9:11 
GeneralRe: Image processing! Pin
l a u r e n6-Feb-04 15:32
l a u r e n6-Feb-04 15:32 
General(Newbie) Outlining in VC7 IDE Pin
Ravi Bhavnani6-Feb-04 8:31
professionalRavi Bhavnani6-Feb-04 8:31 
GeneralRe: (Newbie) Outlining in VC7 IDE - edited Pin
Michael P Butler6-Feb-04 8:47
Michael P Butler6-Feb-04 8:47 
GeneralRe: (Newbie) Outlining in VC7 IDE - edited Pin
Ravi Bhavnani6-Feb-04 8:53
professionalRavi Bhavnani6-Feb-04 8:53 
GeneralRe: (Newbie) Outlining in VC7 IDE - edited Pin
l a u r e n6-Feb-04 15:33
l a u r e n6-Feb-04 15:33 
GeneralRe: (Newbie) Outlining in VC7 IDE - edited Pin
Ravi Bhavnani6-Feb-04 15:44
professionalRavi Bhavnani6-Feb-04 15:44 

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.