I've got several child window controls embedded into a tool bar. I'm trying to use TextOut to add a label right above two of the child windows so the user will know what these controls do. However, the text never gets displayed. The toolbar appears to be drawn over it, covering it up. My question is, how do I get the text to appear over the top of the toolbar? Instead of being covered by it? Here's the code snippet I'm working with. Sorry if the code is sloppy. I'm still learning! If you need more code to work with, let me know and I'll supply the code in it's entirety.
Thanks for your input, David B.
case WM_CREATE:
LoadLibrary(TEXT ("Msftedit.dll"));
//Create Child Windows
RichEdit = CreateWindow(MSFTEDIT_CLASS, TEXT("EDITOR"), WS_CHILD | ES_MULTILINE | WS_VISIBLE | WS_BORDER,
0, 0, 0, 0, hwnd, RichEditorID, GetModuleHandle(NULL), NULL);
Toolbar = CreateWindow(TOOLBARCLASSNAME, NULL, WS_CHILD | TBSTYLE_FLAT, 0, 0, 0, 0, hwnd,
ToolBarID, GetModuleHandle(NULL), NULL);
ListboxType = CreateWindow(WC_LISTBOX, NULL, WS_CHILD| WS_VISIBLE, 0, 0, 0, 0, Toolbar, ChildID1 2,
GetModuleHandle(NULL), NULL);
ListboxArch = CreateWindow(WC_LISTBOX, NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, Toolbar, ChildID1 3,
GetModuleHandle(NULL), NULL);
hwndBuildButton = CreateWindow(WC_BUTTON, L"Build", WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, 0, 0, 0, 0, Toolbar, ChildID1 4,
GetModuleHandle(NULL), NULL);
EnumChildWindows(hwnd, EditorChildProc, (LPARAM)&rect);
return 0;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
SetTextAlign(hdc, TA_TOP);
TextOut (hdc, archListBoxPos 20, 5, ArchLabel, ARRAYSIZE(ArchLabel));
TextOut(hdc, btListBoxPos, 5, BuildLabel, ARRAYSIZE(BuildLabel));
EndPaint(hwnd, &ps);
return 0;
CodePudding user response:
You need to create a window that would contain the text, and put it on top of the toolbar. The drawing you do in the wndproc is always subordinate to the child controls: they will cover it up.