- Код: Выделить всё
#include <windows.h>
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "gdi32.lib")
LRESULT CALLBACK WndFrmProc(HWND,UINT,WPARAM,LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance
,LPSTR lpszCmdParam,int nCmdShow)
{
HWND hWnd;
MSG Message;
WNDCLASS WndClass;
WndClass.cbClsExtra=0;
WndClass.cbWndExtra=0;
WndClass.hbrBackground=(HBRUSH)(HOLLOW_BRUSH);
WndClass.hCursor=LoadCursor(NULL,IDC_ARROW);
WndClass.hIcon=LoadIcon(NULL, IDI_APPLICATION);
WndClass.hInstance=hInstance;
WndClass.lpfnWndProc=(WNDPROC)WndFrmProc;
WndClass.lpszClassName="lalala";
WndClass.lpszMenuName=NULL;
WndClass.style=CS_SAVEBITS;
RegisterClass(&WndClass);
hWnd=CreateWindow("lalala","trampampam",WS_OVERLAPPEDWINDOW,
100,100,500,500,
NULL,(HMENU)NULL,hInstance,NULL);
HRGN rg = CreateEllipticRgn(0,0,500,500);
SetWindowRgn(hWnd,rg,TRUE);
ShowWindow(hWnd,nCmdShow);
while(GetMessage(&Message,0,0,0)) {
TranslateMessage(&Message);
DispatchMessage(&Message);
}
return Message.wParam;
}
// Main Frame Window
LRESULT CALLBACK WndFrmProc(HWND hwnd,UINT iMessage,WPARAM wParam,LPARAM lParam)
{
switch (iMessage) /* handle the messages */
{
case WM_RBUTTONUP:
case WM_DESTROY:
PostQuitMessage(0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc(hwnd, iMessage, wParam, lParam);
}
}
Аналогичное окно на бейсике ведёт себя гораздо приличнее.
- Код: Выделить всё
Option Explicit
Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function CreateEllipticRgn Lib "gdi32" _
(ByVal X1 As Long, ByVal Y1 As Long, _
ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Sub Form_Load()
Me.Width = 500 * Screen.TwipsPerPixelX
Me.Height = 500 * Screen.TwipsPerPixelY
Dim rg As Long
rg = CreateEllipticRgn(0, 0, 500, 500)
SetWindowRgn hWnd, rg, True
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
End
End Sub
С чем это может быть связано?
Думаю, что со стилями окна или класса. Пробовал разные флаги, но как-то малоуспешно. Посоветуйте, какую комбинацию стилей подобрать?