3个回答
展开全部
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;
}
#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;
}
展开全部
#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);
}
#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);
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用tc吧,例子多一点,会快一点的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询