Sign in to follow this  
Followers 0
Noddle

FileOpenDialog wanting to show in "thumbnails" view

6 posts in this topic

Hi

is there a way to make

FileOpenDialog show the files listed in a "thumbnail" view by defaut without clicking on the "view menu" button

to select "thumbnails'

i'm working with images..

$var = FileOpenDialog($message, $_RunningPath & "", "Images (*.jpg)", 1 + 4)

thanks for anyhelp,

Nigel

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include "_FileDialogsEx.au3"

Global $f_CDN_Start = 1

$Return = _FileOpenDialogEx("", @WindowsDir & "\Web\Wallpaper", "All Files (*.*)", BitOR($OFN_ENABLESIZING,$OFN_ALLOWMULTISELECT), "", 0, "_OFN_HookProc")
If @error Then
ConsoleWrite('No file selected.' & @CRLF)
Else
ConsoleWrite($Return & @CRLF)
EndIf

Func _OFN_HookProc($hWnd, $Msg, $wParam, $lParam)
Switch $Msg
  Case $WM_NOTIFY
   Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
   $tNMHDR = DllStructCreate("hwnd hWndFrom;int idFrom;int code", $lParam)
   $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
   $iIDFrom = DllStructGetData($tNMHDR, "idFrom")
   $iCode = DllStructGetData($tNMHDR, "code")
   Switch $iCode
    Case $CDN_INITDONE
    Case $CDN_FOLDERCHANGE
     If $f_CDN_Start Then;if executing first time
      Local $hODLV = _FindWindowEx($hWndFrom, 0, "SHELLDLL_DefView", "")
      If $hODLV <> 0 Then
       DllCall('user32.dll','int','SendMessage','hwnd',$hODLV,'uint',$WM_COMMAND,'wparam',$ODM_VIEW_THUMBS,'lparam',0)
      EndIf
      WinMove($hWndFrom, "", 0,0, 400, 200, 0)
      $f_CDN_Start = 0;to make sure these tweaks happens only once.
     EndIf
    Case $CDN_SELCHANGE
    Case $CDN_FILEOK
   EndSwitch
  Case Else
EndSwitch
EndFunc

Func _FindWindowEx($hWndParent,$hWndChildAfter,$sClassName,$sWinTitle="")
Local $aRet = DllCall('user32.dll','hwnd','FindWindowEx', 'hwnd', $hWndParent,'hwnd',$hWndChildAfter,'str',$sClassName,'str',$sWinTitle)
If $aRet[0] = 0 Then ConsoleWrite('_FindWindowEx() Error : ' & _WinAPI_GetLastErrorMessage())
Return $aRet[0]
EndFunc

Exit

Edited by johnmcloud

Share this post


Link to post
Share on other sites

This will not run, it uses @Unicode

in the changlog for Auto it, it says this

16th May, 2008 - v3.2.12.0

AutoIt:

  • Changed: @Unicode renamed to @AutoItUnicode. @Unicode is an alias for now. It will be removed > 3.2.14.0

so I go to use @AutoitUnicode, it still will not work,

so more time on Google, I found this,

3.2.13.1 (10th June, 2008) (Beta)

AutoIt:

- Removed #357: @AutoItUnicode macro.

So it looks like this has not worked for a long time..

so has anyone else have any ideas how to do what I want ?

Nigel

Share this post


Link to post
Share on other sites

Change @Unicode with "" and magically it work...

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

KaFu,

On that example there isn't the type mode ( Detail, Thumbs etc. )

Based on your modified version:

#include "_FileDialogsEx.au3"

Global Const $CBN_SELCHANGE = 1
Global $__aDialogDef[3]

$__aDialogDef[0] = "Export to"
$__aDialogDef[1] = "Export"
$__aDialogDef[2] = "Cancel"
Global $Type = $ODM_VIEW_THUMBS
$Output = _FileSaveDialogEx("", @WindowsDir & "\Web\Wallpaper", "All Files (*.*)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_HookProc")

