Re: isIconic issue again...



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,
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
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Icon flag Bit 7
    ... Yes, you could do that, but what if the contents of the icon were dependant ... So I could use it to draw a RiscCAD ... drawing into an icon in a window. ... if they are set, first, and then issue the redraw request. ...
    (comp.sys.acorn.programmer)
  • Icon not showing in window
    ... I create a window, get its DC, load an icon resource, then call DrawIcon to draw the icon on the DC. ... Is this because DrawIcon will not work until the windows is painted, or is there some other reason? ...
    (microsoft.public.win32.programmer.gdi)
  • Re: Icon flag Bit 7
    ... icon's definition would be set i.e. the icon 'requires task's ... So I could use it to draw a RiscCAD ... drawing into an icon in a window. ... Could you explain what you mean by drawing 'into an icon'? ...
    (comp.sys.acorn.programmer)
  • RE: APPCRASH - Microsoft Office Word has stopped working
    ... Disabling HP related files from the Startup: ... 1.Click Start Icon. ... On the User Account Control window, ... When I use Mailmerge - Envelopes, after printing the envelope and close Word ...
    (microsoft.public.word.mailmerge.fields)
  • RE: word 2007 app crash
    ... I just did the "quick fix" by changing my default printer to Microsoft ... If you does not have any other printer icon in Printers and Faxes folder, ... On the User Account Control window, ... Click Restart to apply the changes. ...
    (microsoft.public.word.application.errors)