IsIconic到底怎么用

abc3240666 2011-10-14 04:16:02
void CtestDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

Dialog的右上角已经添加了最大化和最小化按钮了
为什么最小化时,IsIconic死活都是FALSE,究竟是神马情况啊?

在工程的其他地方想通过IsIconic来判断也是总是FALSE,郁闷啊。
...全文
441 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
abc3240666 2011-10-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 huangcheng90 的回复:]
void CXXDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (IsIconic())
{
MessageBox(L"Iconic!");
KillTimer(1);
}
CDialogEx::OnTimer(nIDEvent);
}
[/Quote]
这样做的话,只有在发生重绘的时候才会弹出MessageBox,否则最小化后,什么都不操作的话,不会弹出来提示框的
abc3240666 2011-10-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 jkmaple 的回复:]
//The following example attaches an HWND to the CWindow object and
//calls CWindow::IsIconic() to determine if the window is minimized

CWindow myWindow;
myWindow.Attach(hWnd);
BOOL bIconic = my……
[/Quote]
这位仁兄的方法可行,阿里嘎到!
jkmaple 2011-10-14
  • 打赏
  • 举报
回复
//The following example attaches an HWND to the CWindow object and
//calls CWindow::IsIconic() to determine if the window is minimized

CWindow myWindow;
myWindow.Attach(hWnd);
BOOL bIconic = myWindow.IsIconic();

abc3240666 2011-10-14
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 huangcheng90 的回复:]
void CXXDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (IsIconic())
{
MessageBox(L"Iconic!");
KillTimer(1);
}
CDialogEx::OnTimer(nIDEvent);
}
[/Quote]IsIconic跟Timer有啥关系呢?放哪不都一样么?
Dreadnought 2011-10-14
  • 打赏
  • 举报
回复
void CXXDlg::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (IsIconic())
{
MessageBox(L"Iconic!");
KillTimer(1);
}
CDialogEx::OnTimer(nIDEvent);
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