getting Win32 Messagebox to work

Mark Moorhen Mark at Moorhen.com
Fri Oct 26 13:01:17 UTC 2018


On Friday, 26 October 2018 at 12:56:21 UTC, rikki cattermole 
wrote:
> 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);

Thanks again. It does work indeed. Now I'll have to try and get 
my head around it. But that will work out. eventually...


More information about the Digitalmars-d-learn mailing list