c语言 对话框窗体 初始化WM_INITDIALOG 不能出图??怎么处理???
c语言 对话框窗体 初始化WM_INITDIALOG 不能出图??怎么处理???高手帮忙看看!!!
rc文件
程序代码:
#define MANIFEST 24 #define DLG_MAIN 100 #define DLG_MAIN1 101 #define IDC_IMG1 102 #define IDC_IMG2 103 #define IDC_BTN1 104 #define IDB_BITMAP1 200 #define IDB_BITMAP2 201 #include <windows.h> #include <commctrl.h> #include "resource.h" LANGUAGE 0,0 DLG_MAIN DIALOGEX 0,0,420,225 CAPTION "Dialog" FONT 8,"Ms Shell Dlg",0,0,0 STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME|DS_SHELLFONT|DS_3DLOOK BEGIN CONTROL "",IDC_IMG1,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_SUNKEN|SS_CENTERIMAGE|SS_BITMAP,10,20,285,175 CONTROL "IDC_BTN",IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,325,40,65,30 END 1 MANIFEST "./manifest.xml" IDB_BITMAP1 BITMAP DISCARDABLE "./111.bmp" IDB_BITMAP2 BITMAP DISCARDABLE "./222.bmp" DLG_MAIN1 DIALOGEX 10,10,435,230 CAPTION "IDD_DLG" FONT 8,"MS Sans Serif",0,0,0 STYLE WS_VISIBLE|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|DS_CENTER BEGIN CONTROL "",IDC_IMG2,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_SUNKEN|SS_CENTERIMAGE|SS_BITMAP,10,10,355,205 END
主程序
程序代码:
#include <windows.h> #include <commctrl.h> #include "resource.h" HINSTANCE hInst; BOOL CALLBACK DlgMain1(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { HBITMAP himg=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP2)); HBITMAP oldimage=(HBITMAP)SendMessage(GetDlgItem(hwndDlg, IDC_IMG2),STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)himg); if(oldimage != NULL) { DeleteObject(oldimage); } DeleteObject(himg); } return TRUE; case WM_CLOSE: { EndDialog(hwndDlg, 0); } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { } } return TRUE; } return FALSE; } BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { HBITMAP himg=LoadBitmap(hInst, MAKEINTRESOURCE(IDB_BITMAP1)); HBITMAP oldimage=(HBITMAP)SendMessage(GetDlgItem(hwndDlg, IDC_IMG1),STM_SETIMAGE,IMAGE_BITMAP,(LPARAM)himg); if(oldimage != NULL) { DeleteObject(oldimage); } DeleteObject(himg); } return TRUE; case WM_CLOSE: { EndDialog(hwndDlg, 0); } return TRUE; case WM_COMMAND: { switch(LOWORD(wParam)) { case IDC_BTN1: DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN1), NULL, (DLGPROC)DlgMain1); break; } } return TRUE; } return FALSE; } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { hInst=hInstance; InitCommonControls(); return DialogBox(hInst, MAKEINTRESOURCE(DLG_MAIN), NULL, (DLGPROC)DlgMain); }