View mode: basic / threaded / horizontal-split · Log in · Help
January 27, 2013
Re: now I didn't have RegisterClassExW, how to import that ?
On Sunday, 27 January 2013 at 19:31:59 UTC, John Chapman wrote:
> Actually, replace "LPCTSTR" above with "LPCWSTR".

Ok, fine, now the linker *again*. I have some lenghty code, if is 
strip it down I post it here.
January 29, 2013
Re: now I didn't have RegisterClassExW, how to import that ?
In case you had not seen in the other thread:

On Sunday, 27 January 2013 at 14:06:00 UTC, rsk82 wrote:
> Ok, nevermind, found, it, it was so easy that it simply didn't 
> have to had an example:
>
>     struct WNDCLASSEXW {
>       UINT      cbSize;
>       UINT      style;
>       WNDPROC   lpfnWndProc;
>       int       cbClsExtra;
>       int       cbWndExtra;
>       HINSTANCE hInstance;
>       HICON     hIcon;
>       HCURSOR   hCursor;
>       HBRUSH    hbrBackground;
>       LPCWSTR   lpszMenuName;
>       LPCWSTR   lpszClassName;
>       HICON     hIconSm;
>     }

If you find yourself desiring other bindings of the win32 api and
don't want them to define them by hand, a project was started
some time ago by Stewart Gordon that contains an almost complete
set of bindings:
http://dsource.org/projects/bindings/wiki/WindowsApi

Set the import directory of your compiler appropriately and use
it like that:
import win32.winuser; //example, where you will probably find
wndclassexw

Additionnally, you should know that SOMETHINGA and SOMETHINGW
means A for ascii and W for wide chars (UCS-2, so every char
is two bytes instead of one). Normally, the api was intented to
be used without the extra letter at the end:

WNDCLASSEX wndclass; //No suffix: defaults to ascii.

When people compile with the preprocessor Unicode defined, then
all aliases are mapped to their W counterpart. What changes is
how you pass and receive strings.
Keep in mind they must be null terminated (as in C).

The microsoft bunch also defined another macro that would help
you make your code independant of the version used, it is called
TCHAR.
TCHAR * someString; //Will be char * without unicode or wchar
with.
someString = "My window class".toUTFz!( TCHAR * ); //This is how
I use the std library to convert my strings. Try to keep a handle
on strings that might be kept by the OS, to prevent them from
being garbage collected.

WNDCLASSEX wndclass;
...
wndclass.lpszClassName = someString;

Peace,
Phil

...

And because I forgot to mention, to mimic the preprocessor
directive, the bindings use a version conditional compilation.
Therefore, you use it like that:
rdmd -I/where/you/put/the/bindings -version=Unicode yourmodule.d

You can double check in the code, but IIRC, only the first letter
is capsed.
January 29, 2013
Re: now I didn't have RegisterClassExW, how to import that ?
On Tuesday, 29 January 2013 at 19:04:04 UTC, Phil Lavoie wrote:
> In case you had not seen in the other thread:
>
> On Sunday, 27 January 2013 at 14:06:00 UTC, rsk82 wrote:
>> Ok, nevermind, found, it, it was so easy that it simply didn't 
>> have to had an example:
>>
>>    struct WNDCLASSEXW {
>>      UINT      cbSize;
>>      UINT      style;
>>      WNDPROC   lpfnWndProc;
>>      int       cbClsExtra;
>>      int       cbWndExtra;
>>      HINSTANCE hInstance;
>>      HICON     hIcon;
>>      HCURSOR   hCursor;
>>      HBRUSH    hbrBackground;
>>      LPCWSTR   lpszMenuName;
>>      LPCWSTR   lpszClassName;
>>      HICON     hIconSm;
>>    }
>
> If you find yourself desiring other bindings of the win32 api 
> and
> don't want them to define them by hand, a project was started
> some time ago by Stewart Gordon that contains an almost complete
> set of bindings:
> http://dsource.org/projects/bindings/wiki/WindowsApi
>
> Set the import directory of your compiler appropriately and use
> it like that:
> import win32.winuser; //example, where you will probably find
> wndclassexw
>
> Additionnally, you should know that SOMETHINGA and SOMETHINGW
> means A for ascii and W for wide chars (UCS-2, so every char
> is two bytes instead of one). Normally, the api was intented to
> be used without the extra letter at the end:
>
> WNDCLASSEX wndclass; //No suffix: defaults to ascii.
>
> When people compile with the preprocessor Unicode defined, then
> all aliases are mapped to their W counterpart. What changes is
> how you pass and receive strings.
> Keep in mind they must be null terminated (as in C).
>
> The microsoft bunch also defined another macro that would help
> you make your code independant of the version used, it is called
> TCHAR.
> TCHAR * someString; //Will be char * without unicode or wchar
> with.
> someString = "My window class".toUTFz!( TCHAR * ); //This is how
> I use the std library to convert my strings. Try to keep a 
> handle
> on strings that might be kept by the OS, to prevent them from
> being garbage collected.
>
> WNDCLASSEX wndclass;
> ...
> wndclass.lpszClassName = someString;
>
> Peace,
> Phil
>
> ...
>
> And because I forgot to mention, to mimic the preprocessor
> directive, the bindings use a version conditional compilation.
> Therefore, you use it like that:
> rdmd -I/where/you/put/the/bindings -version=Unicode yourmodule.d
>
> You can double check in the code, but IIRC, only the first 
> letter
> is capsed.

Pragmas are included inside the modules (so you dont have to 
explicitly link against libraries). There is a 1 to 1 mapping 
with the genuine win32 headers. Example:
winuser.h becomes win32.winuser;
wingdi.h becomes win32.wingdi;
etc...
Next ›   Last »
1 2
Top | Discussion index | About this forum | D home