In VB, Clipboard.SetData Gives "Invalid Format" with Icon

ID Number: Q78073

1.00

WINDOWS

buglist1.00

Summary:

If you use a the Visual Basic LoadPicture function to load an icon

file (.ICO) into a picture control, then attempt to copy that picture

control's picture to the Clipboard using the SetData method, the error

message "Invalid Clipboard Format" will be displayed, regardless of

the format specified for the SetData method.

Microsoft has confirmed this to be a problem in Microsoft Visual Basic

programming system version 1.0 for Windows. We are researching this

problem and will post new information here as it becomes available.

More Information:

This error will also occur if you attempt to directly load an icon

file into the Clipboard using:

ClipBoard.SetData LoadPicture("c:\vb\icons\arrows\arw01rt.ico")

To work around this problem, set the picture control's Autoredraw

property to True (-1) and use the Picture control's Image property in

the SetData method rather than the Picture control's picture property.

'*** This code will fail with the error "Invalid Clipboard Format" ***

Picture1.Picture = LoadPicture("c:\vb\icons\arrows\arw01rt.ico")

Clipboard.SetData Picture1.Picture, 2

'*** This will avoid the error ***

Picture1.Autoredraw = -1

Picture1.Picture = LoadPicture("c:\vb\icons\arrows\arw01rt.ico")

Clipboard.SetData Picture1.Image, 2

'*** This will also work ***

Picture1.Picture = LoadPicture("c:\vb\icons\arrows\arw01rt.ico")

Picture1.Picture = Picture1.Image

Clipboard.SetData Picture1.Picture, 2

Additional reference words: 1.00