Confusion over the BS_OWNERDRAW flag.

Started by
6 comments, last by Oranda 21 years, 10 months ago
Hello all . I''m trying to make a button which has both an icon and a textlabel on it. Unfortunately, it appears that the Windows API only allows one or the other. If I specify an icon, I get no text. So I thought, "Hey, why don''t I just make myself an owner drawn window??". It seemed like the perfect solution, except that I can''t figure out how to process the WM_OWNERDRAW message. I know when it needs to be drawn, sure, but how is the question. Is it depressed? Is it highlighted? Is it just a normal redraw? I don''t see any flags in the MSDN to address any of these, except selection!! Could somebody please tell me how to tell how a window needs to be redrawn? Or even better yet, how to put both an icon and a text label on the same button? Thanks.
Advertisement
WM_DRAWITEM has a pointer to DRAWITEMSTRUCT which has the state.
---visit #directxdev on afternet <- not just for directx, despite the name
Just a quick note to save you some searching: the DrawFrameControl function will come in handy when drawing your button.

Kippesoep
Thanks guys . Kippesoep, that funtion is pretty near the top of my "Things I never knew existed but will never be able live without again" list. Thank you so much. Now I think I''m just going to call DrawFrameControl, and then use DrawText for the text and DrawIcon for the icon. Voila! A button with an icon AND text. And thank you too InDirectX, I looked at the drawdata member, but I''m afraid that the it only specifies things like selection and keyboard focus. I think I''m just going to have to monitor the mouse messages and keep track of it.
Okay, I guess I'm still stuck. I still haven't managed to figure out how to tell if one of the buttons is being depressed. The API mouse messages (WM_LBUTTONDOWN, etc.) don't apply to controls, and I can't seem to get the button notification messages (such as BN_PUSHED, BN_HILITE, etc.). I tried all of the flags in the itemState member of DRAWITEMSTRUCT, and none of those were triggered by mouse clicks either. Could somebody please show me exactly how I can do this?

[edited by - Oranda on June 6, 2002 11:00:17 AM]
Send a BM_GETSTATE message to the button. If the return value has BST_PUSHED set, it''s being held down.

Kippesoep
Okay, I''ll try that then. Thanks again Kipp.
Perfect. That''s exactly what I was looking for, and it works just fine. Thanks.

This topic is closed to new replies.

Advertisement