ok, I added more points. Could I get this translated to C++ MFC for a dialog box?
Main Topics
Browse All TopicsI have a program somebody gave me that creates an non-square window. Has anybody else seen this? What I need to know is if there is some way to do this for a Dialog box instead of a SDI. Here is the code for SDI:
#include <windows.h>
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static char szAppName[] = "App Name";
static char szAppTitle[] = "App Name";
HWND hwnd;
MSG msg;
WNDCLASSEX wndclass;
wndclass.cbSize = sizeof(wndclass);
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
wndclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
RegisterClassEx(&wndclass)
hwnd = CreateWindow (szAppName, szAppTitle,WS_OVERLAPPEDWI
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
RECT rect;
HRGN Rgn;
POINT points[5];
int AutoMagic = -1;
switch (iMsg)
{
case WM_CREATE :
SetWindowRgn(hwnd,NULL,FAL
GetWindowRect(hwnd,&rect);
points[0].x = points[0].y = points[1].x = 0;
points[1].y = GetSystemMetrics(SM_CYMENU
points[3].x = points[4].x = rect.right - rect.left;
points[4].y = 0;
points[3].y = points[1].y;
points[2].x = (rect.right - rect.left)/2;
points[2].y = rect.bottom - rect.top;
Rgn = CreatePolygonRgn(points,5,
SetWindowRgn(hwnd,Rgn,TRUE
return 0;
case WM_PAINT :
hdc = BeginPaint(hwnd, &ps);
GetClientRect(hwnd,&rect);
DrawText(hdc, "Inside the Window!", AutoMagic, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER);
EndPaint(hwnd, &ps);
return 0;
case WM_DESTROY :
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hwnd, iMsg, wParam, lParam);
}
This is pretty clever programming, but is it possible for Dialog boxes and can I implement it in C++ using MSVC++5.0?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
In the Window Procedure of your dialog, add:
case WM_INITDIALOG:
SetWindowRgn(hwnd,NULL,FAL
GetWindowRect(hwnd,&rect);
points[0].x = points[0].y = points[1].x = 0;
points[1].y = GetSystemMetrics(SM_CYMENU
GetSystemMetrics(SM_CYCAPT
points[3].x = points[4].x = rect.right - rect.left;
points[4].y = 0;
points[3].y = points[1].y;
points[2].x = (rect.right - rect.left)/2;
points[2].y = rect.bottom - rect.top;
Rgn = CreatePolygonRgn(points,5,
SetWindowRgn(hwnd,Rgn,TRUE
return 0;
If you want this to be done in MFC, do this:
1. Create a dialog based app using AppWizard - It will generate you a dialog based app.
2. Click on View->ClassWizard. Select the class named CMyDlg.
In the messageList select WM_INITDIALOG and doubleclick it.
paste the code:
SetWindowRgn(NULL,FALSE);
GetWindowRect(&rect);
points[0].x = points[0].y = points[1].x = 0;
points[1].y = GetSystemMetrics(SM_CYMENU
GetSystemMetrics(SM_CYCAPT
points[3].x = points[4].x = rect.right - rect.left;
points[4].y = 0;
points[3].y = points[1].y;
points[2].x = (rect.right - rect.left)/2;
points[2].y = rect.bottom - rect.top;
Rgn = CreatePolygonRgn(points,5,
SetWindowRgn(Rgn,TRUE);
return 0;
Business Accounts
Answer for Membership
by: thuiPosted on 1998-04-03 at 22:11:00ID: 1412526
The "trick" is to use SetWindowRgn() on the dialog. After calling SetWindowRgn() with the region of how you want the dialog to look.