Click to See Complete Forum and Search --> : connect OwnerDrawn button with it's DrawProc


Zolix2010
September 20th, 2005, 04:45 AM
hi,
i created a button and i got a OwnDrawProc() but i don't know how connect
between the two things.

how do i "tell" the button to connect with the Proc? :ehh:

thanks in advance,
Avi.

golanshahar
September 20th, 2005, 05:27 AM
if you set the owner-drawn option to a button, then what you need to do is add the WM_DRAWITEM message handler.



LRESULT CALLBACK MainWndProc( HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{

switch (uMsg)
{

//
// Process other messages.
//
case WM_DRAWITEM:
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}


hope it helps

Cheers

Zolix2010
September 20th, 2005, 05:29 AM
i should say before that im using Windows API.

anyway, till now i find that there's SetLong(...) function that i can give as parameter the Proc.
(the problem now that the WM_DRAWITEM not being called :blush: )

golanshahar
September 20th, 2005, 05:48 AM
i should say before that im using Windows API.

i fixed my code for win32 ;)


anyway, till now i find that there's SetLong(...) function that i can give as parameter the Proc.
(the problem now that the WM_DRAWITEM not being called :blush: )

you mean ::SetWindowLong(..) ;)
did you set the BS_OWNERDRAW style to the button?

Cheers

Zolix2010
September 20th, 2005, 05:53 AM
yep,
and no other styles and still not calling WM_DRAWITEM.
(it calls WM_PAINT if it tells you something...).

i also try to catch the WM_DRAWITEM in my parent window (dialog) but the switch block not catching it.

any hint? :ehh:

golanshahar
September 20th, 2005, 12:56 PM
well i dont know what exactly you doing worng :confused:
but here is a simple win32 app i just build and in the About dialog i set the button to ower-drawn and i added in the message loop the WM_DRAWITEM and it gets there and its ok...

take a look.

Cheers

Zolix2010
September 20th, 2005, 05:38 PM
well, i see your message now but i fix the problem couple of hours ago :thumb: thanks (alot) anyway.

the thing that solve the problem was
changing the SetWindowLong() (subclassing the button i think i the right term) and then in the switch block catch the WM_DRAWITEM and draw the button.

it's pretty awful that there's no HOW TO DRAW SKIN tutorial in the net. there's alot of patches and QA but no straight forword, whole, tutorial.
:ehh:

thanks again,
Avi.