システムアイコンの複製 <TOP>
選択したシステムアイコンを複製し、表示させています。
LoadIcon アイコンの読込
DuplicateIcon システムアイコンの複製
DrawIcon アイコンの描画
WINLOGO(WindowsXP) WINLOGO(Windows98)
'================================================================ '= システムアイコンの複製 '= (DuplicateIcon.bas) '================================================================ #include "Windows.bi" #define IDI_APPLICATION 32512 #define IDI_HAND 32513 #define IDI_ERROR 32513 'IDI_HAND #define IDI_QUESTION 32514 #define IDI_WARNING 32515 'IDI_EXCLAMATION #define IDI_EXCLAMATION 32515 #define IDI_ASTERISK 32516 #define IDI_INFORMATION 32516 'IDI_ASTERISK #define IDI_WINLOGO 32517 ' アイコンの複製 Declare Function Api_DuplicateIcon& Lib "shell32" Alias "DuplicateIcon" (ByVal hInst&, ByVal hIcon&) ' アイコンのハンドルを解放 Declare Function Api_DestroyIcon& Lib "user32" Alias "DestroyIcon" (ByVal hIcon&) ' アイコンを描画 Declare Function Api_DrawIcon& Lib "user32" Alias "DrawIcon" (ByVal hDC&, ByVal x&, ByVal y&, ByVal exhIcon&) ' アイコン読込 Declare Function Api_LoadIcon& Lib "user32" Alias "LoadIconA" (ByVal hInstance&, ByVal lpIconName&) ' 指定されたウィンドウのクライアント領域または画面全体を表すディスプレイデバイスコンテキストのハンドルを取得 Declare Function Api_GetDC& Lib "user32" Alias "GetDC" (ByVal hWnd&) ' デバイスコンテキストを解放 Declare Function Api_ReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hWnd&, ByVal hDC&) Var Shared Radio(5) As Object Var Shared Button1 As Object For i = 0 To 5 Radio(i).Attach GetDlgItem("Radio" & Trim$(Str$(i + 1))) : Radio(i).SetFontSize 14 Next i Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14 '================================================================ '= '================================================================ Declare Function Index bdecl () As Integer Function Index() Index = Val(Mid$(GetDlgRadioSelect("Radio1"), 6)) - 1 End Function '================================================================ '= '================================================================ Declare Sub Button1_on edecl () Sub Button1_on() Var Ret As Long Var hDC As Long Var hIcon As Long Var hDuplIcon As Long hDC = Api_GetDC(GetHwnd) Select Case Index Case 0 hIcon = Api_LoadIcon(ByVal 0, IDI_APPLICATION) Case 1 hIcon = Api_LoadIcon(ByVal 0, IDI_ERROR) Case 2 hIcon = Api_LoadIcon(ByVal 0, IDI_QUESTION) Case 3 hIcon = Api_LoadIcon(ByVal 0, IDI_EXCLAMATION) Case 4 hIcon = Api_LoadIcon(ByVal 0, IDI_ASTERISK) Case 5 hIcon = Api_LoadIcon(ByVal 0, IDI_WINLOGO) End Select Cls hDuplIcon = Api_DuplicateIcon(ByVal 0, hIcon) Ret = Api_DrawIcon(hDC, 10, 10, hDuplIcon) Ret = Api_DestroyIcon(hIcon) Ret = Api_DestroyIcon(hDuplIcon) Ret = Api_ReleaseDC(GetHwnd, hDC) End Sub '================================================================ '= '================================================================ While 1 WaitEvent Wend Stop End