|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 899599 于 2018-10-13 10:09 编辑
请教各位大神,最近我想在控制台里面添加按钮等控件,但是添加了之后按钮是能点击有效果的,但是去没有显示。
代码如下:
int main()
{
HWND hWnd;
MSG msg;
HWND makeSureButton;
HWND changeButton;
HWND changeButton2;
HWND closeButton;
HWND gobackButton;
hWnd = GetConsoleWindow();
MoveWindow(hWnd, 0, 0, 700, 800, true);
closeButton = CreateWindowA(TEXT("button"), TEXT("取消"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD,
500, 80, 100, 40, hWnd, (HMENU)IDC_CLOSEBUTTON, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
makeSureButton = CreateWindowA(TEXT("button"), TEXT("确定"), WS_VISIBLE | BS_PUSHBUTTON | WS_CHILD,
500, 150, 100, 40, hWnd, (HMENU)IDC_MAKESUREBUTTON, (HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE), NULL);
ShowWindow(makeSureButton, SW_NORMAL);
ShowWindow(closeButton, SW_NORMAL);
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
ShowWindow(makeSureButton, SW_SHOWNORMAL);
ShowWindow(closeButton, SW_SHOWNORMAL);
if (msg.hwnd == makeSureButton && msg.message == WM_LBUTTONDOWN)
{
MessageBox(hWnd, TEXT("点击"), TEXT("132"), MB_OK);
hideCursorInfo();
}
if (msg.hwnd == closeButton && msg.message == WM_LBUTTONDOWN)
{
MessageBox(hWnd, TEXT("点击了取消按钮"), TEXT("Hello"), MB_ICONINFORMATION);
hideCursorInfo();
}
}
return 0;
}
图片如下
请大家帮帮忙,十分感谢了 |
-
点击相应的位置后
-
刚打开
|