The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => The Orphanage => Topic started by: Robert Collins on October 29, 2005, 06:49:00 PM

Title: DrawIcon function
Post by: Robert Collins on October 29, 2005, 06:49:00 PM
If I make a VB program that has a PictureBox control on it and I wand to fetch an icon from a file and display the icon in the PictureBox control I use the following to do so:


Sub PutIconInPictureBox()
  Dim IconHwnd As Long
  '
  '
  IconHwnd = ExtractIcon(App.hInstance, "thefile.exe",  1)
  PictureBox.AutoRedraw = True 
  DrawIcon(PictureBox.hDC, 0, 0, IconHwnd)
  '
  '
End Sub


Now the above works as long as I have the PictureBox control AutoRedraw property set to True.

However, if I want to call a function in a DLL to do this where the DLL function contains the ExtractIcon and DrawIcon APIs and takes care of the positioning and fetching of the Icon and other stuff I use the following:


Sub PutIconInPictureBox()
  '
  '
  PictureBox.AutoRedraw = False 
  dll_DrawIcon(Me.hWnd, PictureBox.hDC, 1)
  '
  '
End Sub


The above only works if the AutoRedraw property of the PictureBox is set to False (just the opposite of the first method). If I set the AutoRedraw property to True it wont work.

This doesn't make any sense to me.

Anyone have any ideas about this?


Title: Re: DrawIcon function
Post by: Robert Collins on December 09, 2005, 06:54:38 PM
OK, never mind. I got around this problem.