How to create Windows in D using win32?

Hello, I am trying to open a window with win32 in D, and I have a little problem. The program is called when CreateWindowA is called.

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 run exe, the program crashes, and I have:

Process terminated with status -1073740791

on code :: blocks.

+4
source share
3 answers

The error code -1073740791 (or 0xc0000409) is caused by a stack buffer overflow (not an overflow like when the stack was started, but a write to a place on the stack where you should not write).

The called call looks normal. But you did not tell us the class registration code, and, more importantly, WndProc you register. I'm not sure how you do it in D, but your WndProc needs to be declared __stdcall so that it matches the calling convention adopted by Windows. This is a common problem that causes CreateWindow to crash.

+11
source

Yes, that was the problem:

I did not declare WndProc as __stdcall the way you do it in D,

 extern (Windows) int windowRuntime(HWND window, UINT message, WPARAM wParam, LPARAM lParam) 

thank you for your help.

+1
source

I would suggest using gtkD or QTD instead of Win32. Two widget libraries are mature and powerful, but very easy to use. And you have cross-platform support.

0
source

All Articles