Creating a child window that can't be dragged

I have the following code that creates an About Window. AboutBox is called from WndProc(). How do I create the window in AboutBox so that the box is not moveable within the main Window? I saw a couple of forum posts that WS_EX_NODRAG was used, but that is not a valid window style in Visual Studio 2019.

Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
void AboutBox(HWND hwnd)
{
    HWND hwnd_child;

    hwnd_child = CreateWindow(ChildWindowClass, AboutWindowTitle, WS_CHILD | WS_VISIBLE | WS_CAPTION, 175, 100, 375, 200, hwnd, (HMENU)ABOUT_OK, hInstance, NULL);
    if (!hwnd_child)
    {
        MessageBox(NULL, L"Call to CreateWindow failed!", AboutWindowTitle, NULL);
        return;
    }

    CreateWindow(L"BUTTON", L"OK", WS_VISIBLE | WS_CHILD, 138, 110, 80, 25, hwnd_child, (HMENU)BUTTON_OK, hInstance, NULL);
}


LRESULT CALLBACK AboutProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    RECT rect;
    HDC hdc_child;

    switch (message)
    {
        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case BUTTON_OK:
                    DestroyWindow(hwnd);
                    break;
            }
            break;

        case WM_PAINT:
            hdc_child = BeginPaint(hwnd, &ps);
            GetClientRect(hwnd, &rect);
            DrawTextW(hdc_child, L"\n\n\n\u00a92021 Lookout Portable Security\nVersion 1.0\n9/8/2021\n", -1, &rect, DT_CENTER);
            EndPaint(hwnd, &ps);
            return(0);
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Also. Does all drawing within the client area HAVE to be done in WM_PAINT? IOW, can I do the writing in the AboutBox function (GetClientRect,DrawTextW) and then let the WM_PAINT just to the repaint? I'm guessing not. It doesn't seem to work anyway, other than the way it is now. I was trying to consolidate all the operations in the AboutBox function and not have it spread out.
This will help, its not C++ code but its easy to translate

1
2
3
4
5
6
7
8
9
10
CASE WM_SYSCOMMAND
            if (wParam and &HF060) = SC_CLOSE then Return 0
             if (wParam and &HF150) = SC_HOTKEY Then Return 0
        '     if (wParam and &HF160) = SC_DEFAULT Then Return 0 
               if (wParam and &HF090)  = SC_MOUSEMENU Then Return 0 
                if (wParam and &HF030) = SC_MAXIMIZE Then Return 0
                 if (wParam and &HF020) = SC_MINIMIZE Then Return 0  

IF (wParam AND &HFFF0) = SC_MOVE THEN Return 0
 


you are looking for SC_MOVE
Last edited on
WS_EX_NODRAG is for Windows CE
JohnOfC - perfect. Thanks. Works great.
Topic archived. No new replies allowed.