簡體   English   中英

如何正確添加MFC鏈接控制到Dialog?

[英]How to properly add MFC Link Control to Dialog?

我為游戲制作了一個插件DLL。 現在我想在我的插件中添加許可證激活,因此我使用Visual Studio資源向導創建了一個簡單的Dialog(LicenseActivation.rc)。

當附加DLL時,我將HMODULE保存為m_hModule成員變量,並在新線程中運行以下代碼

DialogBox(m_hModule, MAKEINTRESOURCE(IDD_DIALOG1), NULL, About);

About回調函數的實現如下

INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    PrintDebug(L"About(%d, %#x, %d, %d)", hDlg, message, wParam, lParam);
    switch (message)
    {
    case WM_INITDIALOG:
        //PrintDebug(L"case WM_INITDIALOG");
        return (INT_PTR)TRUE;

    case WM_COMMAND:
        //PrintDebug(L"case WM_COMMAND");
        switch (LOWORD(wParam))
        {
        case IDOK:
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        case IDCANCEL:
            EndDialog(hDlg, LOWORD(wParam));
            return (INT_PTR)TRUE;
        }
        break;
    }
    return (INT_PTR)FALSE;
}

這是Dialog資源

Visual Studio 2015編輯器中的對話框

在我將MFC鏈接控制元素添加到Dialog之前它運行正常,運行時會顯示Dialog並打印以下調試消息

[11848] About(1380712, 0x30, 1544171096, 0)
[11848] About(1380712, 0x110, 6359660, 0)
[11848] About(1380712, 0x46, 0, 253295812)
[11848] About(1380712, 0x1c, 1, 0)
[11848] About(1380712, 0x86, 0, 0)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)
[11848] About(1380712, 0x7f, 1, 0)
[11848] About(1380712, 0x6, 1, 0)
[11848] About(1380712, 0x400, 0, 0)
[11848] About(1380712, 0x127, 3, 0)
[11848] About(1380712, 0x128, 196609, 0)
[11848] About(1380712, 0x31f, 1, 0)
[11848] About(1380712, 0x18, 1, 0)
[11848] About(1380712, 0x46, 0, 253296052)
[11848] About(1380712, 0x85, 1, 0)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)
[11848] About(1380712, 0x7f, 1, 0)
[11848] About(1380712, 0x14, 16855179, 0)
[11848] About(1380712, 0x136, 16855179, 1380712)
[11848] About(1380712, 0x47, 0, 253296052)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)
[11848] About(1380712, 0x7f, 1, 0)
[11848] About(1380712, 0xf, 0, 0)
[11848] About(1380712, 0x135, 16855179, 6359660)
[11848] About(1380712, 0x135, 16855179, 1445800)
[11848] About(1380712, 0x138, 16855179, 1446218)
[11848] About(1380712, 0x133, 16855179, 2363706)
[11848] About(1380712, 0x133, 16855179, 2363706)
[11848] About(1380712, 0x138, 16855179, 1577080)
[11848] About(1380712, 0x7f, 2, 96)
[11848] About(1380712, 0x7f, 0, 96)
[11848] About(1380712, 0x7f, 1, 96)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)
[11848] About(1380712, 0x7f, 2, 0)
[11848] About(1380712, 0x7f, 0, 0)

但是一旦我將MFC鏈接控制添加到對話框 ,對話框就不會出現並打印以下調試消息

[9748] About(3018840, 0x30, 1393179198, 0)
[9748] About(3018840, 0x90, 0, 0)
[9748] About(3018840, 0x2, 0, 0)
[9748] About(3018840, 0x82, 0, 0)

我看到你有一個簡單的Win32程序。

鏈接控制僅適用於MFC項目。 您既沒有從CDialogEx派生的對話框,也沒有使用任何技術以MFC的方式創建或處理控件。

這里這里有 win32的普通超級鏈接控件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM