myloveqmx 发表于 2010-2-6 16:20:13

如何打开带图片预览和可以查看图标的对话框

预览图如下:



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

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

非典男人 发表于 2010-2-6 17:02:11

FileOpenDialog但是好像不能像你说的那种效果

sanmoking 发表于 2010-2-6 17:21:54

这个我猜的估计au3搞不来...

afan 发表于 2010-2-6 17:23:40

下面那个API函数里面有例子

catcher 发表于 2010-2-6 17:23:55

本帖最后由 catcher 于 2010-2-6 17:27 编辑

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

myloveqmx 发表于 2010-2-6 17:36:18

回复 4# afan


能不能告诉一下那个API的函数呢?谢谢~

myloveqmx 发表于 2010-2-6 17:37:29

回复 5# catcher


    能不能把源码发一下?谢谢~

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, $ahLabels
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

afan 发表于 2010-2-6 18:07:29

回复 6# myloveqmx #include <WinAPIEx.au3>
$Data = _WinAPI_PickIconDlg(@SystemDir & '\shell32.dll')
If Not @error Then MsgBox(0, '图标的索引:' & $Data, '文件路径:' & $Data)

myloveqmx 发表于 2010-2-10 16:34:18

O(∩_∩)O谢谢~,问题解决了:face (36):

pusofalse 发表于 2010-2-10 23:13:00

第一个功能肯定也有API能够调用,如果没有,可以自己画一个GUI~

rikthhpgf2005 发表于 2010-2-11 17:55:32

图片好不好!!!!:face (28):

lin0308 发表于 2010-2-11 18:37:53

8楼的代码我正需要

lin0308 发表于 2010-2-11 18:37:59

8楼的代码我正需要
页: [1]
查看完整版本: 如何打开带图片预览和可以查看图标的对话框