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, 100, 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With