Click here to Skip to main content
16,007,858 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: URGENT required help on Printing Text size! Pin
ATC24-Sep-02 13:13
ATC24-Sep-02 13:13 
QuestionCArchive File Format? Pin
Matthew R. Miller23-Sep-02 14:46
Matthew R. Miller23-Sep-02 14:46 
AnswerRe: CArchive File Format? Pin
Neville Franks23-Sep-02 16:21
Neville Franks23-Sep-02 16:21 
AnswerRe: CArchive File Format? Pin
Ravi Bhavnani23-Sep-02 17:42
professionalRavi Bhavnani23-Sep-02 17:42 
GeneralEnumWindows... Pin
adamUK23-Sep-02 11:56
adamUK23-Sep-02 11:56 
GeneralRe: EnumWindows... Pin
Joaquín M López Muñoz23-Sep-02 12:00
Joaquín M López Muñoz23-Sep-02 12:00 
GeneralRe: EnumWindows... Pin
adamUK23-Sep-02 21:45
adamUK23-Sep-02 21:45 
GeneralMake sure it's a static function Pin
TyMatthews23-Sep-02 12:57
TyMatthews23-Sep-02 12:57 
Make sure GetWndProc is declared as a static function in your CAutoRestartDlg class. Most any time you define a Win32 API callback function inside a class you need to make the function static. This is because the Win32 API is written in C and C can't handle C++ classes and their polymorphic abilities. The API needs to know at exactly what position in memory your function resides so that it can call it. Polymorphism allows run-time determination of function addresses. Static functions -and static member variables, too- are allocated once when your app begins and never move for the duration of your app's existence. Only one copy of a static function exists in memory for the entire class; regardless of how many instances of the class you create.

Static functions are basically identical in nature to any old C-style function you'd create outside of your class. The only difference is that they're located in your classes' namespace, so you can keep things neat and know where to look for the code. That's really the only reason why they're even allowed in a class; you don't get any object-oriented features with static functions.

One additional note to preempt further frustration... static functions inside C++ classes cannot directly access anything inside the class except other static member variables or static functions. IE if you had an integer member variable named m_iMyVar, you could not read it nor set it unless it were also declared as being static. This is because only one copy of the function for the entire class exists; it would not know which object instance to use when setting the member variable or calling the other function. If you want to actually use something inside your CAutoRestartDlg class you'll have to use the LPARAM portion of your call to EnumWindows() and pass along a pointer to the class or a struct which contains a pointer. I can whip up some code if you'd like to see an example of this.

Sorry for the over-explanation if you knew this stuff already Smile | :) I guessed from your code that you probably already tried various casts.

Ty


"The significant problems we face cannot be solved at the same level of thinking we were at when we created them." -Albert Einstein


GeneralRe: Make sure it's a static function Pin
adamUK23-Sep-02 21:43
adamUK23-Sep-02 21:43 
GeneralRe: Make sure it's a static function Pin
Daniel Lohmann24-Sep-02 8:28
Daniel Lohmann24-Sep-02 8:28 
Generalwindow smoothing on static controls Pin
Anonymous23-Sep-02 11:42
Anonymous23-Sep-02 11:42 
GeneralRe: window smoothing on static controls Pin
Shog923-Sep-02 12:35
sitebuilderShog923-Sep-02 12:35 
Questionlocation of dll on users machine. Where to put it? Pin
ns23-Sep-02 11:22
ns23-Sep-02 11:22 
AnswerRe: location of dll on users machine. Where to put it? Pin
Joaquín M López Muñoz23-Sep-02 11:30
Joaquín M López Muñoz23-Sep-02 11:30 
Generalthanks very much Pin
ns23-Sep-02 11:32
ns23-Sep-02 11:32 
Generalproblem with pasting bitmap into a clipboard Pin
Mariusz Popiolek23-Sep-02 9:57
sussMariusz Popiolek23-Sep-02 9:57 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Joaquín M López Muñoz23-Sep-02 11:18
Joaquín M López Muñoz23-Sep-02 11:18 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Mariusz Popiolek24-Sep-02 0:28
sussMariusz Popiolek24-Sep-02 0:28 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Tomasz Sowinski24-Sep-02 0:07
Tomasz Sowinski24-Sep-02 0:07 
GeneralAttn: Shell Gurus Pin
Turtle needs Shell help23-Sep-02 9:53
sussTurtle needs Shell help23-Sep-02 9:53 
GeneralRe: Attn: Shell Gurus Pin
Stephane Rodriguez.23-Sep-02 11:21
Stephane Rodriguez.23-Sep-02 11:21 
GeneralRe: Attn: Shell Gurus Pin
Stephane Rodriguez.24-Sep-02 5:32
Stephane Rodriguez.24-Sep-02 5:32 
GeneralNew to computer programming Pin
Brandinimo23-Sep-02 9:30
Brandinimo23-Sep-02 9:30 
GeneralRe: New to computer programming Pin
Joaquín M López Muñoz23-Sep-02 9:41
Joaquín M López Muñoz23-Sep-02 9:41 
GeneralRe: New to computer programming Pin
SanShou23-Sep-02 9:52
SanShou23-Sep-02 9:52 

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.