getting Win32 Messagebox to work
Mark Moorhen
Mark at Moorhen.com
Fri Oct 26 12:36:42 UTC 2018
Hi,
I've recently started looking into D, and I'm afraid i'm gonna
need some support to get me going.
I work mostly on Windows, so i've downloaded the examples from
"https://github.com/AndrejMitrovic/DWinProgramming". Only these
examples do not work out-of-the-box on my machine (Win10, 64-bit
/ DMD32 D Compiler v2.082.0)
Now I'm trying to pass the content for a Messagebox as a variable
like this:
<code>
import core.runtime;
import win32.windef;
import win32.winuser;
extern (Windows)
void WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR
lpCmdLine, int iCmdShow)
{
string content = "Some random content.";
MessageBox(NULL, content , "Window title", 0);
}
</code>
When compiling I get the error:
HelloMsg.d(9): Error: function `win32.winuser.MessageBoxA(void*,
const(char)*, const(char)*, uint)` is not callable using argument
types `(typeof(null), string, string, int)`
HelloMsg.d(9): cannot pass argument `content` of type
`string` to parameter `const(char)*`
Can anyone help me out with this?
More information about the Digitalmars-d-learn
mailing list