I'm not talking about win2k layered windows. But it's the same thing... if I drag something, graphic, window, tree node, listview node, custom this, custom that, I rather than changing the ICON or showing a bounding box, I would like to create a 50% translucent image of whatever it is beging dragged, or if the image is more than 128x128, then I can create a bounding box with a scaled image of what I'm dragging. My question is this... what API's help me get the image of screen regions or particular windows (such as, a window with an hWnd), and then what API's handle translucency without DirectX installed.?? I think it's alpha blending, but I'm not sure... I just want it to be about 50% transparent, 50% visible... so I can see through it... Thanks, _Shawn
Shawn, Question: When you say "transparent" do you mean you wish the background to show thru ALL of your bitmap, or only say a certain background color? The former is simple to achieve with an appropiate DROP in bitblit (exactly which I do not know). You need not get every window you're traveling over, as you can 'GetDC 0' and get the device context for the entire screen. To make a transparent backgroiund color, either make sure your program is installed on W98 (which has a transparent blit built in), or make your own mask cutouts. You can make a mask by defining a two color bitmap, make the background color your bitmap background color, foregrouns mort anything else (IE, white). Then open your bitmap in that dc, it build the mask for you. Open the bitmap a 2nd time in a screen compatable dc, use the mask to blit make a hole, blit your bitmap to make the reverse hole, then blit bitmap to screen. ---------------- "I saw this in a movie about a bus that had to speed around a city, keeping its speed over fifty, and if it's speed dropped, it would explode! I think it was called "The bus that couldn't slow down."
Windows 2k or not has none alpha blending capabilities, not even after you install DirectX you dont get alpha blending (even if your video board knows to do it by hard :D) only Direct3D has support for alpha blending...:) So you have to do it yourself (no api will help) either use a DirectX lock() to get a pointer to the video memory or use GDI (as ernie told you before) to get a pointer to the GDi screen.... then just start by doing a 50% aplha: (i will assume 16 bits per pixel 565 scheme ignore the points they are for easy reading)
optimizations are possible and required :) this is more complicated than this as 555 pixel format exist for 16 bits also not to speak of 24 or 32 bits..that must use diffrent masks and operations...and yeah this is a trick for 50%, variable alpha is even harder......like : dest_pixel=alpha*src_pixel1+(1-alpha)*src_pixel2 but i hope you get the picture....its slow and hard to do :) However i guess you dont want this, Windows uses a simpe method: ONE pixel on One pixel off mask, much faster...and its hard to get it on higher resolutions so they get by.... (even AOE got by with this :) ) Bogdan
mov eax,word ptr ; get destination pixel1 and eax,0.11110.111110.11110 ; mask and 1/2 shr eax,1 mov ebx, word ptr and ebx,0.11110.111110.11110 ; again for src pixel2 shr ebx,1 add eax,ebx ; 1/2 pixel1+ 1/2 pixel2 mov word ptr ,eax ; wite back to destination
I like the transparency in Win2K, but the computer really drags (pun intended) when this is enabled - could be my VooDoo3K. You could cheat and use the method that Ernie describes above, then dither the image your dragging with the transparent color. The transparency that looks pretty in 32bit color would have to be a control of your design, as I'm fairly sure that all versions of Windows don't support the APIs that Win2K uses for this feature. For each pixel you would just calculate the average color (do R, G, B components separately). This isn't a fast operation unless it's done in MMX. bitRAKE.