Click here to Skip to main content
15,921,660 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: WIndows Device Driver Books Pin
David Crow8-Sep-03 3:22
David Crow8-Sep-03 3:22 
GeneralProblems accessing small/big icon versions frmo a single Icon resource Pin
ohadp8-Sep-03 2:44
ohadp8-Sep-03 2:44 
GeneralRe: Problems accessing small/big icon versions frmo a single Icon resource Pin
David Crow8-Sep-03 3:01
David Crow8-Sep-03 3:01 
GeneralRe: Problems accessing small/big icon versions frmo a single Icon resource Pin
ohadp8-Sep-03 3:17
ohadp8-Sep-03 3:17 
QuestionHow to create a win32 static library? Pin
willyfu8-Sep-03 2:43
willyfu8-Sep-03 2:43 
AnswerRe: How to create a win32 static library? Pin
Brad Sokol8-Sep-03 6:03
Brad Sokol8-Sep-03 6:03 
GeneralProblem with pointer to function Pin
Anonymous8-Sep-03 2:27
Anonymous8-Sep-03 2:27 
GeneralRe: Problem with pointer to function Pin
ohadp8-Sep-03 2:38
ohadp8-Sep-03 2:38 
The reason this occurs is because the type of your function (the one which is a part of a class) isn't void(*func)(void).

Whenever you want to call a classe's function you need to call it in the context of an object of that class (i.e. supply a 'this' pointer), but when you'll try to call the function you received with SetCallback you won't have any 'this' (should the code would compile, which it doesn't Smile | :)

here's some code to help put you in the right direction:
(btw, this is also usable when you want a classe's function to run in it's own thread

<br />
class MyClass<br />
{<br />
public:<br />
   void MyFunc(void);<br />
};<br />
<br />
<br />
void __cdecl worker(void *pVar)<br />
{<br />
   ((MyClass*)pVar)->MyFunc();<br />
}<br />
<br />
// lets take the constructo for example<br />
MyClass::MyClass()<br />
{<br />
   // this would allow an external function to execute 'MyFunc', since you<br />
   // pass it a pointer to this<br />
   worker(this);<br />
}<br />
<br />
<br />


What you need to do is seperate handling of global functions and class-contained functions.
I'm trying to understnad from your example what you were trying to do, perhaps you can define an abstract class 'IMyFunc', put a function 'MyFunc' there, then have all the classes you want to have this possible behaviour implement this class/interface and then you can call an external function, suplpy 'this' and have it call the function, or save the 'this' instead of the function pointer...

hmm, this came out abit confusing, perhaps you can elaborate mroe on waht you're trying to do Smile | :)
GeneralRe: Problem with pointer to function Pin
David Crow8-Sep-03 3:19
David Crow8-Sep-03 3:19 
GeneralRe: Problem with pointer to function Pin
Yongjun Pan8-Sep-03 18:39
Yongjun Pan8-Sep-03 18:39 
GeneralSetting time interval for timer event in Console app Pin
haritadala8-Sep-03 2:21
haritadala8-Sep-03 2:21 
GeneralRe: Setting time interval for timer event in Console app Pin
David Crow8-Sep-03 3:31
David Crow8-Sep-03 3:31 
GeneralRe: Setting time interval for timer event in Console app Pin
haritadala8-Sep-03 4:00
haritadala8-Sep-03 4:00 
GeneralRe: Setting time interval for timer event in Console app Pin
David Crow8-Sep-03 4:10
David Crow8-Sep-03 4:10 
GeneralRe: Setting time interval for timer event in Console app Pin
haritadala8-Sep-03 4:15
haritadala8-Sep-03 4:15 
GeneralSEH problem between debug and release version Pin
crazyzhou8-Sep-03 1:51
crazyzhou8-Sep-03 1:51 
GeneralRe: SEH problem between debug and release version Pin
Brad Sokol8-Sep-03 4:24
Brad Sokol8-Sep-03 4:24 
GeneralErrors in handle parent dialog send message to a modeless dialog Pin
Jeef8-Sep-03 0:18
Jeef8-Sep-03 0:18 
Generalpointer var Pin
macmac388-Sep-03 0:11
macmac388-Sep-03 0:11 
GeneralRe: pointer var Pin
Alexander M.,8-Sep-03 0:29
Alexander M.,8-Sep-03 0:29 
GeneralRe: pointer var Pin
macmac388-Sep-03 0:41
macmac388-Sep-03 0:41 
GeneralRe: pointer var Pin
jhwurmbach8-Sep-03 1:23
jhwurmbach8-Sep-03 1:23 
GeneralGUI database query Pin
coda_x8-Sep-03 0:08
coda_x8-Sep-03 0:08 
GeneralRe: GUI database query Pin
David Crow8-Sep-03 3:35
David Crow8-Sep-03 3:35 
GeneralCHttpView - Viewing and modifing post header Pin
Brian Delahunty8-Sep-03 0:07
Brian Delahunty8-Sep-03 0:07 

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.