Sign in to follow this  
Followers 0
trancexx

FileOpenDialogWithPreview

8 posts in this topic

It's FileOpenDialog with preview :).

Called from msvfw32.dll. Looks like shit IMHO but gives the option to preview media files before selecting one.

All you need to do is browse to some folder with some music or video and you will get an option to preview it.

Like I said, I don't like it but hey it's just me. For example I don't like Robbie Williams, Lady Gaga or F1 races too.

Script with one example:

Global $sSelected = _FileOpenDialogWithPreview("Open with preview", "", "Music files (*.mp3;*.wav;*.wma)| Video files (*.avi)| All files (*.*)", "")

ConsoleWrite("!@error = " & @error & @CRLF)
ConsoleWrite("Selected: " & $sSelected & @CRLF)





Func _FileOpenDialogWithPreview($sTitle = "Open", $sInitDir = "", $sFilter = "All Files (*.*)", $sDefaultName = "", $hWnd = 0)

    ; OPENFILENAME structure:
    Local $tOPENFILENAME = DllStructCreate("dword StructSize;" & _
            "hwnd Owner;" & _
            "ptr Instance;" & _
            "ptr Filter;" & _
            "ptr  CustomFilter;" & _
            "dword MaxCustFilter;" & _
            "dword FilterIndex;" & _
            "ptr File;" & _
            "dword MaxFile;" & _
            "ptr FileTitle;" & _
            "dword MaxFileTitle;" & _
            "ptr InitialDir;" & _
            "ptr Title;" & _
            "dword Flags;" & _
            "ushort FileOffset;" & _
            "ushort FileExtension;" & _
            "ptr DefExt;" & _
            "ptr CustData;" & _
            "ptr Hook;" & _
            "ptr TemplateName;" & _
            "ptr Reserved;" & _
            "dword SizeReserved;" & _
            "dword FlagsEx")

    ; Set size and owner:
    DllStructSetData($tOPENFILENAME, "StructSize", DllStructGetSize($tOPENFILENAME))
    DllStructSetData($tOPENFILENAME, "Owner", $hWnd)

    ; Filter job:
    Local $tagFilter
    Local $aArray = StringRegExp($sFilter & "|", "\s*(.*?)\s*\((.*?)\)\|", 3)

    For $i = 0 To UBound($aArray) - 1
        $tagFilter &= "wchar[" & StringLen($aArray[$i]) + 1 & "];"
    Next

    $tagFilter &= "wchar"

    Local $tFilter = DllStructCreate($tagFilter)
    For $i = 0 To UBound($aArray) - 1
        DllStructSetData($tFilter, $i + 1, $aArray[$i])
    Next

    DllStructSetData($tOPENFILENAME, "Filter", DllStructGetPtr($tFilter, 1))

    ; Path job:
    Local $tPath = DllStructCreate("wchar[32767]")
    DllStructSetData($tPath, 1, $sDefaultName)

    DllStructSetData($tOPENFILENAME, "File", DllStructGetPtr($tPath))
    DllStructSetData($tOPENFILENAME, "MaxFile", 32767)

    ; Title job:
    Local $tTitle = DllStructCreate("wchar[" & StringLen($sTitle) + 1 & "]")
    DllStructSetData($tTitle, 1, $sTitle)

    DllStructSetData($tOPENFILENAME, "Title", DllStructGetPtr($tTitle))

    ; Initial dir job:
    Local $tInitDir = DllStructCreate("wchar[" & StringLen($sInitDir) + 1 & "]")
    DllStructSetData($tInitDir, 1, $sInitDir)

    DllStructSetData($tOPENFILENAME, "InitialDir", DllStructGetPtr($tInitDir))

    ; Call the function
    DllCall("msvfw32.dll", "int", "GetOpenFileNamePreviewW", "ptr", DllStructGetPtr($tOPENFILENAME))

    ; Get wanted string
    Local $sOut = DllStructGetData(DllStructCreate("wchar[32767]", DllStructGetData($tOPENFILENAME, "File")), 1)

    Return SetError($sOut = False, 0, $sOut)

EndFunc   ;==>_FileOpenDialogWithPreview

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites



Thanks, once i've searched for such dialog. Very usefull!


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

It's FileOpenDialog with preview :).

Called from msvfw32.dll. Looks like shit IMHO but gives the option to preview media files before selecting one.

All you need to do is browse to some folder with some music or video and you will get an option to preview it.

Like I said, I don't like it but hey it's just me. For example I don't like Robbie Williams, Lady Gaga or F1 races too.

Thanks, nice work!

Script with one example:

Global $sSelected = _FileOpenDialogWithPreview("Open with preview", "", "Music files (*.mp3;*.wav;*.wma)| Video files (*.avi)| All files (*.*)", "")

ConsoleWrite("!@error = " & @error & @CRLF)
ConsoleWrite("Selected: " & $sSelected & @CRLF)





