Re: isIconic issue again...
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Thu, 03 Jan 2008 18:10:11 -0500
As far as I can recall, this code was applicable only in Win16 and perhaps NT 3.x, because
these systems allowed you to actually draw the icon (you could do cool animated icons, for
example). Once we went to the current model with the taskbar, however, this became
irrelevant. It has been largely irrelevant for a decade, but like far too much of MFC
there is a reluctance in the MFC group to bring it into conformance with the modern API
world. It appears to be largely clutter these days.
IsIconic does return TRUE if the window is iconic; any rumor to the contrary is nonsense.
But in modern Windows, an iconic window is never called to draw itself, so the OnPaint
doesn't happen.
You can prove that IsIconic returns TRUE for iconic windows trivially by writing an
OnTimer handler
void CMyDialog::OnTimer(UINT nIDEvent)
{
if(IsIconic())
MessageBeep(MB_ICONASTERISK);
else
MessageBeep(MB_ICONHAND);
}
Set your timer to some useful value like 1000ms. You will get different beeps depending
on whether the window is minimized or not. But if you put a MessageBeep (or even a
breakpoint) in the IsIconic branch of the OnPaint handler shown below, it will never be
taken.
joe
On Thu, 3 Jan 2008 13:26:33 -0800 (PST), camelot <scosmo@xxxxxxxxxxxxx> wrote:
Hello,Joseph M. Newcomer [MVP]
I'm trying to undestand every piece of code the vc wirard create. In
particular, I'm not able un understand when the function IsIconic()
became true in this piece of code:
void CGUI1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this);
SendMessage(WM_ICONERASEBKGND,
reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);
// Centrare l'icona nel rettangolo client.
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;
// Disegnare l'icona
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
I tried to search the old posts and seems that under XP this funtion
never became true, is it true?
Camelot
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- isIconic issue again...
- From: camelot
- isIconic issue again...
- Prev by Date: Re: isIconic issue again...
- Next by Date: Re: isIconic issue again...
- Previous by thread: Re: isIconic issue again...
- Next by thread: Automation timeout problem
- Index(es):
Relevant Pages
|