Attach Windows/Buttons To Diff DC's

This is a discussion on Attach Windows/Buttons To Diff DC's within the Windows Programming forums, part of the Platform Specific Boards category; Is it possible to attach several buttons to several HDC's?
I've got it to work with text, as TextOut() outputs ...

Attach Windows/Buttons To Diff DC's

I've got it to work with text, as TextOut() outputs to an HDC, but I've no idea how to make that work with a window. I've tried several different hacks, but as they say, "no workie".

For instance, I tried declaring a new HDC variable, with the intention of trying to cast it to an HWND in CreateWindow(), but of course that made little sense and didn't work.

I tried earlier on to declare several separate HWND's, children to none, but the results were buggy at best. Anyway, if anyone knows if this can be done, it would enable me to more easily show-and-hide windows/buttons!

I'm not sure what you're trying to do but if you just want to show/hide different windows, the you can call ShowWindow(), with the HWND and either SW_HIDE or SW_SHOW depending.

If this isn't what you want to do, then you can have Windows allocate a seperate DC for each window by creating the WNDCLASS with the CS_OWNDC style. You can obtain this DC in the normal way, but Windows will maintain it so that any changes are saved for each window.

Thanks, your second suggestion sounded close to my requirements. See, at present, I am grouping "families" of buttons as arrays, and use my function ShowWindowArray() to show/hide them with relative ease. The problem is, the more groups I add to a given "screen", the less automated the process is. Ultimately,I would like to just swap the "current" DC with the "prev" DC with a single pointer as I do now with text. Anyway, I will try that out, thanks.

If you have a dialog and want to put different groups of buttons on it depending on what function the user is performing. Say for a config screen.

Try a TAB control. On to each seperate TAB draw the button groups. The user then can select the group they want.

You can even paste dialogs onto the TAB's. Create a complicated button filled dlg in the resource editor.
Create the TAB screen and button dlg's, hiding the button dlg's from view.
When the TAB is changed hide the current button dlg and show the new one, setting its position over the TAB screen.