October 29, 2025, 11:32:07 AM

News:

IWBasic runs in Windows 11!


Ownerdraw menu?

Started by fasecero, April 19, 2009, 01:28:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

fasecero

Time ago I was playing with this, just add a small image to te left of the menÃÆ'Ã,º text. The problem is the background of the image, it is supposed that it should be transparent, but instead appears in black color, perhaps someone can see why.
BTW, it's a full winapi thing...

LarryMc

Looks fine to me.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Haim

Looks perfectly well on my Laptop (Thinkpad T60)

Haim

fasecero

Sorry for not having been more precise in my initial enquiry. The problem only happen when the mouse is over an item.

Haim

Hello,
Even with the mouse over an item the icon is transparent.
I do not percieve any problem...
Haim


sapero

April 20, 2009, 01:23:02 AM #5 Last Edit: April 20, 2009, 01:44:18 AM by sapero
Subroutine MenuitDraw - change the operator (from = to &)IF *<DRAWITEMSTRUCT>lParam.itemState & ODS_SELECTED

Subroutine ImageTranspCreate, MenuOwnerDrawAux - GDI memory leaks in SelectObject calls. You should save what the first SelectObject returns, and select it back before returning or deleting the HDC.

sub ImageTranspCreate
...
int old, old2
old  = _SelectObject(hdcMem, hbmColour) ' save old HBITMAP
old2 = _SelectObject(hdcMem2, hbmMask) ' save old HBITMAP
...
_SelectObject(hdcMem, old) ' restore old HBITMAP
_SelectObject(hdcMem2, old2) ' restore old HBITMAP
_DeleteDC(hdcMem)
_DeleteDC(hdcMem2)
...


By the way instead, creating the mask, you could use TransparentBlt api (ncluded in Windows 98 and later) to draw your bitmaps transparently. It takes the pixel color to be transparent, two HDC, source and destination rectangles.
Take a look at Office Menu topic.

fasecero

Hi, I found it strange that does not work, because the same procedure in other controls worked well, thanks for warning me, it's only a local problem  :).
Sapero, thanks for the corrections, the function TransparentBlt sounds promising, I will consider it in these days, and i will try to add checkbox and radios in the menus.