$__aDialogDef[0] = "Save as"
$__aDialogDef[1] = "Save"
$__aDialogDef[2] = "Cancel"
Global $Type = $ODM_VIEW_ICONS
$Output = _FileSaveDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_OVERWRITEPROMPT, $OFN_PATHMUSTEXIST, $OFN_DONTADDTORECENT), "", 0, "_HookProc")

$__aDialogDef[0] = "Open File"
$__aDialogDef[1] = "Open"
$__aDialogDef[2] = "Cancel"
Global $Type = $ODM_VIEW_LIST
$Output = _FileOpenDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_FILEMUSTEXIST, $OFN_PATHMUSTEXIST, $OFN_ALLOWMULTISELECT), "", 0, "_HookProc")

$__aDialogDef[0] = "Import File"
$__aDialogDef[1] = "Import"
$__aDialogDef[2] = "Cancel"
Global $Type = $ODM_VIEW_TILES
$Output = _FileOpenDialogEx("", @MyDocumentsDir, "Text Files (*.txt)", BitOR($OFN_FILEMUSTEXIST, $OFN_PATHMUSTEXIST, $OFN_ALLOWMULTISELECT), "", 0, "_HookProc")

Func _HookProc($hWnd, $Msg, $wParam, $lParam)
 Switch $Msg
  Case $WM_INITDIALOG
   Local $hDlg = _WinAPI_GetParent($hWnd)
   _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDOK, $__aDialogDef[1], 0, "int", "wstr")
   _SendMessage($hDlg, $CDM_SETCONTROLTEXT, $IDCANCEL, $__aDialogDef[2], 0, "int", "wstr")
   ControlCommand($hDlg, "", '[CLASS:ComboBox;Instance:3]', "AddString", 'ANSI')
   $aWinSize = WinGetPos($hDlg, "")
   WinMove($hDlg, "", @DesktopWidth / 2 - $aWinSize[2] / 2, @DesktopHeight / 2 - $aWinSize[3] / 2)
   WinSetTitle($hDlg, "", $__aDialogDef[0])
  Case $WM_COMMAND
   Local $hComboEnc = ControlGetHandle($hWnd, "", '[CLASS:ComboBox;Instance:3]')
   Local $iCode = BitShift($wParam, 16)
   If $lParam = $hComboEnc And $iCode = $CBN_SELCHANGE Then
    $sEncoding = ControlCommand($hWnd, "", '[CLASS:ComboBox;Instance:3]', "GetCurrentSelection", "")
   EndIf
   ConsoleWrite($sEncoding & @CRLF)
  Case $WM_NOTIFY
   Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
   $tNMHDR = DllStructCreate("hwnd hWndFrom;int idFrom;int code", $lParam)
   $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom")
   $iIDFrom = DllStructGetData($tNMHDR, "idFrom")
   $iCode = DllStructGetData($tNMHDR, "code")
   Switch $iCode
    Case $CDN_INITDONE
    Case $CDN_FOLDERCHANGE
     Local $aRet = DllCall('user32.dll', 'hwnd', 'FindWindowEx', 'hwnd', $hWndFrom, 'hwnd', 0, 'str', "SHELLDLL_DefView", 'str', "")
     If $aRet[0] = 0 Then
      ConsoleWrite("_FindWindowEx Error")
     Else
      DllCall('user32.dll', 'int', 'SendMessage', 'hwnd', $aRet[0], 'uint', $WM_COMMAND, 'wparam', $Type, 'lparam', 0)
     EndIf
   EndSwitch
 EndSwitch
EndFunc   ;==>_HookProc

I don't know how to make a Func parameter for:

$ODM_VIEW_ICONS = 0x7029

$ODM_VIEW_LIST = 0x702b

$ODM_VIEW_DETAIL = 0x702c

$ODM_VIEW_THUMBS = 0x702d

$ODM_VIEW_TILES = 0x702e

Edited by johnmcloud

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0