getting Win32 Messagebox to work

rikki cattermole rikki at cattermole.co.nz
Fri Oct 26 12:56:21 UTC 2018


On 27/10/2018 1:46 AM, Mark Moorhen wrote:
> On Friday, 26 October 2018 at 12:39:13 UTC, rikki cattermole wrote:
>> On 27/10/2018 1:36 AM, Mark Moorhen wrote:
>>> [...]
>>
>> alias string = immutable(char)[];
>>
>> A slice (string in this case) is a length + pointer pair. You need to 
>> add .ptr on content with a cast to get to const(char)*.
> 
> Thanks for your quick reply.
> 
> However when I do:
> cast(const(char)*) content.ptr;
> 
> I get a error:
> 
> 
> HelloMsg.d(9): Error: `cast(const(char)*)cast(immutable(char)*)content` 
> has no effect
This should work:

string content = "Some random content.";
MessageBoxA(null, cast(const(char)*)content.ptr, 
cast(const(char)*)"Window title".ptr, 0);


More information about the Digitalmars-d-learn mailing list