お世話になります。
さて早速質問なのですが、SHGetFileInfo で取得したファイルのアイコンを Picture1 に描画させた後に、
Picture2.Picture = Picture1.Picture
のようなことをやりたいのですが、これを可能にするまでの手続きはどのようにすればよいのでしょうか?
ちなみに、SHGetFileInfo を使ってのアイコン取得は、下記のように行っています。
Dim lngTargetInfomation As Long
Dim utdShellFileInfo As SHFILEINFOA
Dim lngRC As Long
Dim strFileName As string
strFileName = "d:\test.txt"
lngTargetInfomation = SHGFI_ICON Or SHGFI_SMALLICON
lngRC = SHGetFileInfo(strFileName, _
0, _
utdShellFileInfo, _
Len(utdShellFileInfo), _
lngTargetInfomation)
With Picture1
.Cls
lngRC = DrawIcon(.hdc, 0, 0, utdShellFileInfo.hIcon)
End With
Picture1.AuteSize=True
にしといて
アイコン描画(DrawIcon)
そしてDrawIcon
そのあと
Picture2.PaintPicture Picture1.Image, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
'サイズ指定はテキトーです妥当な引数を指定してください
みたいだったっけかな
あとBitBltでもできます。
アドバイスありがとうございます。
早速
RC = DrawIcon(.hdc, 0, 0, utdShellFileInfo.hIcon)
Picture1.AuteSize=True
Picture2.PaintPicture Picture1.Image, 0, 0,Picture1.ScaleWidth, Picture1.ScaleHeight
を実行してみたのですが、残念なことに Picture2 にはアイコンが描画されませんでした。
何がおかしかったのでしょうか。
これでは?
Picture1.AuteSize=True
Picture1.AuteRedraw=True
Picture2.AuteSize=True
Picture2.AuteRedraw=True
RC = DrawIcon(Picture1.hdc, 0, 0, utdShellFileInfo.hIcon)
Picture2.PaintPicture Picture1.Image, 0, 0,Picture1.ScaleWidth, Picture1.ScaleHeight
AutoRedraw = True にして、
DrawIcon()等で描画後、
Picture1.Picture = Picture1.Image
そして、
Picture2.Picture = Picture1.Picture
では?
犬ひろしさん、pictさんありがとうございました。
うまく Picture2 に描画させることができました!!
ツイート | ![]() |