Func _FileOpenDialogWithPreview($sTitle = "Open", $sInitDir = "", $sFilter = "All Files (*.*)", $sDefaultName = "", $hWnd = 0)

    ; OPENFILENAME structure:
    Local $tOPENFILENAME = DllStructCreate("dword StructSize;" & _
            "hwnd Owner;" & _
            "ptr Instance;" & _
            "ptr Filter;" & _
            "ptr  CustomFilter;" & _
            "dword MaxCustFilter;" & _
            "dword FilterIndex;" & _
            "ptr File;" & _
            "dword MaxFile;" & _
            "ptr FileTitle;" & _
            "dword MaxFileTitle;" & _
            "ptr InitialDir;" & _
            "ptr Title;" & _
            "dword Flags;" & _
            "ushort FileOffset;" & _
            "ushort FileExtension;" & _
            "ptr DefExt;" & _
            "ptr CustData;" & _
            "ptr Hook;" & _
            "ptr TemplateName;" & _
            "ptr Reserved;" & _
            "dword SizeReserved;" & _
            "dword FlagsEx")

    ; Set size and owner:
    DllStructSetData($tOPENFILENAME, "StructSize", DllStructGetSize($tOPENFILENAME))
    DllStructSetData($tOPENFILENAME, "Owner", $hWnd)

    ; Filter job:
    Local $tagFilter
    Local $aArray = StringRegExp($sFilter & "|", "\s*(.*?)\s*\((.*?)\)\|", 3)

    For $i = 0 To UBound($aArray) - 1
        $tagFilter &= "wchar[" & StringLen($aArray[$i]) + 1 & "];"
    Next

    $tagFilter &= "wchar"

    Local $tFilter = DllStructCreate($tagFilter)
    For $i = 0 To UBound($aArray) - 1
        DllStructSetData($tFilter, $i + 1, $aArray[$i])
    Next

    DllStructSetData($tOPENFILENAME, "Filter", DllStructGetPtr($tFilter, 1))

    ; Path job:
    Local $tPath = DllStructCreate("wchar[32767]")
    DllStructSetData($tPath, 1, $sDefaultName)

    DllStructSetData($tOPENFILENAME, "File", DllStructGetPtr($tPath))
    DllStructSetData($tOPENFILENAME, "MaxFile", 32767)

    ; Title job:
    Local $tTitle = DllStructCreate("wchar[" & StringLen($sTitle) + 1 & "]")
    DllStructSetData($tTitle, 1, $sTitle)

    DllStructSetData($tOPENFILENAME, "Title", DllStructGetPtr($tTitle))

    ; Initial dir job:
    Local $tInitDir = DllStructCreate("wchar[" & StringLen($sInitDir) + 1 & "]")
    DllStructSetData($tInitDir, 1, $sInitDir)

    DllStructSetData($tOPENFILENAME, "InitialDir", DllStructGetPtr($tInitDir))

    ; Call the function
    DllCall("msvfw32.dll", "int", "GetOpenFileNamePreviewW", "ptr", DllStructGetPtr($tOPENFILENAME))

    ; Get wanted string
    Local $sOut = DllStructGetData(DllStructCreate("wchar[32767]", DllStructGetData($tOPENFILENAME, "File")), 1)

    Return SetError($sOut = False, 0, $sOut)

EndFunc   ;==>_FileOpenDialogWithPreview

Share this post


Link to post
Share on other sites

Amazing, I can't remember ever seeing that dialog before. Looks like shit thou and doesn't work any good with modern video formats.

Also I like Robbie Williams and Lady Gaga.... Well a few of their songs anyway. And a F1 race every once in a while.

Share this post


Link to post
Share on other sites

Amazing, I can't remember ever seeing that dialog before. Looks like shit thou and doesn't work any good with modern video formats.

Also I like Robbie Williams and Lady Gaga.... Well a few of their songs anyway. And a F1 race every once in a while.

I don't like Lady Gaga at all, but I have to say the South Park version is a lot better :)

http://kotaku.com/5392643/lady-gagas-poker-face-comes-to-rock-band-+-in-south-park

Share this post


Link to post
Share on other sites

It definitely looks 80's but might come in handy.

Was I supposed to get an actual preview of the file? (I only got a preview of the list of files)

Thanks!

Share this post


Link to post
Share on other sites

It definitely looks 80's but might come in handy.

Was I supposed to get an actual preview of the file? (I only got a preview of the list of files)

Thanks!

Click once (not twice) on one of those files to select it and you'll get player controls below 'Cancel'.

♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

Ahh, thanks for the explanation. I was trying "All Files" to preview images.

Do you happen to know how to get the Image Preview dialog?

BTW, this would be great with a facelift. I've yet to find a "File..." dialog written it AutoIt, although there have been some great examples of customizing the Win dialogs. I'm hoping somebody proves me wrong.

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