hi guys!

i'm currently working on a <universal> proc for ownerdrawing everything. before the uMsg-check starts, all params are given to this proc. if it returns something non-zero, the WndProc returns it. but if the universal proc returns zero the app checks for the messages - it is easy,indeed.
so, on the WM_INITDIALOG i want to enumerate all DlgItems and set the OWNERDRAW-flag to them. with the EnumChildWindows function i can get the hWnds of all dlgitems. i also can get & set the flag with Get-/SetWindowLong, but i dont know WHAT flag i have to set:
the buttons should get BS_OWNERDRAW. the edit controls cant be ownerdraw so the sould be kept like they are. comboboxes need CBS_OWNERDRAWFIXED or CBS_OWNERDRAWVARIABLE. so i HAVE to know which type of control is behind the hWnd.
my question: HOW?!

further: checkboxes and radiobuttons are buttons too - but how can i differ them in the DRAWITEMSTRUCT? if i set the the BS_OWNERDRAW-flag the get drawn as buttons... (i haven't added additional code, the ctlType was ODT_BUTTON too)
Posted on 2002-08-14 15:06:32 by hartyl
to get the class from a window call GetClassName and
it will give you a string that is, of course, the class name.
Compare this against "EDIT" and "BUTTON" etc. to
determine what to do.

you may also be able to do this by getting the class
atom from GetClassLong. To be honest, though, I don't
know how to get atoms for classes that are already
registered in the system.

as for owner-drawn buttons, I believe that you cannot
mix BS_OWNERDRAWN with any of the other styles
(radio buttons and check buttons and so forth).

From the API:

BS_OWNERDRAW Creates an owner-drawn button. The owner window receives a WM_MEASUREITEM message when the button is created and a WM_DRAWITEM message when a visual aspect of the button has changed. Do not combine the BS_OWNERDRAW style with any other button styles.

Posted on 2002-08-14 15:47:50 by chorus
Hmm, just thought of another way to get the class.
Although it takes a little forethought:

--When you add controls to your Dialog Box, assign them
IDs based on class. i.e., Edit controls can be 1000h-
1FFFh, buttons can be 2000h-2FFFh, etc.
--Use GetWindowLong with GWL_ID to get the ID from
the window.
--Knowing your strategy, do a bit test on the ID returned:
i.e, if bit 12 is set, it's an edit control. If bit 13 is set, it's
a button, etc.

Posted on 2002-08-14 15:52:50 by chorus
Originally posted by chorus
as for owner-drawn buttons, I believe that you cannot
mix BS_OWNERDRAWN with any of the other styles
(radio buttons and check buttons and so forth).

do you want to say, ownerdrawn checkboxes and radiobuttons are impossible?! wouldn't be good!

you ID-assign-idea's genious, but i thought about publishing the code and if any user wants to use it and he has to take care of this it wouldn't be good. the other idea with getting the window's class is better.

--attatching another question--
i'm using an ownerdrawn popup window (draws the frame and caption in WM_PAINT - works good!). i currently have to create & register a WNDCLASS and then i can use CreateDialogParam to read the resource. i want to make it easier to skip the section with the WNDCLASS and ONLY using DialogBoxParam. but now i can't set the background brush to create a solid-blue background. is any function availible? i searched the whole Win32.hlp without results...
Posted on 2002-08-14 16:08:07 by hartyl