Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8449037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:35:29+00:00 2026-06-10T10:35:29+00:00

I use d-ide to develop with D. With D 2.059 compiler version, the project

  • 0

I use d-ide to develop with D.

With D 2.059 compiler version, the project Windows template compile et run like a charm.

With D 2.060 compiler version, the project Windows template does not compile and rises an error :

main.d(41): Error: cannot implicitly convert expression (& WindowProc) of type extern  
(Windows) int function(void* hWnd, uint message, uint wParam, int lParam) to extern  
(Windows) int function(void*, uint, uint, int) nothrow

Following is the code, thanks for your suggestions.

// Example code taken from winsamp.d (Listed under D examples)

import core.runtime;
import std.c.windows.windows;
import std.string;

enum IDC_BTNCLICK     = 101;
enum IDC_BTNDONTCLICK = 102;

extern(Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
    int result;
    void exceptionHandler(Throwable e) { throw e; }

    try
    {
        Runtime.initialize(&exceptionHandler);
        result = myWinMain(hInstance, hPrevInstance, lpCmdLine, iCmdShow);
        Runtime.terminate(&exceptionHandler);
    }
    catch (Throwable e)
    {
        MessageBoxA(null, e.toString().toStringz, "Error", MB_OK | MB_ICONEXCLAMATION);
        result = 0;
    }

    return result;
}

int myWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
    string caption = "The Hello Program";
    string className = "DWndClass";
    HWND hWnd, btnClick, btnDontClick;
    MSG  msg;
    WNDCLASS wndclass;

    wndclass.style         = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc   = &WindowProc;
    wndclass.cbClsExtra    = 0;
    wndclass.cbWndExtra    = 0;
    wndclass.hInstance     = hInstance;
    wndclass.hIcon         = LoadIconA(null, IDI_APPLICATION);
    wndclass.hCursor       = LoadCursorA(null, IDC_CROSS);
    wndclass.hbrBackground = cast(HBRUSH)GetStockObject(WHITE_BRUSH);
    wndclass.lpszMenuName  = null;
    wndclass.lpszClassName = className.toStringz;

    if (!RegisterClassA(&wndclass))
    {
        MessageBoxA(null, "Couldn't register Window Class!", caption.toStringz, MB_ICONERROR);
        return 0;
    }

    hWnd = CreateWindowA(className.toStringz,  // window class name
                         caption.toStringz,    // window caption
                         WS_THICKFRAME   |
                         WS_MAXIMIZEBOX  |
                         WS_MINIMIZEBOX  |
                         WS_SYSMENU      |
                         WS_VISIBLE,           // window style
                         CW_USEDEFAULT,        // initial x position
                         CW_USEDEFAULT,        // initial y position
                         600,                  // initial x size
                         400,                  // initial y size
                         HWND_DESKTOP,         // parent window handle
                         null,                 // window menu handle
                         hInstance,            // program instance handle
                         null);                // creation parameters

    if (hWnd is null)
    {
        MessageBoxA(null, "Couldn't create window.", caption.toStringz, MB_ICONERROR);
        return 0;
    }

    btnClick = CreateWindowA("BUTTON", "Click Me", WS_CHILD | WS_VISIBLE,
                             0, 0, 100, 25, hWnd, cast(HMENU)IDC_BTNCLICK, hInstance, null);

    btnDontClick = CreateWindowA("BUTTON", "DON'T CLICK!", WS_CHILD | WS_VISIBLE,
                                 110, 0, 100, 25, hWnd, cast(HMENU)IDC_BTNDONTCLICK, hInstance, null);

    ShowWindow(hWnd, iCmdShow);
    UpdateWindow(hWnd);

    while (GetMessageA(&msg, null, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessageA(&msg);
    }

    return msg.wParam;
}

int* p;
extern(Windows)
LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case IDC_BTNCLICK:
                    if (HIWORD(wParam) == BN_CLICKED)
                        MessageBoxA(hWnd, "Hello, world!", "Greeting",
                                    MB_OK | MB_ICONINFORMATION);

                    break;

                case IDC_BTNDONTCLICK:
                    if (HIWORD(wParam) == BN_CLICKED)
                    {
                        MessageBoxA(hWnd, "You've been warned...", "Prepare to GP fault",
                                    MB_OK | MB_ICONEXCLAMATION);
                        *p = 1;
                    }

                    break;

                default:
            }

            break;
        }

        case WM_PAINT:
        {
            enum text = "D Does Windows";
            PAINTSTRUCT ps;

            HDC  dc = BeginPaint(hWnd, &ps);
            scope(exit) EndPaint(hWnd, &ps);
            RECT r;
            GetClientRect(hWnd, &r);
            HFONT font = CreateFontA(80, 0, 0, 0, FW_EXTRABOLD, FALSE, FALSE,
                                     FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
                                     DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, "Arial");
            HGDIOBJ old = SelectObject(dc, cast(HGDIOBJ) font);
            SetTextAlign(dc, TA_CENTER | TA_BASELINE);
            TextOutA(dc, r.right / 2, r.bottom / 2, text.toStringz, text.length);
            DeleteObject(SelectObject(dc, old));

            break;
        }

        case WM_DESTROY:
            PostQuitMessage(0);
            break;

        default:
            break;
    }

    return DefWindowProcA(hWnd, message, wParam, lParam);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:35:31+00:00Added an answer on June 10, 2026 at 10:35 am

    It’s not about D-IDE but more on update for last version of Digital Mars Compiler 2.060 Windows version.

    No matter, the solution I’ve found is to put the attribute “nothrow” in front of the window function : nothrow LRESULT WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)

    So this question is answered for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use the Eclipse IDE to develop, compile, and run my Java projects. Today,
I use Netbeans IDE. My hibernate.cfg.xml looks like this: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE hibernate-configuration
What windows C IDE can I use that will use gcc to compile and
I would like to use Apple's Xcode IDE to develop applications on the OS
Can I configure the VS.NET 2008 IDE to use gcc as a compiler?
I am using Eclipse IDE to develop android apps. But I want to use
I'm using IntelliJ Idea as an IDE to develop AIR applications. I use flexmojos-4.0
I am using Corona to develop ios app. I use XCode as IDE. But
I use eclipse IDE for developing my GWT and android apps. I would like
I'm now learning iPhone development with Monotouch and use Mono Develop for IDE. Everything

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.