Click here to Skip to main content
15,920,633 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Changing the root in CFileDialog Pin
g_sol_116-May-05 2:00
g_sol_116-May-05 2:00 
GeneralRe: Changing the root in CFileDialog Pin
PJ Arends16-May-05 7:23
professionalPJ Arends16-May-05 7:23 
GeneralThreads using up too much CPU Pin
15-May-05 3:47
suss15-May-05 3:47 
GeneralRe: Threads using up too much CPU Pin
the one dono15-May-05 6:20
the one dono15-May-05 6:20 
QuestionQuestion: How to retrieve the HINSTANCE when you have HWND? Pin
lxcid14-May-05 23:50
lxcid14-May-05 23:50 
AnswerRe: Question: How to retrieve the HINSTANCE when you have HWND? Pin
bharadwajgangadhar15-May-05 2:05
bharadwajgangadhar15-May-05 2:05 
AnswerRe: Question: How to retrieve the HINSTANCE when you have HWND? Pin
PJ Arends15-May-05 10:42
professionalPJ Arends15-May-05 10:42 
GeneralVisual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas14-May-05 23:08
Axonn Echysttas14-May-05 23:08 
Hi everybody : ). A short question about callbacks in Visual C++. I got a Visual C++ DLL which is called by a VB Application. The Visual C++ DLL is passed the address of the outside callback function using a local function in it, like this:

<br />
void SetCallbackRoutine(long ExternalAddress)<br />
{<br />
	ptrCallbackRoutine = ExternalAddress;<br />
}<br />


ptrCallbackRoutine is declared like this:

<br />
#pragma bss_seg("DLLShare")<br />
long ptrCallbackRoutine;<br />
#pragma bss_seg()<br />


Now... ptrCallbackRoutine memorizes its data fine. The address is ok. When I try to callback my original VB function from the SetCallbackRoutine that I already written above, it works. This works:

<br />
void SetCallbackRoutine(long ExternalAddress)<br />
{<br />
	ptrCallbackRoutine = ExternalAddress;<br />
<br />
	typedef void (__stdcall *OutsideFunction)(BSTR stringVar);<br />
	OutsideFunction FunctionCall;<br />
	FunctionCall = (OutsideFunction)ptrCallbackRoutine;<br />
	BSTR temp = ChartoBSTR("Testing");<br />
	FunctionCall(SysAllocString(temp));<br />
}<br />


However, when I try to do this from within a TimerProc, it crashes. This crashes:

<br />
VOID CALLBACK TmrProc (HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)<br />
{<br />
	KillTimer(NULL, ctTimerID);<br />
        <br />
	typedef void (__stdcall *OutsideFunction)(BSTR stringVar);<br />
	OutsideFunction FunctionCall;<br />
	FunctionCall = (OutsideFunction)ptrCallbackRoutine;<br />
	BSTR temp = ChartoBSTR("Testing");<br />
	FunctionCall(SysAllocString(temp));<br />
}<br />


It's not about KillTimer. I also tried without that instruction and it still doesn't work.

I suppose that the DLL cannot call a function from VB whenever it wants? It can only call it at particular time during execution?? How can I work around this? Is there any way that I can call back on the VB function at any given time??

Thank you for your help : ).

-= E C H Y S T T A S =-
The Greater Mind Balance
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
the one dono15-May-05 4:47
the one dono15-May-05 4:47 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas15-May-05 5:47
Axonn Echysttas15-May-05 5:47 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
the one dono15-May-05 6:34
the one dono15-May-05 6:34 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas15-May-05 11:59
Axonn Echysttas15-May-05 11:59 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
ThatsAlok15-May-05 18:27
ThatsAlok15-May-05 18:27 
GeneralRe: Visual C++ Callbacks Issue - Auto Callbacks Pin
Axonn Echysttas16-May-05 2:08
Axonn Echysttas16-May-05 2:08 
QuestionGetting WM_DROPFILES from child control? Pin
matthew18014-May-05 19:26
matthew18014-May-05 19:26 
GeneralAddFontResource Pin
Inov14-May-05 16:52
Inov14-May-05 16:52 
GeneralRe: AddFontResource Pin
Jack Puppy14-May-05 17:38
Jack Puppy14-May-05 17:38 
Generaldialog box Pin
rain71114-May-05 14:57
rain71114-May-05 14:57 
GeneralRe: dialog box Pin
David Crow15-May-05 16:28
David Crow15-May-05 16:28 
GeneralRe: dialog box Pin
rain71122-May-05 3:47
rain71122-May-05 3:47 
GeneralRe: dialog box Pin
David Crow23-May-05 1:56
David Crow23-May-05 1:56 
GeneralRe: dialog box Pin
ThatsAlok15-May-05 18:35
ThatsAlok15-May-05 18:35 
GeneralRe: dialog box Pin
rain71122-May-05 3:50
rain71122-May-05 3:50 
GeneralHTML parser Pin
princess sarah14-May-05 12:21
princess sarah14-May-05 12:21 
GeneralRe: HTML parser Pin
Jack Puppy14-May-05 15:35
Jack Puppy14-May-05 15:35 

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.