HSPポータル
サイトマップ お問い合わせ


HSPTV!掲示板


未解決 解決 停止 削除要請

2020
0121
こいる特定のアイコンを確実に取得して描画したい3解決


こいる

リンク

2020/1/21(Tue) 18:07:52|NO.89306

開くプログラムがまだ決まっていないファイルなどに使われている、
白いファイルのアイコンを確実に取得して描画したいです。


ファイルの種類・アイコンの取得
http://lhsp.s206.xrea.com/hsp_file.html#11

上のページの方法で、特定のファイルのアイコンを
取得することができるのは分かったのですが、

わざわざアイコン取得用のファイルを作って、取得して消すのは面倒ですし、
万が一、その取得用のファイルのアイコンが、
なんらかの要因で別のアイコンになっている可能性もあるので、別の方法が良いです。


確実にアイコンを取得する方法を教えてください。お願いします。



この記事に返信する


kanamaru

リンク

2020/1/21(Tue) 18:28:08|NO.89307

過去ログにあったプログラムの引数を変えただけですが、
このアイコンでしょうか?

#uselib "user32.dll" #func global InvalidateRect "InvalidateRect" int,int,int #func global DrawIconEx "DrawIconEx" int,int,int,int,int,int,int,int,int #uselib "shell32.DLL" #func global ExtractIconEx "ExtractIconExA" int,int,int,int,int filename="ImageRes.DLL" ExtractIconEx varptr(filename),2,varptr(hicon),0,1;アイコン抽出 DrawIconEx hdc,0,0,hicon,32,32,0,0,3 InvalidateRect hwnd,0,1
表示する場所はDrawIconExの第二引数、第三引数で指定します。
第五引数、第六引数でサイズが変えられます。



あらや

リンク

2020/1/21(Tue) 19:17:47|NO.89308

かぶってしまいましたが……
白いファイルのアイコンは色んな所にあるので
shell32.dllから取得&色んなサイズを全て同じサイズで描画してみました。


#uselib "shell32.dll" #cfunc ExtractIcon "ExtractIconA" int, str, int // アイコン取得用1(アイコンサイズ固定) #cfunc ExtractIconEx "ExtractIconExA" str, int, sptr, sptr, int // アイコン取得用2(大小のアイコン取得) #uselib "user32.dll" #func DrawIconEx "DrawIconEx" int, int, int, int, int, int, int, int, int #func DestroyIcon "DestroyIcon" int #define DI_NORMAL 0x0003 ///////////////////////////////// サイズ固定版 posx = 10; // 描画位置X posy = 10; // 描画位置Y iconWidth = 64; // 描画するサイズX iconHeight = 64; // 描画するサイズY hIcon = ExtractIcon( hInstance, "shell32.dll", 0); // アイコンのハンドル取得 // アイコンハンドルからウィンドウに直接描画 DrawIconEx hdc, posx, posy, hIcon, iconWidth, iconHeight, 0, 0, DI_NORMAL; DestroyIcon hIcon; // アイコンハンドルの破棄 pos posx + 15, 80:mes "通常"; ///////////////////////////////// 大小取得版 dim smallIcon, 4; dim largeIcon, 4; iconnum = ExtractIconEx( "shell32.dll", 0, varptr(largeIcon), varptr(smallIcon), 1 ); repeat iconnum DrawIconEx hdc, posx + 250, posy + cnt*64, largeIcon(cnt), iconWidth, iconHeight, 0, 0, DI_NORMAL; DrawIconEx hdc, posx + 500, posy + cnt*64, smallIcon(cnt), iconWidth, iconHeight, 0, 0, DI_NORMAL; DestroyIcon largeIcon(cnt); DestroyIcon smallIcon(cnt); loop pos posx + 245, 80:mes "アイコン大"; pos posx + 495, 80:mes "アイコン小"; redraw 1; // 直接描画したため、再描画しないと反映されない



こいる

リンク

2020/1/21(Tue) 21:05:00|NO.89312

kanamaruさん、あらやさん、ありがとうございます!
お二人のおかげで解決しました!

一応、アイコンの確認用に作った、
アイコンを全て描画するスクリプトを置いておきます。


#uselib "shell32.dll" #cfunc ExtractIcon "ExtractIconA" int, str, int // アイコン取得用1(アイコンサイズ固定) #cfunc ExtractIconEx "ExtractIconExA" str, int, sptr, sptr, int // アイコン取得用2(大小のアイコン取得) #uselib "user32.dll" #func DrawIconEx "DrawIconEx" int, int, int, int, int, int, int, int, int #func DestroyIcon "DestroyIcon" int #define DI_NORMAL 0x0003 // 対象 filename = "shell32.dll" ;filename = "ImageRes.DLL" // 横の数 x = 30 total = ExtractIcon(hInstance, filename, -1);アイコン総数 // ウィンドウ初期化 val = total/x val + 1 winx = 40*x+15; // ウィンドウ横サイズ winy = 40*val +15; // ウィンドウ縦サイズ screen 0,winx,winy redraw 0; // 描画更新停止 posx = -30; // 描画位置X posy = -30; // 描画位置Y iconWidth = 32; // 描画するサイズX iconHeight = 32; // 描画するサイズY index = -1 font "メイリオ",13,2 // メイン repeat posx = -30 posy + 40 repeat x index + 1 posx + 40 hIcon = ExtractIcon( hInstance, filename, index); // アイコンのハンドル取得 // アイコンハンドルからウィンドウに直接描画 DrawIconEx hdc, posx, posy, hIcon, iconWidth, iconHeight, 0, 0, DI_NORMAL; DestroyIcon hIcon; // アイコンハンドルの破棄 pos posx,posy :mes index; // インデックス描画 if index>=total:break; // 全て描画し終わったらbreak loop if index>=total:break; // 全て描画し終わったらbreak loop redraw 1; // 直接描画したため、再描画しないと反映されない



ONION software Copyright 1997-2023(c) All rights reserved.