c++ - WIN32API C++ 我在编写文本框时遇到问题。无法正确显示文字
问题描述
我是 win32 编程的新手,我只有 13 岁。我试图制作一个文本框,但是在键入它时会导致文本在单击该字段时不可见。有时它会影响菜单。我不知道为什么。
#include <windows.h>
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
void AddMenus(HWND hwnd);
HWND TextBox;
HMENU hmenu;
#define FIRST 1
int WINAPI wWinMain(HINSTANCE hinstance, HINSTANCE hprevinstance, LPTSTR args, int ncmdshow) {
WNDCLASSW wc = {};
wc.hInstance = hinstance;
wc.lpfnWndProc = WindowProc;
wc.hCursor = NULL, IDC_ARROW;
wc.lpszClassName = L"wnd_class";
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
RegisterClassW(&wc);
MSG msg;
CreateWindowW(L"wnd_class", L"EXPONOS", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 100, 100, 1000, 500, NULL, NULL, NULL, NULL);
while (GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch (uMsg) {
case WM_COMMAND:
switch (wParam) {
case FIRST:
MessageBeep(MB_OK);
MessageBox(NULL, L"EXPONOS GUI 1.0 UNDER CONSTRUCTION\nCopyright (C) Name 2021", L"About", MB_OK);
}
case WM_CREATE:
AddMenus(hwnd); //I choose NULL becuase if I use L"" it causes the frame to lag
TextBox = CreateWindowW(L"Edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER, 0, 0, 500, 500, hwnd, NULL, NULL, NULL);
break;
case WM_DESTROY:
PostQuitMessage(NULL);
break;
}
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
}
解决方案
推荐阅读
- vega - 在 vega 中将纪元时间戳转换为日期
- phpspreadsheet - 如何不使用 phpspreadsheet html 阅读器在单元格值中写入注释
- jenkins-pipeline - 在 Jenkinsfile 脚本内的字符串中添加括号会导致语法错误
- python - 如何使用 Tensorboard 绘制损失和准确度
- sql - 如何改进/加速 SQL 查询
- iis - 使用不同别名登录时,相同的 IIS 本地主机标记为不同的名称
- image-processing - 为两个大致相同的蒙版图像创建单应矩阵
- c# - 无法让 costura.fody 将 dll 嵌入 exe
- mysql - MySQL monthly sums
- python - 为什么我的 Python 日志记录设置不起作用?