Help , any idea for dialog Open with image preview
Help , any idea for dialog Open with image preview
Hi, can anybody idea use Open dialog under WinXP in PB
I will open dialog with image preview not with file view.
Dialog same do this, but i must change this over menu or button.
Are any parameter to send from PB to dialog and change this over code in PB ?
Thanks for investigation
Richard
I will open dialog with image preview not with file view.
Dialog same do this, but i must change this over menu or button.
Are any parameter to send from PB to dialog and change this over code in PB ?
Thanks for investigation
Richard
Hi rims, Welcome to Purebasic! 
I fudged around with some old code I had laying around and here's what I came up with. I hope this is what you were looking for. It uses some Win API and does NOT use the native OpenFileRequester. Tested and working on WinXP with PB 3.94.

I fudged around with some old code I had laying around and here's what I came up with. I hope this is what you were looking for. It uses some Win API and does NOT use the native OpenFileRequester. Tested and working on WinXP with PB 3.94.
Code: Select all
;--> **********************************
;--> Code: Custom OpenFileRequester
;--> Author: Sparkie
;--> Date: November 15, 2005
;--> **********************************
#CDN_FOLDERCHANGE = -603
#OFN_ENABLESIZING = $800000
#FCIDM_SHVIEW_LARGEICON = $7029
#FCIDM_SHVIEW_SMALLICON = $702A
#FCIDM_SHVIEW_LIST = $702B
#FCIDM_SHVIEW_REPORT = $702C
#FCIDM_SHVIEW_THUMBNAIL = $702D
#FCIDM_SHVIEW_TILE = $702E
Enumeration
#Window_0
EndEnumeration
Enumeration
#Menu_Main
EndEnumeration
Enumeration
#Text_0
#Menu_Thumb
#Menu_Report
#Menu_List
#Menu_Small
#Menu_Large
#Menu_Tile
#Menu_Exit
EndEnumeration
Global openUsing
Procedure OF_HookFunc(hDlg, msg, wparam, lparam)
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lparam
Select *pnmhdr\code
Case #CDN_FOLDERCHANGE
;--> Set our view choice here
hLV = FindWindowEx_(GetParent_(hDlg), 0, "SHELLDLL_DefView", #Null)
SendMessage_(hLV, #WM_COMMAND, openUsing, 0)
EndSelect
EndSelect
EndProcedure
;--> Title for Open dialog
OF_title$ = "Choose Images to View"
;--> Filter for file types to open
OF_filters$ = "bmp, jpg, jpeg|*.bmp;*.jpg;*.jpeg||"
;--> Thank you to Hi-Toro for his post
;--> http://purebasic.myforums.net/viewtopic.php?t=3173&highlight=lpstrFilter
;--> For filter to function properly, we need
;--> to replace | with null Chr0) directly in memory
*filter = AllocateMemory(Len(OF_filters$))
For i = 0 To Len(OF_filters$) - 1
n$ = Mid(OF_filters$, i + 1, 1)
If n$ = "|"
n$ = Chr (0)
EndIf
PokeB(*filter + i, Asc(n$))
Next
;--> Fill in our OPENFILENAME structure
OF_dir$ = "c:\"
OF_file$ = ""
*selectedFile = AllocateMemory(1024 * #MAX_PATH)
myOpenDlg.OPENFILENAME
myOpenDlg\lStructSize = SizeOf(OPENFILENAME)
myOpenDlg\hInstance = #Null
myOpenDlg\lpstrFilter = *filter
myOpenDlg\lpstrCustomFilter = #Null
myOpenDlg\nMaxCustFilter=#Null
myOpenDlg\nFilterIndex=0
myOpenDlg\lpstrFile = *selectedFile
myOpenDlg\nMaxFile = 1024 * #MAX_PATH
myOpenDlg\lpstrFileTitle = #Null
myOpenDlg\nMaxFileTitle = #Null
myOpenDlg\lpstrInitialDir= @OF_dir$
myOpenDlg\lpstrTitle = @OF_title$
myOpenDlg\Flags = #OFN_ENABLESIZING | #OFN_ALLOWMULTISELECT | #OFN_EXPLORER | #OFN_HIDEREADONLY | #OFN_ENABLEHOOK
myOpenDlg\lpfnHook=@OF_HookFunc()
If OpenWindow(#Window_0, 0, 0, 500, 300, #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar, "Customized File Open") And CreateGadgetList(WindowID())
myOpenDlg\hwndOwner = WindowID()
TextGadget(#Text_0, 10, 100, 280, 50, "No file has been selected")
CreateMenu(#Menu_Main, WindowID())
MenuTitle("&File")
OpenSubMenu("&Open using...")
MenuItem(#Menu_Thumb, "Thumbnails")
MenuItem(#Menu_Report, "Report")
MenuItem(#Menu_List, "List")
MenuItem(#Menu_Small, "Small Icons")
MenuItem(#Menu_Large, "Large Icons")
MenuItem(#Menu_Tile, "Tiles")
CloseSubMenu()
MenuBar()
MenuItem(#Menu_Exit, "E&xit")
quit = #False
Repeat
event = WaitWindowEvent()
Select event
Case #PB_EventMenu
MenuID = EventMenuID()
openUsing = 0
Select MenuID
Case #Menu_Thumb
openUsing = #FCIDM_SHVIEW_THUMBNAIL
Case #Menu_Report
openUsing = #FCIDM_SHVIEW_REPORT
Case #Menu_List
openUsing = #FCIDM_SHVIEW_LIST
Case #Menu_Small
openUsing = #FCIDM_SHVIEW_SMALLICON
Case #Menu_Large
openUsing = #FCIDM_SHVIEW_LARGEICON
Case #Menu_Tile
openUsing = #FCIDM_SHVIEW_TILE
Case #Menu_Exit
quit = #True
EndSelect
If openUsing
If GetOpenFileName_(@myOpenDlg) <> 0
SetGadgetText(#Text_0, "You selected.... " + PeekS(*selectedFile))
Else
SetGadgetText(#Text_0, "No file has been selected")
EndIf
EndIf
Case #PB_EventCloseWindow
quit = #True
EndSelect
Until quit
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
What happens when you run this code Trond?
http://www.purebasic.fr/english/viewtop ... 878#133878
http://www.purebasic.fr/english/viewtop ... 878#133878
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
@Trond: I will have more time to look at this when I get home tonight. For now, see if this works any better.
Code: Select all
;\**********************************
;\Code: Custom OpenFileRequester
;\Author: Sparkie
;\Date: November 15, 2005 REV: May 1, 2006
;\ Add PlacesBar and attempt to fix Win2k bug
;\**********************************
;...Need to add the following members to OPENFILENAME structure for adding PlacesBar
Structure OFEX Extends OPENFILENAME
pvReserved.l
dwReserved.l
FlagsEx.l
EndStructure
#CDN_FOLDERCHANGE = -603
#OFN_ENABLESIZING = $800000
#OFN_EX_NOPLACESBAR = 1
#FCIDM_SHVIEW_LARGEICON = $7029
#FCIDM_SHVIEW_SMALLICON = $702A
#FCIDM_SHVIEW_LIST = $702B
#FCIDM_SHVIEW_REPORT = $702C
#FCIDM_SHVIEW_THUMBNAIL = $702D
#FCIDM_SHVIEW_TILE = $702E
Enumeration
#Window_0
EndEnumeration
Enumeration
#Menu_Main
EndEnumeration
Enumeration
#Text_0
#Menu_Thumb
#Menu_Report
#Menu_List
#Menu_Small
#Menu_Large
#Menu_Tile
#Menu_Exit
EndEnumeration
Global openUsing
Procedure OF_HookFunc(hDlg, msg, wParam, lParam)
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
Select *pnmhdr\code
Case #CDN_FOLDERCHANGE
;...Set our view choice here
hLV = FindWindowEx_(GetParent_(hDlg), 0, "SHELLDLL_DefView", #Null)
SendMessage_(hLV, #WM_COMMAND, openUsing, 0)
EndSelect
EndSelect
EndProcedure
;...Title for Open dialog
OF_title$ = "Choose Images to View"
;...Filter for file types to open
OF_filters$ = "bmp, jpg, jpeg|*.bmp;*.jpg;*.jpeg||"
;...Thank you to Hi-Toro for his post
;...http://purebasic.myforums.net/viewtopic.php?t=3173&highlight=lpstrFilter
;...For filter to function properly, we need
;...to replace | with null Chr0) directly in memory
*filter = AllocateMemory(Len(OF_filters$))
For i = 0 To Len(OF_filters$) - 1
n$ = Mid(OF_filters$, i + 1, 1)
If n$ = "|"
n$ = Chr (0)
EndIf
PokeB(*filter + i, Asc(n$))
Next
;...Fill in our OPENFILENAME structure
OF_dir$ = "c:\"
OF_file$ = ""
*selectedFile = AllocateMemory(1024 * #MAX_PATH)
myOpenDlg.OFEX
myOpenDlg\lStructSize = SizeOf(OFEX)
myOpenDlg\hInstance = #Null
myOpenDlg\lpstrFilter = *filter
myOpenDlg\lpstrCustomFilter = #Null
myOpenDlg\nMaxCustFilter=#Null
myOpenDlg\nFilterIndex=0
myOpenDlg\lpstrFile = *selectedFile
myOpenDlg\nMaxFile = 1024 * #MAX_PATH
myOpenDlg\lpstrFileTitle = #Null
myOpenDlg\nMaxFileTitle = #Null
myOpenDlg\lpstrInitialDir= @OF_dir$
myOpenDlg\lpstrTitle = @OF_title$
myOpenDlg\Flags = #OFN_ENABLESIZING | #OFN_ALLOWMULTISELECT | #OFN_EXPLORER | #OFN_HIDEREADONLY | #OFN_ENABLEHOOK
;...Set the following to #OFN_EX_NOPLACESBAR to remove PlacesBar
myOpenDlg\FlagsEx = 0
myOpenDlg\lpfnHook=@OF_HookFunc()
If OpenWindow(#Window_0, 0, 0, 500, 300, "Customized File Open", #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar) And CreateGadgetList(WindowID(#Window_0))
myOpenDlg\hwndOwner = WindowID(#Window_0)
TextGadget(#Text_0, 10, 100, 280, 50, "No file has been selected")
CreateMenu(#Menu_Main, WindowID(#Window_0))
MenuTitle("&File")
OpenSubMenu("&Open using...")
MenuItem(#Menu_Thumb, "Thumbnails")
MenuItem(#Menu_Report, "Report")
MenuItem(#Menu_List, "List")
MenuItem(#Menu_Small, "Small Icons")
MenuItem(#Menu_Large, "Large Icons")
MenuItem(#Menu_Tile, "Tiles")
CloseSubMenu()
MenuBar()
MenuItem(#Menu_Exit, "E&xit")
quit = #False
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Menu
MenuID = EventMenu()
openUsing = 0
Select MenuID
Case #Menu_Thumb
If openUsing = #FCIDM_SHVIEW_THUMBNAIL And OSVersion() = #PB_OS_Windows_2000
openUsing = #FCIDM_SHVIEW_THUMBNAIL + 4
Else
openUsing = #FCIDM_SHVIEW_THUMBNAIL
EndIf
Case #Menu_Report
openUsing = #FCIDM_SHVIEW_REPORT
Case #Menu_List
openUsing = #FCIDM_SHVIEW_LIST
Case #Menu_Small
openUsing = #FCIDM_SHVIEW_SMALLICON
Case #Menu_Large
openUsing = #FCIDM_SHVIEW_LARGEICON
Case #Menu_Tile
openUsing = #FCIDM_SHVIEW_TILE
Case #Menu_Exit
quit = #True
EndSelect
If openUsing
If GetOpenFileName_(@myOpenDlg) <> 0
SetGadgetText(#Text_0, "You selected.... " + PeekS(*selectedFile))
Else
SetGadgetText(#Text_0, "No file has been selected")
EndIf
EndIf
Case #PB_Event_CloseWindow
quit = #True
EndSelect
Until quit
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
Thank you for helping me. Your new code shows thumbnails when I replace the thumbnail constant with $7031. I still gives a script error in my pictures, but it shows the places bar.
Another thing I noticed is that if the user changes view mode and then changes folder, his change in view mode is not preserved, but this is not really important as long as it works inside my pictures.
Another thing I noticed is that if the user changes view mode and then changes folder, his change in view mode is not preserved, but this is not really important as long as it works inside my pictures.