代碼如下:
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include "resource.h"
#define DLG_MAIN 100
#define IDCANCEL 1003
#define IDOK 1004
void MESSAGE();
HINSTANCE hInst;
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG: ;
return TRUE;
case WM_CLOSE:
{
EndDialog(hwndDlg, 0);
}
return TRUE;
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case IDCANCEL: ;
case IDOK: ;
}
}
return TRUE;
}
return DefWindowProc(hwndDlg,uMsg,wParam,lParam);
}
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
hInst = hInstance;
HWND hdlg = CreateDialog(hInst,MAKEINTRESOURCE(DLG_MAIN), GetDesktopWindow(),DlgMain);
//RegisterClassA(&hdlg);
if (!hdlg)
{
GetLastError();
MessageBox(NULL,
"Call to CreateDialog failed!",
"Windows Desktop Guided Tour",
NULL);
return 1;
}
ShowWindow(hdlg,SW_SHOW);
UpdateWindow(hdlg);
MESSAGE();
return 0;//DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain);
}
void MESSAGE(){
MSG msg = {0};
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
uj5u.com熱心網友回復:
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_DIALOG1), NULL,DialogProc);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
uj5u.com熱心網友回復:
但還是回傳的null,只能顯示錯誤的彈窗。uj5u.com熱心網友回復:
我在rc 資源時出現了resource.rc (23): warning RC2182 : duplicate dialog control ID 0這個警告,會不會是這個原因。uj5u.com熱心網友回復:
只要 DLG_MAINuj5u.com熱心網友回復:
你的DLG_MAIN對話框資源有效嗎?uj5u.com熱心網友回復:
我定義了對話框id的
uj5u.com熱心網友回復:
你可能有多個同名的dialogiduj5u.com熱心網友回復:
我把這個dialog刪掉之后重新建了一個就好了,困擾了我好久了終于解決了


轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/30271.html
標籤:基礎類
