|
Use GetWindowLong() with the GWL_HINSTANCE flag.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
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
|
|
|
|
|
Hi,
What does ChartoBSTR do? Where does the returned pointer point to?
Can you post the function.
Cheers
|
|
|
|
|
Oh. ChartoBSTR is a simple function that does the said conversion. I copy pasted it into my Application. It has nothing to do with the problem, since in one function it works and in other function of the same file, it crashes. It's not about this function. I also tried without it, just making up some dummy string. And I got the same behavior.
With or without that function, calling back my VB function works from in the first case, and doesn't work in the second case. So... I'm kind of puzzled . Could it be that I can't call a VB function unless I called from VB first?
Since in the first case, I call a Visual C++ function, that, in turn, calls my function from VB. This works. But if I want to call the function from VB from that TimerProc (or from anywhere else for that matter), it doesn't work. I tried calling this from a HookProc too... if I do that, the process that contains the hook crashes. Grrrr : ).
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I was taking a long shot there.
I thought a possibility was that ChartoBSTR was returning a pointer to a local variable that gets removed from the stack when the function returns.
This might cause your code to crash some times and work other times.
Good luck
|
|
|
|
|
Hm... so... any other ideas? Anybody??? : )
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Axonn Echysttas wrote:
ChartoBSTR
HI Axonn ,
What about using T2BSTR() defined in ATLCONV.h or CComBSTR("helloo").Detach().
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hello Alok : D. As I said, it has nothing to do with that function. Read my previous posts from within this thread...
Hm... I can't figure out what's going on, so I'm gonna have to work around the problem, since I can't really solve it.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
Greetings,
I have a window that contains a listview that I would like to have receive dropped files from an explorer window. I'm creating the listview in a function called from the WM_CREATE message of the main window, like this:
CreateWindowEx(
WS_EX_ACCEPTFILES,
WC_LISTVIEW, TEXT(""),
WS_VISIBLE | WS_BORDER | WS_CHILD | LVS_ICON | LVS_EDITLABELS | LVS_AUTOARRANGE,
100, 0, rcl.right - 200, rcl.bottom,
hWndParent, (HMENU)IDC_MAIN_LISTVIEW, hInst, NULL);
Nothing fancy here, the control is created and works, but the problem comes when I try to drop a file onto the control: it seems no WM_DROPFILES message is sent... If I set my main window to accept files then the WM_DROPFILES message fires, but I need the listview to receive the drops, not the main window (which is just a container any way.)
What am I missing? I've been searching all day and can't seem to find any specific information on this. Also, I'm working with (and prefer) the WinAPI (or MFC if absolutely necessary.)
Any insight would be greatly appreciated.
Thanks,
Matthew
|
|
|
|
|
How to use "AddFontResource" ?
I've read an article about it on MSDN Library, but I still confused with.
It's declared at wingdi.h (Included at windows.h)
int AddFontResource(<br />
LPCTSTR lpszFilename
);
I have a code:
<br />
...<br />
<br />
#define IDC_STATIC_TEXT 5007<br />
<br />
...<br />
<br />
case WM_CREATE:<br />
CreateWindow ("STATIC", "-- WinTest --\nApplication created by Inov",<br />
WS_CHILD | WS_VISIBLE | SS_CENTER,<br />
0, 40, 290, 120,<br />
hWnd, (HMENU) IDC_STATIC_TEXT, hInst, NULL);<br />
<br />
SendDlgItemMessage (hWnd, IDC_STATIC_TEXT, WM_SETFONT,<br />
(WPARAM) AddFontResource ("C:\\Fonts\\Verdana.ttf"), 0);<br />
break;<br />
<br />
...<br />
I am going to make my static text font to be Verdana, but I couldn't.
[ ++ Inov ++ ]
|
|
|
|
|
AddFontResource is used to add a font to the user's machine.
To set the font for a given control, use CreateFont + WM_SETFONT.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
How to extract dialog box from EXE file.
I have this EXE file it is for a game. When you run the game and you hit [ENTER] a dialog box popup to enter some chat. I would like to know where I can find this dialog box so I can edit its shape?
I appreciate your respond.
Note I used PE explorer but did not extarct dialog boxes only icon stuff and strings
|
|
|
|
|
Use Visual Studio to open the .exe as a resource.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
What version of Visual Studio I should use if my operating system is windows-Xp sp2.
oh is it on the net for free download??
thanks
After all, Today is the Tomorrow you worried about Yesterday
|
|
|
|
|
rain711 wrote:
What version of Visual Studio I should use if my operating system is windows-Xp sp2.
Whichever one is supported on that platform.
rain711 wrote:
oh is it on the net for free download??
If "it" refers to Visual Studio, the answer is no.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
|
Resource hacker extrat dialog boxex and icon stuff
but I think when I disasmble my exe. It said thet the EXE has no dialog or any resources . But indeed when you execute the EXE and when I hit "Enter" on the keyboard a dialog box popup for chating and I have to hit "Enter" again if I want to send the message.
After all, Today is the Tomorrow you worried about Yesterday
|
|
|
|
|
hi all,
i would like to parse the html code to reach the url in the web page, i had get the html code already, so how do i parse till i get to the links?
thnx in advance
|
|
|
|
|
You can use regular expressions to do this. I don't have the exact formula offhand, but a quick search at Google returned this page, which should give you the idea.
Processing HTML using Regular Expressions
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
thnx Jack.
i know i can do it by hand, but it is a headache.
i've seen some vb6.0 code that do this parsing using classes like HTMLLinkElement,MSHTML.HTMLDocument. is there any classes in vc++ equivelant to thease?
|
|
|
|
|
I've never actually used HTML in vc++ for anything other than to simply display a page. (CHtmlView)
I just tried a search at CP, and it returned this article:
http://www.codeproject.com/internet/parse_html.asp
which looks like it might be what you're after, or should at least lead you to something you could use.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Thanks Jack for your help.
it is what i need
|
|
|
|
|
Hi,
I have created a stand alone application (exe) file using matlab,and VC++ compiler, but my problem is that it works only on my computer, On other computers it gives the following error:
The dynamic link liberary libmmfile.dll could not be found in the specified path c:\......
any suggestions friends?
Thanks and have a great week-end.
Irene
|
|
|
|
|
irene_haydon wrote:
The dynamic link liberary libmmfile.dll could not be found in the specified path c:\......
Distribute the file libmmfile.dll with the app.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hello, Irene
It looks like your application is dependent from one of the MatLab's libraries. So, if you want your application to work on other computers (where MatLab is not installed) you need to distribute these libraries with you application. Try to search MatLab documentation for redistributing applications created with MatLab or just copy all dll’s, which are missed. You can use "Dependency Walker" tool to resolve all needed libraries.
With best regards,
Andrew
|
|
|
|