In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use VC to make dynamic pop-up dialog boxes". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian to study and learn "how to use VC to make dynamic pop-up dialog boxes" together.
In Network Ant, if an error occurs during the download process or when the download is complete, you can see a small, dynamic pop-up dialog box in the center of the screen. How is this dynamic pop-up dialog box implemented?
I. Selection method
Usually, we can add some initialization settings to the dialog box in the WM_INDIALOG event response function, such as changing the position and size of the window. Similarly, we can make the dialog box appear small to large in the WM_INDIALOG event response function. But how do you change the size of the dialog box? In the programming process, we usually use MoveWindow function to dynamically adjust the size of the dialog box, but MoveWindow function has its limitations: first, it is slow; second, due to the well-known MFC memory leak, if you repeatedly call MoveWindow function to change the size of the dialog box, MoveWindow can not clear the screen "clean"(you can try this in actual programming), which is obviously not what we need. Can you find another way to quickly change the window size? We know that SetWindowRgn function can change the window display area, then, before the dialog box is displayed, let the program hide the dialog box first, and then let the dialog box display area continue to grow, so as to achieve the dynamic display of the dialog box.
Before continuing, let's introduce the specific usage of SetWindowRgn. The following is its call format:
int SetWindowRgn( HRGN hRgn, BOOL bRedraw );
hRgn: A handle to a region, usually created by a CRgn object.
bRedraw: Indicates whether the window redraws after setting the window display area.
II. Application examples
Next, we take the program's "Help Dialog Box" dynamic pop-up as an example to introduce how to realize the dynamic pop-up display of dialog boxes through programming. Add a mapping to WM_INDIALOG in the CAboutDlg class, and edit its response function OnInitDialog. The specific content of this function is set as follows:
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//hide dialog box
ShowWindow(SW_HIDE);
CRect dlgRect;
GetClientRect(&&dlgRect);
CPoint centerPoint;
centerPoint.x=dlgRect.Width()/2;
centerPoint.y=dlgRect.Height()/2;
//Get the midpoint coordinates of the dialog box
CRgn testrgn;
this-〉ShowWindow(SW_HIDE);
int m=GetSystemMetrics(SM_CYSIZEFRAME);
//The following code implements dynamic pop-up of dialog boxes
for (int i=10;i〈dlgRect.Width()/2+2m;i+=1)
{
testrgn.CreateRectRgn(centerPoint.x-i,centerPoint.y-i,centerPoint.x+i,centerPoint.y+i);
SetWindowRgn((HRGN) testrgn,TRUE);
ShowWindow(SW_SHOW);
CenterWindow();
testrgn.DeleteObject();
}
return TRUE;
}
The program's code is relatively simple, compiled into the program's Help menu, you will see a dialog box from small to large jump on the screen.
Thank you for reading, the above is "how to use VC to make dynamic pop-up dialog box" content, after learning this article, I believe we have a deeper understanding of how to use VC to make dynamic pop-up dialog box, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.