Results 1 to 2 of 2

Thread: Get at project's icon at runtime?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2001
    Location
    N42 29.340 W71 53.215
    Posts
    422

    Question Get at project's icon at runtime?

    Is there a way I can get at the project's icon, the one set in Project - Properties - Make - Application ...
    at run time?

    What I want to do is load an Image control, e.g. right now I can do an
    image1.Picture = Form1.Icon
    but, I want the project's icon, which isn't necessarily Form1's.

    Thanks, DaveBo
    "The wise man doesn't know all the answers, but he knows where to find them."
    VBForums is one place, but for the really important stuff ... here's a clue 1Tim3:15

  2. #2
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    VB Code:
    1. 'This project needs a PictureBox, called 'Picture1'
    2.  
    3. 'In general section
    4. Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    5. Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    6. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    7.  
    8.  
    9. Private Sub Form_Load()
    10.     'KPD-Team 1998
    11.     'URL: [url]http://www.allapi.net/[/url]
    12.     'E-Mail: [email][email protected][/email]
    13.  
    14.     Dim Path As String, strSave As String
    15.     'Create a buffer string
    16.     strSave = String(200, Chr$(0))
    17.     'Get the windows directory and append '\REGEdit.exe' to it
    18.     Path = "YourFilePath"
    19.     'No pictures
    20.     Picture1.Picture = LoadPicture()
    21.     'Set graphicmode to 'persistent
    22.     Picture1.AutoRedraw = True
    23.     'Extract the icon from REGEdit
    24.     return1& = ExtractIcon(Me.hWnd, Path, 2)
    25.     'Draw the icon on the form
    26.     return2& = DrawIcon(Picture1.hdc, 0, 0, return1&)
    27. End Sub


    Has someone helped you? Then you can Rate their helpful post.

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