Results 1 to 2 of 2

Thread: Extract Icon of a form

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 2001
    Posts
    112

    Extract Icon of a form

    Hi all,

    I got a vb exe which has three forms. Each form has its own icon. How can i retrieve the icon of each form from another vb project?


    Thanks

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Play around with this example
    VB Code:
    1. 'In general section
    2. Private Declare Function DrawIcon Lib "user32" Alias "DrawIcon" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
    3. Private Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
    4. Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    5.  
    6.  
    7. Private Sub Form_Load()
    8.     'KPD-Team 1998
    9.     'URL: [url]http://www.allapi.net/[/url]
    10.     'E-Mail: [email][email protected][/email]
    11.  
    12.     Dim Path as String, strSave as string
    13.     'Create a buffer string
    14.     strSave = String(200, Chr$(0))
    15.     'Get the windows directory and append '\REGEdit.exe' to it
    16.     Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave))) + "\REGEdit.exe"
    17.     'No pictures
    18.     Picture1.Picture = LoadPicture()
    19.     'Set graphicmode to 'persistent
    20.     Picture1.AutoRedraw = True
    21.     'Extract the icon from REGEdit
    22.     return1& = ExtractIcon(Me.hWnd, Path, 2)
    23.     'Draw the icon on the form
    24.     return2& = DrawIcon(Picture1.hdc, 0, 0, return1&)
    25. 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