Private Sub Command1_Click()
Const MAX_SIZE As Long = 5826
On Error GoTo fel
ImageList1.ListImages.Clear
CommonDialog1.FileName = ""
CommonDialog1.Filter = "Bitmappar|*.bmp"
CommonDialog1.DialogTitle = "Lada bild"
CommonDialog1.ShowOpen
If CommonDialog1.FileName <> "" Then
If FileLen(CommonDialog1.FileName) <= MAX_SIZE Then
ImageList1.ListImages.Add , , LoadPicture(CommonDialog1.FileName)
CommonDialog1.FileName = ""
CommonDialog1.Filter = "Ikoner|*.ico"
CommonDialog1.DialogTitle = "Spara ikon"
CommonDialog1.ShowSave
If CommonDialog1.FileName <> "" Then
SavePicture ImageList1.ListImages(1).ExtractIcon, CommonDialog1.FileName
End If
Else
MsgBox "Bilden är för stor!!!", vbInformation
End If
End If
fel:
If Err.Number <> 0 Then
MsgBox Err.Description
End If
End Sub