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...
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
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...
People, please help! I really need to do this!
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
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
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.. ;-(
Why can't you use a flat toolbar?
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....
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
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
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
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
Thank you very much! That example is really useful!