Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
January 27, 2013 cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
WNDCLASS wc; - ok WNDCLASSA wc; - ok WNDCLASSW wc; - Error: undefined identifier WNDCLASSW, did you mean alias WNDCLASS? WNDCLASSEX wc; - Error: undefined identifier WNDCLASSEX, did you mean struct WNDCLASSEXA? WNDCLASSEXA wc; - ok WNDCLASSEXW wc; Error: undefined identifier WNDCLASSEXW, did you mean struct WNDCLASSEXA? code: import core.runtime; import core.sys.windows.windows; extern(Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { WNDCLASSEXA wc; return 0; } I most concerned about WNDCLASSEXW, that is the version I intend to use. |
January 27, 2013 Re: cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | Am 27.01.2013 14:10, schrieb rsk82:
> WNDCLASS wc; - ok
> WNDCLASSA wc; - ok
> WNDCLASSW wc; - Error: undefined identifier WNDCLASSW, did you mean
> alias WNDCLASS?
> WNDCLASSEX wc; - Error: undefined identifier WNDCLASSEX, did you mean
> struct WNDCLASSEXA?
> WNDCLASSEXA wc; - ok
> WNDCLASSEXW wc; Error: undefined identifier WNDCLASSEXW, did you mean
> struct WNDCLASSEXA?
>
> code:
>
> import core.runtime;
> import core.sys.windows.windows;
> extern(Windows)
> int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
> lpCmdLine, int iCmdShow) {
> WNDCLASSEXA wc;
> return 0;
> }
>
> I most concerned about WNDCLASSEXW, that is the version I intend to use.
Well WNDCLASSEXW is not defined inside core.sys.windows.windows.
If you need it just look up the definition in MSDN and define it yourself.
Kind Regards
Benjamin Thaut
|
January 27, 2013 Re: cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | On Sunday, 27 January 2013 at 13:36:25 UTC, Benjamin Thaut wrote:
> Well WNDCLASSEXW is not defined inside core.sys.windows.windows.
> If you need it just look up the definition in MSDN and define it yourself.
But how ? MSDN website shows only how to do it in C++, are there any examples how to define winapi structures ?
|
January 27, 2013 Re: cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Benjamin Thaut | 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; } |
January 27, 2013 Re: cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to rsk82 | 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 something like ascii and 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 |
January 27, 2013 Re: cannot initialize WNDCLASSW, WNDCLASSEX, WNDCLASSEXW window structs | ||||
---|---|---|---|---|
| ||||
Posted in reply to Phil Lavoie | Just to clarify: xxxA = Ascii; xxxW = Wide chars (UCS-2); 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. |
Copyright © 1999-2021 by the D Language Foundation