How to create a shaped window using a setwindowrgn function to select Blog from GHJ1976

xiaoxiao2021-03-06  41

How to create a shaped window using the setWindowRGN function

Time: 2000/10/11 21: 06ENET Technology

Many games and tools software use a shaped window to come out. In fact, it is difficult to create a shaped window from a technical difficulty, but is there any effect that is mainly due to whether or not the creativity is surprising. The following is a simple introduction to how to make a shaped window using SETWINDOWRGN. SetwindowRGN is a new SDK function. This function defines the drawing message and the mouse message in a specified area of ​​the window, in fact, enables the window to become the specified irregular shape. First use AppWizard to create a dialog-based application and use the resource editor from the resource from the resource from the resource. Some default controls, titles, and boundaries. Add a CRGN data member to the dialogue to create a window area using the data member. Class Ctestdlg: Public CDialog {... private: CRGN M_RGN; / / WINDOW Region ...} Modify the OnInitDialog function of the dialog, create an ellipse area and call SETWINDOWRGN to assign the area to the window: BOOL CTESTDLG :: OnNitDialog () {cdialog :: OnInitDialog () // Get the size of the dialog CRECT RCDIALOG; GetClientRect (RCDIALOG) // Creates an elliptical area and uses the SETWINDOWRGN reset dialog. m_rgn.createelllipticRGN (0, 0, rcdialog.width (), rcdialog.Height ()); setwindowrgn (getsafehwnd (), (hrgn) m_ rgn, true); return true;} A simple shaped window has been generated, if compiled Running the project, there will be an elliptical window. The following code is processed in the OnPAint message, making the dialog have a stereoscopic effect. Void ctestdlg :: onpAint () {cpaintdc PainTDC (this); // Get the device // Settings Draw the border PainTDC. SELECSTOCKOBJECT (NULL_PEN); // Get the color of the sphere ColorRef ballcolor = RGB (0, 0, 255) ); Byte Byred = GtrValue (ballcolor); Byte Bygreen = getGvalue (ballcolor); Byte Byblue = getBValue (ballcolor); // Get the sphere range. Rect rcdialog; getClientRect (rcdialog); // draws the smallest unit INT NUNITS = Min (rcDialog.right, rcdialog.bottom); // calculates the horizontal direction and the vertical direction. FLOAT FLTSTEPHORZ = (FLOAT) RCDialog.right / NUnits; float fltstepvert = (float) rcdialog.bottom / NUnits; int Nellipse = NUNITS / 3; // Start drawing multiple ellipses to achieve visual stereoscopic. CBRUSH brush; // Picture of a color filler using BallColor.

转载请注明原文地址:https://www.9cbs.com/read-74339.html

New Post(0)