Hi people! I am trying to create something like a BitBtn(from Delphi) control in Asm. It shows a bitmap well, but there are two problems. 1) I want to make control a flat-button like, but DrawEdge doesn't work at all! (I use it on a MemDC). 2) How to make bitmap transparent without using b/w mask? Is it possible? If anyone knows how to solve these two problems, please answer...
Posted on 2001-02-01 16:16:00 by IGosha
Hi I dont know about DrawEdge but to make a transparent (i think you mean color keying out not real transparency like alpha blending).... Well ...you can mangle the bits of the bitmap by GetDIBBits or better: use a memory area and make all your operations there (like check for 0 to key out black etc) then create a compatible bitmap from that memory area and BitBlt it on a memory or screen DC this way you can easy make all sorts of effects by simple memory (independent) operations They really shoud call this tehnique MIB (MemoryIndependentBitmaps) :D
Posted on 2001-02-01 16:24:00 by BogdanOntanu
Sorry, something is still not understood. I use LoadBitmap, then SelectObject to memory DC. I could use MaskBlt, but I don't know how to use anything else? Sorry I'm lame in GDI and custom controls. :-P And second, unanswered question, is: how can I make my control act like toolbar button - flat if mouse is moving over it? DrawEdge doesn't work, and I don't know any other technique...
Posted on 2001-02-01 16:58:00 by IGosha
People, please help! I really need to do this!
Posted on 2001-02-02 01:09:00 by IGosha
To load a bitmap with one transparent color use LoadBitmap API. This only half achieves the effect you wanted. It replaces your background color with the systems background color. It uses the first pixel in the bitmap as the background color. Just look up the API, otherwise you have to compose a mask in memory, or copy your bitmap manually by manipulating the bitmap bits. DrawEdge should work fine. Here's what I'd do: Place this code in the WM_PAINT handler: invoke BeginPaint, hWnd, addr ps mov hDC, eax invoke GetClientRect, hWnd, addr WndRect ;Draw RaisedEdge invoke DrawEdge, hDC, addr WndRect, EDGE_RAISED, BF_RECT invoke EndPaint, hWnd, addr ps I would probably subclass a normal button and just paint it the way I wanted it. (Check out Iczelions site for a subclassing tutorial) Then insert this code in the WM_PAINT procedure and let the rest go to DefWindowProc. You can change the last two parameters of the DrawEdge API to achieve different effects. Hope this helps! See ya, Ben
Posted on 2001-02-02 01:39:00 by cyberben
There is also a buttons example with source in the downloads on Iczelions site that shows how to make some odd 25 different custom buttons! Check it out. See ya, Ben
Posted on 2001-02-02 01:40:00 by cyberben
Thanks for the answer, DrawEdge works pretty well. Besides, I didn't understand that about LoadBitmap's first color as the background. Where is that pixel? It doesn't seem to work :-( And one question remains. How to make a custom control feel like flat button, raising only when mouse moves over it? That example with lots of buttons is VERY big, so it is hard to find answer out there.. ;-(
Posted on 2001-02-02 01:57:00 by IGosha
Why can't you use a flat toolbar?
Posted on 2001-02-02 03:46:00 by Iczelion
I have to put four flat button on the form, but they are independent (I mean position in the dialog box). So I think creating each time a new toolbar (and its alignment will crash everything) I think is wrong... Please give me advice how to do create these buttons. :) I thought the only way is to create custom controls, but still have problems with transparency and flat-look (as was written before). Hope you, Great MASM32 People :), will help....
Posted on 2001-02-02 04:40:00 by IGosha
you can do flat button by creating a button with WS_CHILD or WS_VISIBLE or BS_OWNERDRAW or BS_BITMAP and subclassing it. In the new callback function of the button, track mouse events and WM_CTLCOLORBTN to draw the edges when appropriate
Posted on 2001-02-02 04:40:00 by amokila
I know how to create such a button (even without subclassing). But the main problem is HOW TO track these mouse events (On/Off) and paint a transparent bitmap on it... :( This message was edited by IGosha, on 2/2/2001 5:01:47 AM
Posted on 2001-02-02 05:01:00 by IGosha
For tracking when a mouse enters and leaves a window, look into the SetCapture and ReleaseCapture API's, they'll suit your needs well. SetCapture becomes true when a mouse is over the specified window, once it becomes false, call ReleaseCapture (in addition to any work you need done to undraw the edge of the control). _Shawn
Posted on 2001-02-02 11:09:00 by _Shawn
Hi IGosha, You got alot of posts on this so here's one more. I got a sample program with source at 'http://czdrillard.cjb.net/' with colored buttons and the about button raises on mouse over. Maybe this is helpful? best regards czDrillard
Posted on 2001-02-02 23:43:00 by czDrillard
Thank you very much! That example is really useful!
Posted on 2001-02-03 00:51:00 by IGosha