3个回答
展开全部
你好
很高兴为你解答
答案是:基于对话框的程序:
void CVc6aDlg::OnPaint()
{
if (IsIconic())
{
.......................
}
else
{
//就是下面的代码
CPaintDC dc(this);
::SetGraphicsMode(dc.GetSafeHdc(),GM_ADVANCED);
XFORM xf;
xf.eDx =xf.eDy = 0;
xf.eM11 = 0.4330; //0.5 * cos(30)
xf.eM12 = -0.25;//0.5 * [- sin( 30 )]
xf.eM21 = 0.25;//0.5 * sin ( 30 )
xf.eM22 = 0.4330;// 0.5 * cos( 30 )
::SetWorldTransform(dc.GetSafeHdc(),&xf);
dc.Ellipse(100,300, 300,200);
CDialog::OnPaint();
}
}
满意请采纳,谢谢
展开全部
#include <windows.h>
#pragma comment(linker, "/subsystem:windows")
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmd, INT nShow)
{
HWND h = CreateWindowA("#32770", "椭圆", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 300, 200,
0, 0, hInst, 0);
HWND hs = CreateWindowA("Static", "", WS_CHILD | WS_VISIBLE | SS_BITMAP,
0, 0, 200, 100, h, 0, hInst, 0);
HDC d = GetDC(hs);
HBITMAP b = CreateCompatibleBitmap(d, 200, 100);
HDC m = CreateCompatibleDC(d);
SelectObject(m, b);
BitBlt(m, 0, 0, 200, 100, d, 0, 0, WHITENESS);
Ellipse(m, 0, 0, 200, 100);
DeleteDC(m);
ReleaseDC(hs, d);
SendMessage(hs, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)b);
MSG mg;
while( GetMessageA(&mg, 0, 0, 0) > 0 ) {
if (mg.message == <a href="https://www.baidu.com/s?wd=WM_COMMAND&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y3P1b4ryfvujI9nhmYnhR40ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6K1TL0qnfK1TL0z5HD0IgF_5y9YIZ0lQzqlpA-bmyt8mh7GuZR8mvqVQL7dugPYpyq8Q1m3njfvPWc1rHRLnjf1rH64n6" target="_blank" class="baidu-highlight">WM_COMMAND</a> && mg.wParam == (WPARAM)MAKEWORD(IDCANCEL, BN_CLICKED))
break;
TranslateMessage(&mg);
DispatchMessageA(&mg);
}
DeleteObject(b);
DestroyWindow(h);
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include <windows.h>
#include <math.h>
#pragma comment(linker, "/subsystem:windows")
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmd, INT nShow)
{
HWND h = CreateWindowA("#32770", "椭圆", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 400, 300,
0, 0, hInst, 0);
HWND hs = CreateWindowA("Static", "", WS_CHILD | WS_VISIBLE | SS_BITMAP,
0, 0, 200, 100, h, 0, hInst, 0);
HDC d = GetDC(hs);
HBITMAP b = CreateCompatibleBitmap(d, 400, 200);
HDC m = CreateCompatibleDC(d);
SetGraphicsMode(m, GM_ADVANCED);
SelectObject(m, b);
BitBlt(m, 0, 0, 400, 400, d, 0, 0, WHITENESS);
float angle = 30 * 3.141592f / 360.0f;
XFORM xf;
xf.eM11 = cos(angle); xf.eM12 = sin(angle);
xf.eM21 = -sin(angle); xf.eM22 = cos(angle);
xf.eDx = 0.0f; xf.eDy = 0.0f;
SetWorldTransform(m, &xf);
SetWindowOrgEx(m, -100, -50, NULL);
Ellipse(m, 0, 0, 200, 100);
DeleteDC(m);
ReleaseDC(hs, d);
SendMessage(hs, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)b);
MSG mg;
while( GetMessageA(&mg, 0, 0, 0) > 0 ) {
if (mg.message == WM_COMMAND && mg.wParam == (WPARAM)MAKEWORD(IDCANCEL, BN_CLICKED))
break;
TranslateMessage(&mg);
DispatchMessageA(&mg);
}
DeleteObject(b);
DestroyWindow(h);
return 0;
}
angle的那个30是30度,自己改
来自:求助得到的回答
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询