15,979
社区成员
发帖
与我相关
我的任务
分享
#include<Windows.h>
#include<tchar.h>
LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,PSTR,int iCmdShow)
{
static TCHAR szAppName[]=TEXT("HelloWin");
HWND hwnd;
MSG msg;
WNDCLASS 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;
if(!RegisterClass(&wndclass))
{
MessageBox(NULL,TEXT("This NT"),szAppName,MB_ICONERROR);
return 0;
}
hwnd = CreateWindow(szAppName,
TEXT("Hello program"),
WS_OVERLAPPEDWINDOW,
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 message, WPARAM wParam, LPARAM lParam)
{
if(message==WM_CREATE)
{
int x;
HDC hdc=GetDC(hwnd);
x=BeginPath(hdc );// '在窗体上产生"窗体"字路径
x=TextOut (hdc, 0, 0, L"葛军万人编程联盟 荣誉出品", 26);
x=EndPath (hdc);
HRGN hRgn = PathToRegion(hdc);// '将所产生的路径转换为区域
ReleaseDC(hwnd,hdc);
//'设置窗体形状为转换成的区域
x=SetWindowRgn (hwnd, hRgn, 1);
// '删除对象,释放系统资源
DeleteObject( hRgn);
return 0;
}
return DefWindowProc(hwnd,message,wParam,lParam);
}
Private Sub Form_Load()
Dim hRgn As Long
Me.Height = 1000
Me.Left = 0
Me.Top = 0
Me.Width = 12000
With Me
.Font.Name = "隶书"
.Font.Size = 48
End With
BeginPath Form1.hdc '在窗体上产生"窗体"字路径
TextOut Form1.hdc, 0, 0, "葛军万人编程联盟 荣誉出品", 26
EndPath Form1.hdc
hRgn = PathToRegion(hdc) '将所产生的路径转换为区域
'设置窗体形状为转换成的区域
SetWindowRgn hWnd, hRgn, 1
'删除对象,释放系统资源
DeleteObject hRgn
End Sub
void CBigPenDlg::OnButton1()
{
// TODO: Add your control notification handler code here
HRGN wndRgn;
CClientDC dc(this);
CFont Font;
CFont *pOldFont;
if (dc.m_hDC!=NULL)
{
Font.CreatePointFont(500,"微软雅黑");// 80=8 point
dc.BeginPath();
dc.SetBkMode(TRANSPARENT);
pOldFont = dc.SelectObject(&Font);
dc.TextOut(0, 0, "你好!");
dc.SelectObject(pOldFont);
dc.EndPath();
//
StrokeAndFillPath(dc.m_hDC);
wndRgn=::PathToRegion(dc.m_hDC);
SetWindowRgn(wndRgn, TRUE);
}
}
vc6 win7 没问题