|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
IntroductionNormally Dialog Boxes are rectangular in shape. Various methods can be adopted to make them non-rectangular in shape. However, most of these methods are complicated and suited for application that uses skinning to create dialogs with the shape of a skin or image. If the required shape of the dialog is simple like a rectangle with rounded corners or an ellipse, then a much simpler method can be used. In this method multiple The CodeAll the required code is in the Step 1: Set Dialog styleTo change the shape of the dialog, in the ... // Remove caption and border SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) & (~(WS_CAPTION | WS_BORDER))); ... Step 2: Create individual regionsIndividual elliptic regions are then created using the coordinates of the dialog's window // Get the rectangle CRect rect; GetWindowRect(&rect); int w = rect.Width(); int h = rect.Height(); CRgn rgn1; CRgn rgn2; // Create the top ellipse rgn1.CreateEllipticRgn(1, 1, w, h/2 + 30); // Create the bottom ellipse rgn2.CreateEllipticRgn(1, h/2 - 30, w, h); Step 3: Combine the regions into oneThe regions are combined to create a single region. The combination is actually a UNION of all the individual regions // Combine the two ellipses CombineRgn(rgn1, rgn1, rgn2, RGN_OR); Step 4: Change the shape of the dialog to the regionThe dialogs shape is changed using the following code // Set the window region SetWindowRgn(static_cast<HRGN>(rgn1.GetSafeHandle()), TRUE); Step 5: Cleaning upThe rgn1.Detach();
rgn2.Detach();
History
|
||||||||||||||||||||||