IonicWind Software

IWBasic => General Questions => Topic started by: fasecero on April 19, 2009, 01:28:42 PM

Title: Ownerdraw menu?
Post by: fasecero on April 19, 2009, 01:28:42 PM
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...
Title: Re: Ownerdraw menu?
Post by: LarryMc on April 19, 2009, 07:41:31 PM
Looks fine to me.

Larry
Title: Re: Ownerdraw menu?
Post by: Haim on April 19, 2009, 09:56:09 PM
Looks perfectly well on my Laptop (Thinkpad T60)

Haim
Title: Re: Ownerdraw menu?
Post by: fasecero on April 19, 2009, 10:06:09 PM
Sorry for not having been more precise in my initial enquiry. The problem only happen when the mouse is over an item.
Title: Re: Ownerdraw menu?
Post by: Haim on April 20, 2009, 01:05:12 AM
Hello,
Even with the mouse over an item the icon is transparent.
I do not percieve any problem...
Haim

Title: Re: Ownerdraw menu?
Post by: sapero on April 20, 2009, 01:23:02 AM
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.
Title: Re: Ownerdraw menu?
Post by: fasecero on April 20, 2009, 03:04:22 PM
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.