Thank you so much for your help!

Below is the resource file,I compiled it with 

rcc -32 testd.rc

it then generated 
testd.res.

testd.rc:

#include <windows.h>


101 DIALOG 129, 26, 180, 70
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Show Info"
FONT 8, "MS Sans Serif"
BEGIN
    EDITTEXT        102, 19, 15, 147, 12, ES_AUTOHSCROLL
    PUSHBUTTON      "&Quit", IDCANCEL, 107, 42, 40, 14
    PUSHBUTTON      "&OK", IDOK, 28, 43, 40, 14
END


Below is the D source file:
module testd;

//import std.c.windows.windows;
import win32.windows;
import std.string;
import std.conv;

import std.stdio;

import core.runtime;
import core.stdc.stdlib;
import core.stdc.stdio;

//extern(Windows)
//int MessageBoxW(HWND handle,in wchar* text,in wchar* caption,int style);
extern(Windows)
int WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int 
nCmdShow)
{
    
    try
    {
        
                Runtime.initialize;
                runModuleUnitTests;
        
                WNDCLASSEX wc;
                //memset(&wc,0,wc.sizeof);
                wc.cbSize=wc.sizeof;
                wc.lpfnWndProc=&DefDlgProc;
                wc.cbWndExtra=DLGWINDOWEXTRA;
                wc.hInstance=hInstance;
                wc.hCursor=LoadCursor(null,IDC_ARROW);
                wc.hbrBackground=cast(HBRUSH)(COLOR_WINDOW+1);
                wc.lpszClassName=toStringz("dialog");
                if(!RegisterClassEx(&wc))
                {
                        MessageBox(null,toStringz("Register class 
failed"),toStringz("failed"),MB_OK|MB_ICONERROR);
                        return -1;
                }
        
        
                if(!CreateDialog/*DialogBox*/(hInstance, 
                     MAKEINTRESOURCE(101), 
                     null, cast(DLGPROC)&DialogFunc))
                {
                        MessageBox(null,toStringz("Create Dialog 
failed!"),toStringz("failed"),MB_OK|MB_ICONINFORMATION);
                        return -1;
                }
                return 0;
    }

    catch (Object o)            // catch any uncaught exceptions
    {
                MessageBoxW(HWND.init, cast(wchar*)o.toString, "Fatal Error",
                    MB_OK | MB_ICONEXCLAMATION);
        
        
                return -1;              // failed
        
    }
    finally
    {
                
    }

        // run finalizers; terminate garbage collector
    Runtime.terminate;
                
    return 0;
}



int  DialogFunc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
        switch(msg)
        {
                case WM_COMMAND:
                switch(LOWORD(wParam))
                {
                        case IDOK:
                        EndDialog(hwnd,1);
                        return 1;
                        case IDCANCEL:
                        EndDialog(hwnd,0);
                        return 1;
                }
                break;
                case WM_CLOSE:
                        EndDialog(hwnd,0);
                        return 1;
        }
        return 0;
}

I compiled with 
bud -O -release -gui -clean testd.d testd.res and it generated testd.exe.
When I run testd.exe,first I heard a beep,then windows popped up an error
messagebox:
testd.exe has encountered a problem and needs to close.We are sorry for the 
inconvenience.

I tried to upload the screen shot but failed.

So where should I start from?

Regards,
Sam

Reply via email to