My current project allows the user to skin the application. I'm using GDI+ for painting an image as the background for the program. The image is either an 32bit bitmap or an 24bit PNG. I want to paint the image directly on the screen (so alphatransparency is keeped, pixels which is semi-transparent in the image should be it on the screen). I'm currently painting the image on the form, which makes the image painted overlap the form, so it doesn't keep it's transparency. So you can say that i want to make the form-background invisible, while keeping the painted image and the controls on the form visible.
this is how it should look like (taken from another app):
The image isn't painted on the form, it's painted directly on the screen or whatever you should call it.
this is the image which should be painted (24bit png with transparency):
This is how it currently looks like:
The reason why i got pink/purple background is becuase i'm using SetLayeredWindowAttributes() to make the color pink/purple go invisible. But since the image is painted on the form, the image's parts where it is semi-transparent is chaning the pink behind it to another color. I would like to scrap the "pink is invisible"-function and instead use images with transparency to decide the invisibility of the pixels.
I have no idea on how to solve this. Are there anyone who is familiar with this? I've looked after a solution for one week, but i can't find anything regarding this.
Thanks in advance.
Last edited by vigge89; May 31st, 2004 at 02:04 PM.
I think you could probably get the desktop DC and blend the two images together and then paint it to the form.
You should also hide the form before getting the desktop DC...
If I'm not wrong, the desktop DC holds an image of the entire screen. You should be able to do it this way:
1) Hide the program
2) Copy the desktop DC to a local DC
3) Mix it with the skin
4) Paint it on the form
5) Show the program
Also everytime you move the form you'll have to remix the skin with the other DC. And everytime your program loses/gets focus, you should update the desktop DC, because other windows might have been moved.
(You don't have to get the whole DC, just the part that's behind the program)
Just as vigge89 says, there should be another way, but I don't know it. I know there is a way to make the program fully transparent in different regions, but you can not make it partially transparent using that method.
Originally posted by vigge89 that way would be kinda slow, laggy, and it would probably flicker alot, so it wouldn't look to good
That's probably true.
I've heard that the new windows "longhorn" will keep separate buffers for each windows which allows them to be blended with the other windows. Maybe you should wait for longhorn
Originally posted by vigge89 it is possible right now, i've seen lots of system-monitoring apps and stuff do this
I know that in 3D Mark when you load it, the splash screen fades in and blends with the background. But I think it does it using my method... Is it those kind of windows you're talking about? Or are you talking about those that you can move around?
I downloaded the code and looked trhough it, but i don't know C++ at all, so i can't "read" the code. If anyone could find the code for using the trans, could you tell me how it's done?
thanks...
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
From looking at rainwindow.cpp, it looks like it takes a pic of the desktop (inc. windows), draws itself on it, then displays it.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Hmm, i'm using SetLayeredWindowAttributes() which is an API in my project for setting alphatransparency, maybe they're related?
How i call the function:
VB Code:
SetLayeredWindowAttributes hWnd, RGB(255, 0, 255), bAlpha, LWA_COLORKEY Or LWA_ALPHA
Does anyone know what the UpdateLayeredWindow() does, and what it "is"?
Judging by C++ naming conventions i'd guess that ULW_ALPHA was a constant (unsigned long) value.
Sorry i can't help more.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
Well according to the declaration of 'updatelayeredwindow' it's its flags.
From the MSDN help:
dwFlags
This parameter can be one of the following values.
ULW_ALPHA
Use pblend as the blend function. If the display mode is 256 colors or less, the effect of this value is the same as the effect of ULW_OPAQUE.
ULW_COLORKEY
Use crKey as the transparency color.
ULW_OPAQUE
Draw an opaque layered window.
If hdcSrc is NULL, dwFlags should be zero.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
i've got another question now (don't forget the old one tho ):
I use this code to draw an image on an picturebox:
VB Code:
gfx.CreateFromHDC cmdExe.hDC
gfx.DrawImageI img_btn_normal.Handle, 0, 0
cmdExe.Refresh
gfx is the GDI+ graphics handle, and cmdExe is the picturebox (wrong name, i know). Now i'm wondering how to clear the drawn picture, so i can paint another image (which could be transprarent) on the picturebox. I've tried cmdExe.Cls, but that stops the picturebox from being painted on again. Does anyone know how to do it properly?
Edit: nevermind, got it to work by using:
VB Code:
cmdExe.Cls
gfx.CreateFromHDC cmdExe.hDC
gfx.DrawImageI img_btn_normal.Handle, 0, 0
cmdExe.Refresh
ANy new ideas on the main problem?
Last edited by vigge89; May 22nd, 2004 at 03:32 AM.
pulling this thread up again after i contacted the author of Rainlendar. He gave me an example source for doing this in C++.
Check the attachment for the Vc++ source. Now, i've studied some C++, but i'm not that good on it, so if anyone could take a look, if you could translate the code into english, so I can port the code into VB.
Here's the program i'm trying to add the feuture to (just an simple example program which uses the current way of painting images which i got in my main project)
I can't get the UpdateLayeredWindow() function to work