News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

DrawIcon function

Started by Robert Collins, October 29, 2005, 06:49:00 PM

Previous topic - Next topic

Robert Collins

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?



Robert Collins

OK, never mind. I got around this problem.