WIN32API C++ I’m having trouble programming a text box. Won’t show text properly

  c++, user-interface, winapi

I’m new to win32 programming I’m only 13 years of age. I tried to make a text box but when typing it causes the text to be invisible when but when clicked the field it appears. Sometimes it affects the menu. I have no idea why.

#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 CONSTRUCTIONnCopyright (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);
}

Source: Windows Questions C++

LEAVE A COMMENT