Click to See Complete Forum and Search --> : Owner drawn, what is it?


Will Rothwell
March 30th, 1999, 09:44 AM
Hi,


On this discussion board, I often read about owner-drawn listbox and various controls etc. I believe this is to do with getting more control on the property of these controls/dialog. Am I on the right track?


Can someone please describe what this owner drawn thing is about. And more importantly, how to go about doing it ? I have tried to look up in books (like Inside Visual C++) but no help. What are the procedures to make owner-drawn button, for example.


Any help to this green 'MFCer' is appreciated.


Will

Martin Speiser
March 30th, 1999, 10:02 AM
Hi Will,


you're on the right track. An owner-drawn control is drawn by the owner of the control. Imagine a normal dialog box with several control in it. Normally every control does the painting for itself. By specifying the owner-draw style the controls sends several messages to his owner, the dialog, to get information about what the item(s) to be drawn and to draw the item or the entire control. Let's assume you have a listbox where you let the user choose a country. A small frag in front of the country names will be fine. Okay, this is a typical task for an owner-drawn listbox with items with fixed height. After creation the control will send the message WM_MEASUREITEM to his owner to get information about the dimension of each item. The control will send this message for each item if you specify a listbox with variable height items. Some time later the control get the WM_PAINT message as every window does (a control is nothing else than a special window). It will ask the system for a device context, and sending this dc along with other information in form of a WM_DRAWITEM.


That's all in short.


HTH


Martin

Will Rothwell
April 1st, 1999, 07:27 AM
Thanks Martin for your clear description. You probably have guessed this comming; can you owner-draw the whole of the dialogs or the application. For example, how do you do something like what Winamp does, I mean with non MFC standard View like interface?


Will