找回密码
 加入
搜索
查看: 5055|回复: 13

[GUI管理] 如何打开带图片预览和可以查看图标的对话框

 火.. [复制链接]
发表于 2010-2-6 16:20:13 | 显示全部楼层 |阅读模式
预览图如下:



打开后如何再得到返回值?

大家有知道的话,希望能帮忙解答一下,谢谢~

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-2-6 17:02:11 | 显示全部楼层
FileOpenDialog
但是好像不能像你说的那种效果
发表于 2010-2-6 17:21:54 | 显示全部楼层
这个我猜的估计au3搞不来...
发表于 2010-2-6 17:23:40 | 显示全部楼层
下面那个API函数里面有例子
发表于 2010-2-6 17:23:55 | 显示全部楼层
本帖最后由 catcher 于 2010-2-6 17:27 编辑

你的下图跟在DLL中找图标是不是一样的?我好像在帮助里找到过,我看一下.
是这样吗?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2010-2-6 17:36:18 | 显示全部楼层
回复 4# afan


能不能告诉一下那个API的函数呢?谢谢~
 楼主| 发表于 2010-2-6 17:37:29 | 显示全部楼层
回复 5# catcher


    能不能把源码发一下?谢谢~
发表于 2010-2-6 17:43:31 | 显示全部楼层
本帖最后由 catcher 于 2010-2-6 17:45 编辑

回复 7# myloveqmx
AU3自带的例子,路径如下:
D:\autoit3\Examples\GUI\Advanced\enumicons.au3
代码也一起CTRL+V给你吧
;===============================================================================
;
; Description:      Show all icons in the given file
; Requirement(s):   Autoit 3.0.103+
; Author(s):        YDY (Lazycat)
;
;===============================================================================

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <StaticConstants.au3>


; Setting variables
Global $ahIcons[30], $ahLabels[30]
Global $iStartIndex = 1, $iCntRow, $iCntCol, $iCurIndex
Global $sFilename = @SystemDir & "\shell32.dll"; Default file is "shell32.dll"
Global $iOrdinal = -1

Global $hPrev

_Main()

Func _Main()
        Local $hGui, $hFile, $hFileSel, $hNext, $hToggle
        Local $iMsg, $sCurFilename, $sTmpFile

        ; Creating GUI and controls
        $hGui = GUICreate("Icon Selector by Ordinal value", 385, 435, @DesktopWidth / 2 - 192, _
                        @DesktopHeight / 2 - 235, -1, $WS_EX_ACCEPTFILES)
        GUICtrlCreateGroup("", 5, 1, 375, 40)
        GUICtrlCreateGroup("", 5, 50, 375, 380)
        $hFile = GUICtrlCreateInput($sFilename, 12, 15, 325, 16, -1, $WS_EX_STATICEDGE)
        GUICtrlSetState(-1, $GUI_DROPACCEPTED)
        GUICtrlSetTip(-1, "You can drop files from shell here...")
        $hFileSel = GUICtrlCreateButton("...", 345, 14, 26, 18)
        $hPrev = GUICtrlCreateButton("Previous", 10, 45, 60, 24, $BS_FLAT)
        GUICtrlSetState(-1, $GUI_DISABLE)
        $hNext = GUICtrlCreateButton("Next", 75, 45, 60, 24, $BS_FLAT)
        $hToggle = GUICtrlCreateButton("by Name", 300, 45, 60, 24, $BS_FLAT)

        ; This code build two arrays of ID's of icons and labels for easily update
        For $iCntRow = 0 To 4
                For $iCntCol = 0 To 5
                        $iCurIndex = $iCntRow * 6 + $iCntCol
                        $ahIcons[$iCurIndex] = GUICtrlCreateIcon($sFilename, $iOrdinal * ($iCurIndex + 1), _
                                        60 * $iCntCol + 25, 70 * $iCntRow + 80)
                        $ahLabels[$iCurIndex] = GUICtrlCreateLabel($iOrdinal * ($iCurIndex + 1), _
                                        60 * $iCntCol + 11, 70 * $iCntRow + 115, 60, 20, $SS_CENTER)
                Next
        Next

        GUISetState()

        While 1
                $iMsg = GUIGetMsg()
                ; Code below will check if the file is dropped (or selected)
                $sCurFilename = GUICtrlRead($hFile)
                If $sCurFilename <> $sFilename Then
                        $iStartIndex = 1
                        $sFilename = $sCurFilename
                        _GUIUpdate()
                EndIf
                ; Main "Select" statement that handles other events
                Select
                        Case $iMsg = $hFileSel
                                $sTmpFile = FileOpenDialog("Select file:", "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}", "Executables & dll's (*.exe;*.dll;*.ocx;*.icl)")
                                If @error Then ContinueLoop
                                GUICtrlSetData($hFile, $sTmpFile); GUI will be updated at next iteration
                        Case $iMsg = $hPrev
                                $iStartIndex = $iStartIndex - 30
                                _GUIUpdate()
                        Case $iMsg = $hNext
                                $iStartIndex = $iStartIndex + 30
                                _GUIUpdate()
                        Case $iMsg = $hToggle
                                If $iOrdinal = -1 Then
                                        $iOrdinal = 1
                                        GUICtrlSetData($hToggle, "by Ordinal")
                                        WinSetTitle($hGui, "", "Icon Selector by Name value")
                                Else
                                        $iOrdinal = -1
                                        GUICtrlSetData($hToggle, "by Name")
                                        WinSetTitle($hGui, "", "Icon Selector by Ordinal value")
                                EndIf
                                _GUIUpdate()
                        Case $iMsg = $GUI_EVENT_CLOSE
                                Exit
                EndSelect
        WEnd
EndFunc   ;==>_Main

; Just updates GUI icons, labels and set state of "Previous" button
Func _GUIUpdate()
        For $iCntRow = 0 To 4
                For $iCntCol = 0 To 5
                        $iCurIndex = $iCntRow * 6 + $iCntCol
                        GUICtrlSetImage($ahIcons[$iCurIndex], $sFilename, $iOrdinal * ($iCurIndex + $iStartIndex))
                        If $iOrdinal = -1 Then
                                GUICtrlSetData($ahLabels[$iCurIndex], -($iCurIndex + $iStartIndex))
                        Else
                                GUICtrlSetData($ahLabels[$iCurIndex], '"' & ($iCurIndex + $iStartIndex) & '"')
                        EndIf
                Next
        Next
        ; This is because we don't want negative values
        If $iStartIndex = 1 Then
                GUICtrlSetState($hPrev, $GUI_DISABLE)
        Else
                GUICtrlSetState($hPrev, $GUI_ENABLE)
        EndIf
EndFunc   ;==>_GUIUpdate
发表于 2010-2-6 18:07:29 | 显示全部楼层
回复 6# myloveqmx
#include <WinAPIEx.au3>
$Data = _WinAPI_PickIconDlg(@SystemDir & '\shell32.dll')
If Not @error Then MsgBox(0, '图标的索引:' & $Data[1], '文件路径:' & $Data[0])
 楼主| 发表于 2010-2-10 16:34:18 | 显示全部楼层
O(∩_∩)O谢谢~,问题解决了
发表于 2010-2-10 23:13:00 | 显示全部楼层
第一个功能肯定也有API能够调用,如果没有,可以自己画一个GUI~
发表于 2010-2-11 17:55:32 | 显示全部楼层
图片好不好!!!!
发表于 2010-2-11 18:37:53 | 显示全部楼层
8楼的代码我正需要
发表于 2010-2-11 18:37:59 | 显示全部楼层
8楼的代码我正需要
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-11 04:56 , Processed in 0.084618 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表