Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying dialogs in different shapes 1

Status
Not open for further replies.

atumbomb

Programmer
Jun 20, 2001
9
0
0
US
When working with MFC apps, is it possible to display the dialog box in different shapes? (i.e. circle, triangle, blob) Squares are getting boring. :) ~~~~~~~~~~~~~~~~~~~~~~
Adam Horky
Sealevel Systems, Inc.
(864)843-4343
~~~~~~~~~~~~~~~~~~~~~~
 
#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#define WIN_NAME &quot;CircleGUI&quot;
#define WIN_X 220
#define WIN_Y 200

LRESULT CALLBACK WindowProc( HWND,
UINT,
WPARAM,
LPARAM );

int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{

HWND hWnd;
MSG mSg;
WNDCLASSEX winClass;

winClass.cbSize=sizeof( WNDCLASSEX );
winClass.style =CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winClass.lpfnWndProc=WindowProc;
winClass.cbClsExtra =0;
winClass.cbWndExtra =0;
winClass.hInstance =hinstance;
winClass.hIcon=LoadIcon(NULL,IDI_APPLICATION );
winClass.hCursor=LoadCursor(NULL,IDC_ARROW );
winClass.hbrBackground=( HBRUSH )GetStockObject( BLACK_BRUSH );
winClass.lpszMenuName =NULL;
winClass.lpszClassName=&quot;WIN_SHELL&quot;;
winClass.hIconSm =NULL;

RegisterClassEx( &winClass );
hWnd=CreateWindow( &quot;WIN_SHELL&quot;,
WIN_NAME,
WS_POPUP,
CW_USEDEFAULT,
CW_USEDEFAULT,
WIN_X,
WIN_Y,
NULL,
NULL,
hinstance,
NULL );

ShowWindow( hWnd,ncmdshow );
UpdateWindow( hWnd );

while( GetMessage( &mSg,NULL,0,0 ) )
{
TranslateMessage( &mSg );
DispatchMessage ( &mSg );
}
return ( mSg.wParam );
}


LRESULT CALLBACK WindowProc( HWND hWnd,
UINT mSg,
WPARAM wParam,
LPARAM lParam )
{

PAINTSTRUCT ps;
HDC hdc;
POINT pt;

switch( mSg )
{

case WM_CREATE:

SetWindowRgn( hWnd,CreateEllipticRgn( 10,25,
220,200 ),TRUE );
break;

case WM_PAINT:

hdc=BeginPaint( hWnd,&ps);
EndPaint( hWnd,&ps );

break;

case WM_LBUTTONUP:

PostQuitMessage( 0 );

break;

case WM_MOUSEMOVE:

GetCursorPos( &pt );
SendMessage( hWnd,WM_SYSCOMMAND,SC_MOVE+2,
MAKELPARAM( pt.x,pt.y ) );

break;

default:return( DefWindowProc( hWnd, mSg, wParam, lParam ) );
}
return 0;

}

I don't know if the MFC encapsulates this, but you can accomplish it with the raw API. The above code creates an elliptic shaped window and allows the user to drag it by it's client area. The key function is SetWindowRgn().
Mike L.G.
mlg400@linuxmail.org
 
The code works great! Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top