vc可视化程序设计
发布网友
发布时间:2022-04-29 10:32
我来回答
共2个回答
热心网友
时间:2022-06-26 06:28
我来回答吧,你打开vc6.0,新建工程,选择“Win32 Application”,工程名随便你写一个,再新建Files,随便写一个文件名,选择"C++ Source File",确定后输入如下代码
#include <stdio.h>
#include <windows.h>
LRESULT CALLBACK WangProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=NULL;//(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_NO);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WangProc;
wndcls.lpszClassName="王朝帅";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_VREDRAW | CS_PARENTDC/* | CS_HREDRAW*/;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("王朝帅","安徽大学 计算机科学与技术学院 王朝帅",WS_OVERLAPPEDWINDOW,
50,50,600,400,0,0,0,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WangProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is '%c'",wParam);
MessageBox(hwnd,szChar,"朝帅作品",MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"mouse clicked","朝帅作品",MB_OK);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"MFC学习中心--朝帅作品",strlen("MFC学习中心--朝帅作品"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"MFC培训",strlen("MFC培训"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否真的结束?","朝帅作品",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(1);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}
呵呵,里面还含有一点我的个人信息~~
热心网友
时间:2022-06-26 06:28
你真幽默 这样问能写本书了