我要做一个C语言的图形界面,用vc编,希望可以用鼠标点击

希望你能给一个例子,和常用的函数说明!规定用vc... 希望你能给一个例子,和常用的函数说明!
规定用vc
展开
 我来答
我是菜狗
2008-09-10 · TA获得超过118个赞
知道小有建树答主
回答量:272
采纳率:0%
帮助的人:0
展开全部
WINDOWS编程
#include "stdio.h"
#include "windows.h"
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
class win
{
public:
BOOL W_class(HINSTANCE hInstance);
BOOL create(HINSTANCE hInstance);
};
BOOL win::W_class(HINSTANCE hInstance)
{
WNDCLASS wdnclass;//设计窗口
wdnclass.style=CS_HREDRAW|CS_VREDRAW;;//窗口
wdnclass.lpfnWndProc=wndproc;//窗口指针很重要
wdnclass.cbClsExtra=0;//通常为0
wdnclass.cbWndExtra=0;//通常为0
wdnclass.hInstance=hInstance;//句柄
wdnclass.hIcon=LoadIcon(NULL,IDI_ERROR);//图标句柄
wdnclass.hCursor=LoadCursor(NULL,IDC_CROSS);//光标句柄
wdnclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);//背色句柄
wdnclass.lpszMenuName=NULL;
wdnclass.lpszClassName=L"zhuzi";//类的名字

return (RegisterClass(&wdnclass));//注册窗口
}
BOOL win::create(HINSTANCE hInstance)
{
HWND hwnd;
hwnd=CreateWindow(L"zhuzi",L"猪",WS_OVERLAPPEDWINDOW,
200,200,600,400,NULL,NULL,
hInstance,NULL);
//显示窗口
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
return 1;
}

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
win window;
if(!window.W_class(hInstance))
return 0;
if(!window.create(hInstance))
return 0;
//消息循环
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);//接收消息
DispatchMessage(&msg);//将接收的消息处理
}
return 0;
}

//过程函数
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,L"猪",(int)wcslen(L"猪"));
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char szchar[20];
sprintf_s(szchar,"ch%d",wParam);
MessageBox(hwnd,(LPCWSTR)szchar,L"zhuzi",MB_OK);
break;
case WM_LBUTTONDOWN:
if(IDYES==MessageBox(hwnd,L"猪编程",L"zhuzi",MB_YESNO))
{
HDC hDC;
hDC=GetDC(hwnd);
TextOut(hDC,150,150,L"猪万岁", (int)wcslen(L"猪万岁"));
ReleaseDC(hwnd,hDC);
}
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,L"真的退出",L"zhuzi",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
break;
}
return 0;
}
菲菲大爱EXO
推荐于2018-03-29 · TA获得超过1.1万个赞
知道小有建树答主
回答量:1396
采纳率:72%
帮助的人:299万
展开全部
#include "stdio.h"
#include "windows.h"
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
class win
{
public:
BOOL W_class(HINSTANCE hInstance);
BOOL create(HINSTANCE hInstance);
};
BOOL win::W_class(HINSTANCE hInstance)
{
WNDCLASS wdnclass;//设计窗口
wdnclass.style=CS_HREDRAW|CS_VREDRAW;;//窗口
wdnclass.lpfnWndProc=wndproc;//窗口指针很重要
wdnclass.cbClsExtra=0;//通常为0
wdnclass.cbWndExtra=0;//通常为0
wdnclass.hInstance=hInstance;//句柄
wdnclass.hIcon=LoadIcon(NULL,IDI_ERROR);//图标句柄
wdnclass.hCursor=LoadCursor(NULL,IDC_CROSS);//光标句柄
wdnclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);//背色句柄
wdnclass.lpszMenuName=NULL;
wdnclass.lpszClassName=L"zhuzi";//类的名字

return (RegisterClass(&wdnclass));//注册窗口
}
BOOL win::create(HINSTANCE hInstance)
{
HWND hwnd;
hwnd=CreateWindow(L"zhuzi",L"猪",WS_OVERLAPPEDWINDOW,
200,200,600,400,NULL,NULL,
hInstance,NULL);
//显示窗口
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
return 1;
}

int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
win window;
if(!window.W_class(hInstance))
return 0;
if(!window.create(hInstance))
return 0;
//消息循环
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);//接收消息
DispatchMessage(&msg);//将接收的消息处理
}
return 0;
}

//过程函数
LRESULT CALLBACK wndproc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HDC hdc;
PAINTSTRUCT ps;
switch(uMsg)
{
case WM_PAINT:
hdc=BeginPaint(hwnd,&ps);
TextOut(hdc,0,0,L"猪",(int)wcslen(L"猪"));
EndPaint(hwnd,&ps);
break;
case WM_CHAR:
char szchar[20];
sprintf_s(szchar,"ch%d",wParam);
MessageBox(hwnd,(LPCWSTR)szchar,L"zhuzi",MB_OK);
break;
case WM_LBUTTONDOWN:
if(IDYES==MessageBox(hwnd,L"猪编程",L"zhuzi",MB_YESNO))
{
HDC hDC;
hDC=GetDC(hwnd);
TextOut(hDC,150,150,L"猪万岁", (int)wcslen(L"猪万岁"));
ReleaseDC(hwnd,hDC);
}
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
521linux
2008-09-09 · TA获得超过888个赞
知道小有建树答主
回答量:802
采纳率:0%
帮助的人:366万
展开全部
用tc吧,例子多一点,会快一点的
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式