Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / What is the HWND data type letter in dll stringtable?

Author
Message
Skywriter
15
Years of Service
User Offline
Joined: 27th Aug 2008
Playing:
Posted: 21st Jan 2010 18:03
I just simply want to return a window handle in my dll so i can use it in other functions, but i cant figure out what letter i should use in the dll's string table or maybe some conversion is there to be done? Please help.

Sky
Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 21st Jan 2010 19:07
Use L or D. DBPro doesn't have a HWND type so you have to use an integer or dword.

Skywriter
15
Years of Service
User Offline
Joined: 27th Aug 2008
Playing:
Posted: 21st Jan 2010 20:12
Ok, so i have to perform a typecast like:
int createbutton()
{
button=CreateWindow(blah blah...);
return (int)button;
}
Is that correct?

Sky
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 21st Jan 2010 20:28
Isn't HWND just a wrapper for DWORD, which in turn is equivalent to long?

Skywriter
15
Years of Service
User Offline
Joined: 27th Aug 2008
Playing:
Posted: 21st Jan 2010 20:38
When i tried to return it like DWORD (without typecast) it generates an erron in compiler. It sais it cannot convert DWORD to HWND.

Sky
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 22nd Jan 2010 09:34 Edited at: 22nd Jan 2010 09:36
DWORD Function()
{
HWND hWnd;
...
return (DWORD)hWnd;
}

And in the stringtable:
1, "Function[%L%Decorated%Description"

I don't see why it wouldn't work.
To retrieve data:

Function Use(DWORD handle)
{
HWND hWnd = (HWND)handle;
...
}

Cheers!
Sven B

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Jan 2010 19:07
Unnecessary - simply set the return type to a HWND and return a HWND, but keep the resource string as an L or D.

As long as the value you are returning is 4 bytes in size and not a float, this works perfectly well. It works just as well for input parameters too.

I do this all of the time in my plug-ins with no problem at all.

Skywriter
15
Years of Service
User Offline
Joined: 27th Aug 2008
Playing:
Posted: 23rd Jan 2010 09:49
Yeah, that's correct IanM. Thereis no need for typecast. I was having trouble with function decorations, thats why i wasn't able to launch my functions from dll. I thought that letter was a mistake, but it's not. I usec extern"c" and all functions work well now without any need for decorations. Thanks for a good advice lads. Cheers

Sky

Login to post a reply

Server time is: 2024-04-24 02:42:20
Your offset time is: 2024-04-24 02:42:20