我做了一个对话框程序DlgA,DlgA上有一ButtonA,左击ButtonA,弹出对话框DlgB,
我要在DlgB中改变其对话框图标-Icon图片,怎样做? 在对话框程序DlgA很容易,在其构造孙数中加入m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);就可以了,但在DlgB中就不能这样了.
我要在DlgB中改变其对话框图标-Icon图片,怎样做? 在对话框程序DlgA很容易,在其构造孙数中加入m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);就可以了,但在DlgB中就不能这样了.
::SendMessage(hDlg, WM_SETICON, 0, (LPARAM)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ICON1)));
非常感谢:初始化对话框B时,我这样写:
::SendMessage(GetDlgItem(IDD_DIALOG1)->GetSafeHwnd(), WM_SETICON, 0, (LPARAM)LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_ALARM)));
但还是不成功,问题出在哪?
Think u!
If true as your said. But my DialogB's Icon is different from DialogA,There is no use if I use "AfxGetApp()->LoadIcon(IDI_ALARM)"
in the construction function in DialogB.
I have solve with your help.By the way, to phiger(phiger),
You are wrong,an application instance can have more than one application icon.
AfxGetApp( )-> LoadIcon (IDI_ICON1), // icon handle
TRUE); // FALSE=16x16 bit icon
m_hIcon沒定義??
樓主的代碼行不通哦。
HICON hicon = ::LoadIcon(AfxGetApp()->m_hInstance, MAKEINTRESOURCE(IDI_ICON1));
SetClassLong(AfxGetMainWnd()->m_hWnd, GCL_HICON, (long)hicon);
I am trying it, I will give the reasult as soon as I have finished it.
I am unsuccessful to do as your said.to phiger(phiger):
I am gald to tell you that you are right at this time, with your help, I have solved my problem, think u!
To all, thinks.