C++关于按钮的编程
求大神写一个按钮的代码圆圈方框都行只要能点击的就行类似于电脑里跳出来的确定框的按钮确定取消的按钮...
求大神写一个按钮的代码 圆圈方框都行 只要能点击的就行
类似于电脑里跳出来的确定框的按钮 确定取消的按钮 展开
类似于电脑里跳出来的确定框的按钮 确定取消的按钮 展开
3个回答
展开全部
#include <windows.h>
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
switch(msg)
{
case WM_DESTROY:
PostQuitMessage(0);
return 0;
case WM_COMMAND:
if (LOWORD(wp) == 1)
{
MessageBox(hwnd, TEXT("You clicked button."), TEXT("^_^"), MB_OK);
return 0;
}
default:
return DefWindowProc(hwnd, msg, wp, lp);
}
}
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szStr, INT nShow)
{
WNDCLASS wc;
GetClassInfo(NULL, TEXT("#32770"), &wc);
wc.lpfnWndProc = WndProc;
wc.lpszClassName = TEXT("Hello");
RegisterClass(&wc);
HWND h = CreateWindow(TEXT("Hello"), TEXT("Hello"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, 600, 500, NULL, NULL, hInst, 0);
CreateWindow(TEXT("BUTTON"), TEXT("Click me"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
30, 30, 200, 100, h, (HMENU)1, hInst, 0);
ShowWindow(h, SW_SHOWNORMAL);
MSG msg;
while( GetMessage(&msg, h, 0, 0) > 0 )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<windows.h>
int main(){
MessageBox(NULL,"正文1","标题1",0);
MessageBox(NULL,"正文2","标题2",1);
MessageBox(NULL,"正文3","标题3",2);
MessageBox(NULL,"正文4","标题4",3);
MessageBox(NULL,"正文5","标题5",4);
//还可以有返回值,告诉你用户点击了哪个键
if(MessageBox(NULL,"正文","标题",1)==1)
MessageBox(NULL,"你点击了确定","判断返回值",0);
else
MessageBox(NULL,"你点击了取消","判断返回值",0);
//一次只能运行一个MessageBox
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询