delphi IsIconic

The role of IsIconic() is to determine whether the window is in a minimized state (after clicking the minimize button). 
For a normal dialog, if you add AfxMessageBox("haha") below if (IsIconic()), you will find that the message box will not pop up.
The reason is that the if (IsIconic()) code is inside the OnPaint() function. After you minimize the dialog, the OnPaint() function does not run even though the value of IsIconic() is TRUE.
Because OnPaint() responds to the WM_PAINT message, and the WM_PAINT message is for the client area.
A minimized window does not need to redraw the client area.
To verify this, you can set a timer and write if(IsIconic()) MessageBeep(MB_OK) in the OnTimer() function; when you click the minimize button, you will hear a beep.
So what exactly does this code do? Will it never be executed? of course not.
Give two examples. First, if you force a WM_PAINT message, it will execute. Second, special dialog boxes. For example, a ToolBox-style dialog.
This dialog is not displayed on the taskbar, after minimization it becomes a small bar on the desktop. At this time, if it is blocked, a WM_PAINT message will be sent, thereby executing that code.
In short, this code is generally unnecessary, and I don't know its special purpose, but we can at least know how it works.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325203726&siteId=291194637