How do I create Windows in D with win32?
Hello I'm trying to open a window with win32 in D, and I've got a little problem. The program crashes when I call CreateWindowA.
Here is my code :
this.fenetrePrincipale = CreateWindowA(this.classeFenetre.lpszClassName, toStringz(title), WS_OVERLAPPEDWINDOW, 0, 0, 100, 1开发者_StackOverflow中文版00, null, null, this.hInstance, null);
with:
this.classeFenetre.lpszClassName = toStringz("classeF");
this.hInstance = GetModuleHandleA(null);
and
string title = "test";
When I launch the exe, the program crashes and I've got:
Process terminated with status -1073740791
on code::blocks.
The error code -1073740791 (or 0xc0000409) is caused by a stack buffer overrun (not overflow, as in running out of stack, but writing to a place in stack where you are not supposed to write to).
The call that you've shown is looks OK. But you didn't show us the class registration code, and more importantly, the WndProc
you register. I am not sure how you do it in D, but your WndProc
needs to be declared __stdcall
, so that it matches the calling convention assumed by Windows. This is a common problem that causes crashes on CreateWindow
.
Yeah that was the problem :
I didn't declared the WndProc as __stdcall the way you do that in D is
extern (Windows) int windowRuntime(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
thanks for your help.
I would suggest using gtkD or QTD instead of Win32. The two widget libraries are mature and powerful, yet very simple to use. And you have cross-platform support as well.
精彩评论