|
-
Sep 5th, 2001, 06:08 AM
#1
Thread Starter
Addicted Member
Fading An Icon Image
I'm using the SHGetFileInfo API get a handle to the 16 x 16 file icon, which all works fine.
How can I fade the icon image, like the Windows Explorer fades hidden files in Windows 2000.
I'm not using the ListView control so I can't use the Ghosted property, and I've already asked the API people and got no joy.
There must be a way of fading an icon image.
Help
Thanks in advance
-
Sep 5th, 2001, 07:53 AM
#2
Retired VBF Adm1nistrator
Well you could blend it 50/50 with a blank icon, or do a loop over the pixels of the icon to change the pixel colour to halfway between what it is and white...
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 08:54 AM
#3
Thread Starter
Addicted Member
Have you got any examples please?
-
Sep 5th, 2001, 09:29 AM
#4
Retired VBF Adm1nistrator
This code doesnt work yet, but I'd do something long these lines :
VB Code:
Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Sub Form_Load()
Picture1.Picture = LoadPicture("c:\a.bmp")
Me.Show
HalfFadeToWhite Picture1
End Sub
Private Sub HalfFadeToWhite(destPic As PictureBox)
Dim i As Long, j As Long, col As Long
Dim colwhite As Long, colRed As Long, colGreen As Long, colBlue As Long
colwhite = RGB(255, 255, 255)
destPic.Visible = False
For i = 0 To destPic.ScaleWidth
For j = 0 To destPic.ScaleHeight
col = GetPixel(destPic.hdc, i, j)
colRed = ((col Mod 256) + 255) / 2
colGreen = ((((col And &HFF00) / 256&) Mod 256&) + 255) / 2
colBlue = (((col And &HFF0000) / 65536) + 255) / 2
SetPixel destPic.hdc, i, j, RGB(colRed, colGreen, colBlue)
Next
Next
destPic.Visible = True
destPic.Refresh
End Sub
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 11:13 AM
#5
Thread Starter
Addicted Member
I like the idea.
I'm doing all this in a VB Active X DLL, and I don't want to add any forms to the project.
What is the easiest way to get a DC handle?
Create one using the CreateDC or CreateCompatibleDC API's, or use an existing one using the GetDC API.
If I was going to use an existing DC, which one would I use?
Can I use the Desktop DC?
-
Sep 5th, 2001, 11:21 AM
#6
Retired VBF Adm1nistrator
Quote from MSDN :
<start quote>
CreateCompatibleDC
The CreateCompatibleDC function creates a memory device context (DC) compatible with the specified device.
HDC CreateCompatibleDC(
HDC hdc // handle to the device context
);
Parameters
hdc
Handle to an existing device context. If this handle is NULL, the function creates a memory device context compatible with the application's current screen.
<end quote>
So it would appear that if you pass a null as the parameter to the createcompatibledc function it'll create a new dc for you anyway.
So try that.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Sep 5th, 2001, 11:40 AM
#7
Thread Starter
Addicted Member
I've just tried:
lngDC = CreateCompatibleDC(0)
and it works . It returns the new compatible DC handle.
Nice one
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|