#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#define WIN_NAME "CircleGUI"
#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="WIN_SHELL";
winClass.hIconSm =NULL;
RegisterClassEx( &winClass );
hWnd=CreateWindow( "WIN_SHELL",
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