Results 1 to 9 of 9

Thread: Ghosting An Icon

  1. #1

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Question Ghosting An Icon

    When a file is hidden, the file icon is displayed in the Windows Explorer with a Ghost like effect.

    How do you ghost an icon?

    I'm not using the ListView control, so I can't simply set the Ghosted property to True.



    Thanks in advance.

  2. #2
    Megatron
    Guest
    I think explorer does that manually by brightening the color.

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    I'll give you the code for this tomorrow, what happens is that there is a hidden listview, and a LVM_SETITEMSTATE message gets sent, same as a treeview....I'm 80% thru the code, you'll have it tomorrow, as for the find dialog hack with the findwindow e.t.c it WORKED A TREAT, I was pretty chuffed too, here it is - have fun (I know it's not the best way to do it, but it works)
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Here's a better version with a wait for the dialog to load, I tried waiting less time, but it fails...
    Attached Files Attached Files
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  5. #5

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185
    Here's the code for Windows 2000 I was playing with.
    I just can't get it to select the Local Harddrives item in the Look in ComboBox.
    Attached Files Attached Files

  6. #6
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    i understand now - i'll make it work tonight when i get home to my w2k advanced server machine.....
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  7. #7

    Thread Starter
    Addicted Member VB6Coder's Avatar
    Join Date
    Apr 2001
    Location
    Northampton, UK
    Posts
    185

    Smile

    Here's the code for Windows 2000 which sets the look in combo to Local Harddrives. It works.
    Attached Files Attached Files

  8. #8
    Addicted Member
    Join Date
    Feb 2001
    Location
    Upstate NY
    Posts
    210
    you can do it via DOS. i don't know if that's what those examples show but you run this:
    Shell("C:\windows\command\attrib.exe +h C:\filename.dat")
    that will make it 'ghosted', if you replace it with a -h it unghosts it.
    < o >

  9. #9
    assbeef
    Guest

    More effeicient idea

    You could use simple VBScript to do it for you.
    You just change the Attributes property of the File Object.
    Here is an example of a helpful sub that will change the attributes of a file for you:

    Private Sub ChangeFileAttributes(Path As String, ReadOnly _
    As Boolean, Hidden As Boolean, Archive As Boolean)
    Dim FSO As Object
    Dim objFile As Object
    Dim AttrVal As Integer
    Const intReadOnly = 1
    Const intHidden = 2
    Const intArchive = 32

    'Calculate Attribute Number
    If ReadOnly = True Then AttrVal = intReadOnly
    If Hidden = True Then AttrVal = AttrVal + intHidden
    If Archive = True Then AttrVal = AttrVal + intArchive

    'Set Attributes
    On Error GoTo FileError
    Set FSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = FSO.GetFile(Path)
    objFile.Attributes = AttrVal

    Exit Sub
    FileError:
    'If error occured show msgbox
    MsgBox "An error occured, file may not exists."
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width