November 25, 2020, 04:53:11 AM

Author Topic: [bmx] Search Tool by JoshK [ 1+ years ago ]  (Read 643 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bmx] Search Tool by JoshK [ 1+ years ago ]
« on: June 29, 2017, 12:28:42 AM »
Title : Search Tool
Author : JoshK
Posted : 1+ years ago

Description : Windows search tool that actually works

Code :
Code: BlitzMax
  1. Framework maxgui.drivers
  2. Import brl.eventqueue
  3. Import "search.bmx"
  4. Import "PathEdit.bmx"
  5.  
  6. AppTitle="Search Tool"
  7.  
  8. Global window:TGadget=CreateWindow(AppTitle,0,0,600,400,,WINDOW_TITLEBAR|WINDOW_STATUS|WINDOW_RESIZABLE|WINDOW_CENTER)
  9.  
  10. Local panel:TGadget=CreatePanel(0,0,182,400,window)
  11. SetGadgetLayout panel,1,0,1,0
  12.  
  13. Local x:Int=2
  14. Local y:Int=2
  15.  
  16. Global Gadget_Token:TGadget
  17. Global Gadget_Folder:TGadget
  18. Global Gadget_Extensions:TGadget
  19. Global Gadget_Search:TGadget
  20. Global Gadget_Results:TGadget
  21. Global Gadget_Recursive:TGadget
  22. Global Gadget_Contents:TGadget
  23. Global Gadget_CaseSensitive:TGadget
  24.  
  25. CreateLabel("Search for:",x,y,120,16,panel)
  26. y:+16
  27. Gadget_Token=CreateTextField(x,y,180,18,panel)
  28. y:+22
  29. ActivateGadget Gadget_Token
  30.  
  31. CreateLabel("File extensions:",x,y,180,16,panel)
  32. y:+16
  33. Gadget_Extensions=CreateTextField(x,y,180,18,panel)
  34. y:+22
  35.  
  36. CreateLabel("In folder:",x,y,180,16,panel)
  37. y:+16
  38. Gadget_Folder=CreatePathEdit(x,y,180,18,panel,PATHEDIT_DIR|PATHEDIT_READONLY)
  39.  
  40. y:+22
  41. Gadget_Recursive=CreateButton("Search subfolders",x,y,180,18,panel,BUTTON_CHECKBOX)
  42. SetButtonState Gadget_Recursive,1
  43.  
  44. y:+22
  45. Gadget_Contents=CreateButton("Search file contents",x,y,180,18,panel,BUTTON_CHECKBOX)
  46.  
  47. y:+22
  48. Gadget_CaseSensitive=CreateButton("Case-sensitive",x,y,180,18,panel,BUTTON_CHECKBOX)
  49.  
  50. y:+22
  51. Gadget_Search=CreateButton("Search",x,y,180,26,panel,BUTTON_OK)
  52.  
  53. y=2
  54. Gadget_Results=CreateListBox(x+180,y,window.ClientWidth()-x-(x+180),window.ClientHeight()-2*y,window)
  55. SetGadgetLayout Gadget_Results,1,1,1,1
  56.  
  57. 'SearchFolder:String[](path:String,token:String,extensions:String[]=Null,options:Int=SEARCH_RECURSIVE,results:String[]=Null)
  58.  
  59. Global popupmenu:TGadget=CreateMenu("",0,Null)
  60. CreateMenu("Open file",0,popupmenu)
  61. CreateMenu("Open containing folder",0,popupmenu)
  62.  
  63. Repeat
  64.  
  65.         WaitEvent()
  66.         Select EventID()
  67.         Case EVENT_WINDOWCLOSE
  68.                 End
  69.  
  70.         Case EVENT_MENUACTION
  71.                 Select String(GadgetText(TGadget(EventSource())))
  72.                 Case "Open file"
  73.                         OpenURL String(EventExtra())
  74.                 Case "Open containing folder"
  75.                         OpenURL ExtractDir(String(EventExtra()))
  76.                 EndSelect
  77.                
  78.         Case EVENT_GADGETMENU
  79.                 Select EventSource()
  80.                 Case Gadget_Results
  81.                         PopupWindowMenu window,popupmenu,GadgetItemExtra(Gadget_results,EventData())
  82.                        
  83.                 EndSelect
  84.                
  85.         Case EVENT_GADGETACTION
  86.                 Select EventSource()
  87.  
  88.                 Case Gadget_Results
  89.                         OpenURL String(GadgetItemExtra(Gadget_results,EventData()))
  90.                        
  91.                 Case Gadget_Search
  92.                         Local results:String[]
  93.                         Local path:String
  94.                         Local token:String
  95.                         Local extensions:String[]
  96.                         Local options:Int
  97.                         Local n:Int
  98.                        
  99.                         ClearGadgetItems(Gadget_Results)
  100.                        
  101.                         If ButtonState(Gadget_Recursive) options=options|SEARCH_RECURSIVE
  102.                         If ButtonState(Gadget_Contents) options=options|SEARCH_CONTENTS
  103.                         If ButtonState(Gadget_CaseSensitive) options=options|SEARCH_CASESENSITIVE
  104.                        
  105.                         path=GadgetText(Gadget_Folder)
  106.                        
  107.                         token=GadgetText(Gadget_Token)
  108.                        
  109.                         extensions=GadgetText(Gadget_Extensions).split(",")
  110.                         For n=0 To extensions.length-1
  111.                                 extensions[n]=extensions[n].Trim()
  112.                         Next
  113.                         If extensions.length=1
  114.                                 If extensions[0]="" extensions=Null
  115.                         EndIf
  116.                        
  117.                         SetStatusText window,"Searching..."
  118.                         results=SearchFolder(path,token,extensions,options)
  119.                         SetStatusText window,results.length+" files found"
  120.                        
  121.                        
  122.                         For n=0 To results.length-1
  123.                                 AddGadgetItem Gadget_Results,StripDir(results[n]),0,-1,results[n],results[n]
  124.                         Next
  125.                        
  126.                         ActivateGadget Gadget_Results
  127.                        
  128.                 EndSelect
  129.         EndSelect
  130.  
  131. Forever


Comments :


JoshK(Posted 1+ years ago)

 PathEdit.bmx:
Code: [Select]
SuperStrict

Import MaxGui.Drivers
Import brl.retro
Import "FileRequester.bmx"

Rem
Local window:TGadget

window=CreateWindow("pathedit Example",40,40,320,240)

Local label:TGadget
Local pathedit:TPathEdit
Local x:Int=4,y:Int=4

label=CreateLabel("Pick File:",x,y,60,18,window)
SetGadgetLayout label,1,0,1,0
pathedit=CreatePathEdit(x+60,y,200,20,window,PATHEDIT_FILE|PATHEDIT_STRIPDIR|PATHEDIT_CHOICES)
SetGadgetLayout pathedit,1,1,1,0


While True
WaitEvent
Print CurrentEvent.ToString()
Select EventID()
Case EVENT_WINDOWCLOSE
End
End Select
Wend
EndRem

'-------------------------------------------------------------------

Const PATHEDIT_FILE:Int=0
Const PATHEDIT_DIR:Int=1
Const PATHEDIT_STRIPDIR:Int=2
Const PATHEDIT_CHOICES:Int=4
Const PATHEDIT_READONLY:Int=8

Type TPathEdit Extends TProxygadget

Field panel:TGadget
Field textfield:TGadget
Field button:TGadget
Field style:Int
Field extensions:String="All Files:*"
Field value:String
Field choices:TMap
Field folder:String

Method Cleanup()
RemoveHook(EmitEventHook,EventHook,Self)
Super.cleanup()
EndMethod

Method InsertItem:Int(index%,text$,tip$,icon%,extra:Object,flags%)
Return textfield.InsertItem(index,text,tip,icon,extra,flags)
EndMethod

Method GetText$()
Return textfield.GetText()
EndMethod

Method SetText:Int(text$)
If PATHEDIT_CHOICES & style
If Not choices
choices=New TMap
EndIf
If Not choices.valueforkey(text)
choices.insert(text,text)
ClearGadgetItems(textfield)
For Local key:String=EachIn choices.keys()
AddGadgetItem(textfield,key)
Next
EndIf
EndIf
value=text
Return textfield.SetText(text)
EndMethod

Method SetTextColor(r:Int,g:Int,b:Int)
Local gadget:TGadget
Super.SetTextColor(r,g,b)
textfield.SetTextColor(r,g,b)
button.SetTextColor(r,g,b)
EndMethod

Method SetColor(r:Int,g:Int,b:Int)
Local gadget:TGadget
Super.SetColor(r,g,b)
textfield.SetColor(r,g,b)
button.SetColor(r,g,b)
EndMethod

Function Create:TPathEdit(x:Int,y:Int,width:Int,height:Int,group:TGadget,style:Int=0)
Local pathedit:TPathEdit

pathedit=New TPathEdit

pathedit.panel=CreatePanel(x,y,width,height,group)

If PATHEDIT_CHOICES & style
If PATHEDIT_READONLY & style
pathedit.textfield=CreateComboBox(0,0,pathedit.panel.ClientWidth()-pathedit.panel.ClientHeight(),pathedit.panel.ClientHeight(),pathedit.panel)
Else
pathedit.textfield=CreateComboBox(0,0,pathedit.panel.ClientWidth()-pathedit.panel.ClientHeight(),pathedit.panel.ClientHeight(),pathedit.panel,COMBOBOX_EDITABLE)
EndIf
?win32
SendMessageA(QueryGadget(pathedit.textfield,QUERY_HWND),CB_SETITEMHEIGHT,-1,height);
?
Else
pathedit.textfield=CreateTextField(0,0,pathedit.panel.ClientWidth()-pathedit.panel.ClientHeight(),pathedit.panel.ClientHeight(),pathedit.panel)
EndIf

SetGadgetLayout pathedit.textfield,1,1,1,1

pathedit.style=style

pathedit.button=CreateButton("...",pathedit.panel.ClientWidth()-pathedit.panel.ClientHeight(),0,pathedit.panel.ClientHeight(),pathedit.panel.ClientHeight(),pathedit.panel)
SetGadgetLayout pathedit.button,0,1,1,1

pathedit.setproxy(pathedit.panel)
SetGadgetFilter(pathedit.textfield,Filter,pathedit)

AddHook(EmitEventHook,EventHook,pathedit)
Return pathedit
EndFunction

Function Filter:Int(event:TEvent,context:Object)
Local pathedit:TPathEdit=TPathEdit(context)
If PATHEDIT_READONLY & pathedit.style
Return 0
Else
Return 1
EndIf
EndFunction

Function EventHook:Object(id:Int,data:Object,context:Object)
Local event:TEvent
Local pathedit:TPathEdit

event=TEvent(data)
If event
pathedit=TPathEdit(context)
If pathedit
Select event.id
Case EVENT_GADGETLOSTFOCUS
If event.source=pathedit.textfield
Local text$
text=GadgetText(pathedit.textfield)
If text<>pathedit.value
pathedit.value=text
EmitEvent CreateEvent(EVENT_GADGETACTION,pathedit,0,0,0,0,text)
EndIf
Return Null
EndIf
Case EVENT_GADGETACTION
Select event.source
Case pathedit.textfield
'If PATHEDIT_CHOICES And pathedit.style
' Local text:String
' text=GadgetText(pathedit.textfield)
' If text<>pathedit.value
' pathedit.value=text
' EmitEvent CreateEvent(EVENT_GADGETACTION,pathedit,0,0,0,0,text)
' EndIf
'EndIf
Return Null
Case pathedit.button
Local file:String
If PATHEDIT_DIR & pathedit.style
file=RequestDir("Select Folder",GadgetText(pathedit.textfield))
Else
file=GadgetText(pathedit.textfield)
If file=""
If pathedit.folder
file=pathedit.folder+""
EndIf
Else
If PATHEDIT_STRIPDIR & pathedit.style
file=pathedit.folder+""+file
EndIf
EndIf
file=RequestFile("Open File",pathedit.extensions,0,file)
If file
pathedit.folder=ExtractDir(file)
EndIf
If PATHEDIT_STRIPDIR & pathedit.style
file=StripDir(file)
EndIf
EndIf
If file
If file<>pathedit.value
pathedit.value=file
SetGadgetText pathedit,file
EmitEvent CreateEvent(EVENT_GADGETACTION,pathedit,0,0,0,0,file)
EndIf
EndIf
Return Null
EndSelect
EndSelect
EndIf
EndIf
Return data
EndFunction

EndType

Rem
bbdoc:
EndRem
Function CreatePathEdit:TPathEdit(x:Int,y:Int,width:Int,height:Int,group:TGadget,flags:Int=0)
Return Tpathedit.Create(x,y,width,height,group,flags)
EndFunction

Rem
bbdoc:
EndRem
Function SetPathEditExtensions(pathedit:TPathEdit,extensions:String)
pathedit.extensions=extensions
EndFunction



JoshK(Posted 1+ years ago)

 search.bmx:
Code: [Select]
SuperStrict

Import brl.filesystem
'Import brl.standardio

Rem
Local file:String
Local results:String[]

results=SearchFolder(AppDir,"GCStackTop",["bmx"],SEARCH_RECURSIVE|SEARCH_CONTENTS)
If results
Print results.length+" search results found:"
For file=EachIn results
Print file
Next
EndIf
EndRem

Const SEARCH_RECURSIVE:Int=1
Const SEARCH_CONTENTS:Int=2
Const SEARCH_CASESENSITIVE:Int=4

Function SearchFolder:String[](path:String,token:String,extensions:String[]=Null,options:Int=SEARCH_RECURSIVE,results:String[]=Null)
Local dir:String[],ext:String,n:Int,i:Int

If path.Trim()="" path=CurrentDir()

dir=LoadDir(path)
If Not dir Return results

If Not results results=New String[0]

For n=0 To dir.length-1
Select FileType(path+"/"+dir[n])
Case 1
If extensions
ext=ExtractExt(dir[n])
If Not (SEARCH_CASESENSITIVE & options)
ext=ext.tolower()
EndIf
For i=0 To extensions.length-1
If extensions[i]=ext
If SearchFile(path+"/"+dir[n],token,options)
results=results[..results.length+1]
results[results.length-1]=path+"/"+dir[n]
EndIf
Exit
EndIf
Next
Else
If SearchFile(path+"/"+dir[n],token,options)
results=results[..results.length+1]
results[results.length-1]=path+"/"+dir[n]
EndIf
EndIf
Case 2
If (SEARCH_RECURSIVE & options)
results=SearchFolder(path+"/"+dir[n],token,extensions,options,results)
EndIf
'If Not (SEARCH_CONTENTS & options)
If Not extensions
If SearchFile(path+"/"+dir[n],token,options)
results=results[..results.length+1]
results[results.length-1]=path+"/"+dir[n]
EndIf
EndIf
EndSelect
Next
Return results
EndFunction

Function SearchFile:Int(path:String,token:String,options:Int=0)
Local stream:TStream,s:String
Local spath:String

If Not (SEARCH_CASESENSITIVE & options)
token=token.tolower()
EndIf

spath=path
If Not (SEARCH_CASESENSITIVE & options)
spath=spath.tolower()
EndIf
spath=StripAll(spath)
If spath.contains(token) Return True

If (SEARCH_CONTENTS & options)
stream=ReadFile(path)
If Not stream Return False
While Not stream.Eof()
s=stream.ReadLine()
If Not (SEARCH_CASESENSITIVE & options)
s=s.tolower()
EndIf
If s.contains(token)
stream.close()
Return True
EndIf
Wend
stream.close()
'Else
' If Not (SEARCH_CASESENSITIVE & options)
' path=path.tolower()
' EndIf
' path=StripDir(path)
' If path.contains(token) Return True
EndIf
Return False
EndFunction



JoshK(Posted 1+ years ago)

 FileRequester:
Code: [Select]
Strict

Import brl.system
Import brl.standardio
Import pub.win32
Import maxgui.maxgui

Private

Extern "win32"
Function GetOpenFileNameA:Int(of:Byte Ptr)
Function GetSaveFileNameA:Int(of:Byte Ptr)
Function CommDlgExtendedError:Int()
Function GetDlgItem(hDlg:Int,nIDDlgItem:Int)
Function GetParent:Int(hwnd:Int)
Function SetWindowTextA(hwnd:Int,text$z)
EndExtern

Public

'requestfileex("Open file")
'GCCollect()
'End


'--------------------------------------------------
'Examples
'--------------------------------------------------
Rem
'Print RequestFile("Open Sesame","All Files:*;My File Format (*.mff):mff;Windows Bitmap (*.bmp):bmp",0,"c:/")
Print RequestFileEx("Open Sesame","All Files:*;My File Format (*.mff):mff;Windows Bitmap (*.bmp):bmp",1,"c:/",Null,Hook,"&Options")

Function Hook()
Notify "Your stuff goes here."
EndFunction
EndRem
'--------------------------------------------------
'
'--------------------------------------------------


Rem
'=======================================================================
'Original unmolested version used for testing
'=======================================================================
Function RequestFile$(text$,exts$="",save_flag=False,path$="")
Local result
Local of:OPENFILENAME
Local file$,dir$

'Fix path
path=path.Replace( "/","" )
Local i=path.FindLast( "" )
If i<>-1
dir=path[..i]
file=path[i+1..]
Else
file=path
EndIf

'Calculate extension string
Local ext$,defext,p,q
p=path.Find(".")
If (p>-1)
ext=","+path[p+1..].toLower()+","
Local exs$=exts.toLower()
exs=exs.Replace(":",":,")
exs=exs.Replace(";",",;")
p=exs.find(ext)
If p>-1
Local q=-1
defext=1
While True
q=exs.find(";",q+1)
If q>p Exit
If q=-1 defext=0;Exit
defext:+1
Wend
EndIf
EndIf
If exts
If exts.Find(":")=-1
exts="Files~0*."+exts
Else
exts=exts.Replace(":","~0*.")
EndIf
exts=exts.Replace(";","~0")
exts=exts.Replace(",",";*.")+"~0"
EndIf

of=New OPENFILENAME
of.lpstrTitle=text.tocstring()
of.lpstrInitialDir=dir.tocstring()
of.lpstrFilter=exts.tocstring()

'Flags
of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR
If save_flag
of.lpstrDefExt=of.lpstrFilter
of.Flags:|OFN_OVERWRITEPROMPT
Else
of.Flags:|OFN_FILEMUSTEXIST
EndIf

'Return string array
Local lpstrFile:Byte[4096]
of.lpstrFile=lpstrFile
of.nMaxFile=4095

Local cs:Byte Ptr
cs=file.tocstring()
MemCopy lpstrFile,cs,file.length
MemFree cs

If save_flag
result=GetSaveFileNameA(of)
Else
result=GetOpenFileNameA(of)
EndIf

MemFree of.lpstrTitle
MemFree of.lpstrInitialDir
MemFree of.lpstrFilter

If result Return String.FromCString(lpstrFile)
EndFunction
'=======================================================================
'
'=======================================================================
EndRem

'=======================================================================
'Whored out version
'=======================================================================
Function RequestFile$(text$,exts$="",save_flag=False,path$="",owner:TGadget=Null,hook()=Null,helpbuttontext$="Help")
Rem
Local parent:TGadget
Local s:String
parent=owner
While parent
DisableGadget(parent)
parent=GadgetGroup(parent)
Wend
s=RequestFile(text,exts,save_flag,path)
parent=owner
While parent
EnableGadget(parent)
parent=GadgetGroup(parent)
Wend
If owner ActivateGadget(owner)
Return s
EndRem

Local result
Local of:OPENFILENAME
Local file:String,dir:String
Local parent:TGadget

owner=GadgetWindow(ActiveGadget())

parent=owner
If parent
For Local gadget:TGadget=EachIn parent.kids
If GadgetClass(gadget)=GADGET_WINDOW DisableGadget gadget
Next
EndIf
While parent
DisableGadget(parent)
parent=GadgetGroup(parent)
Wend

'Fix path
path=path.Replace( "/","" )
Local i=path.FindLast( "" )
If i<>-1
dir=path[..i]
file=path[i+1..]
Else
file=path
EndIf

'Calculate extension string
Local ext$,defext,p,q
p=path.Find(".")
If (p>-1)
ext=","+path[p+1..].toLower()+","
Local exs$=exts.toLower()
exs=exs.Replace(":",":,")
exs=exs.Replace(";",",;")
p=exs.find(ext)
If p>-1
Local q=-1
defext=1
While True
q=exs.find(";",q+1)
If q>p Exit
If q=-1 defext=0;Exit
defext:+1
Wend
EndIf
EndIf
If exts
If exts.Find(":")=-1
exts="Files~0*."+exts
Else
exts=exts.Replace(":","~0*.")
EndIf
exts=exts.Replace(";","~0")
exts=exts.Replace(",",";*.")+"~0"
EndIf

of=New OPENFILENAME
of.lpstrTitle=text.tocstring()
of.lpstrInitialDir=dir.tocstring()
of.lpstrFilter=exts.tocstring()

If owner
of.hwndowner=QueryGadget(owner,QUERY_HWND)
EndIf

'Flags
of.Flags=OFN_HIDEREADONLY|OFN_NOCHANGEDIR
If save_flag
of.lpstrDefExt=of.lpstrFilter
of.Flags:|OFN_OVERWRITEPROMPT
Else
of.Flags:|OFN_FILEMUSTEXIST
EndIf

'Add hook
If hook
RequestFileHook=hook
RequestFileHelpButtonText=helpbuttontext
of.lpfnHook=lpfnHook
of.Flags:|OFN_EXPLORER|OFN_ENABLEHOOK|OFN_SHOWHELP
EndIf

'Return string array
Local lpstrFile:Byte[4096]
Local cs:Byte Ptr
If file
cs=file.tocstring()
MemCopy lpstrFile,cs,file.length
EndIf

of.lpstrFile=lpstrFile
of.nMaxFile=4095

If save_flag
result=GetSaveFileNameA(of)
Else
result=GetOpenFileNameA(of)
EndIf

If result
file=String.FromCString(lpstrFile)
Else
file=""
EndIf

MemFree cs
MemFree of.lpstrTitle
MemFree of.lpstrInitialDir
MemFree of.lpstrFilter

parent=owner
For Local gadget:TGadget=EachIn parent.kids
If GadgetClass(gadget)=GADGET_WINDOW EnableGadget gadget
Next
While parent
EnableGadget(parent)
parent=GadgetGroup(parent)
Wend
If owner ActivateGadget(owner)

Return file
EndFunction

Private

Function GadgetWindow:TGadget(gadget:TGadget)
While gadget
If GadgetClass(gadget)=GADGET_WINDOW Return gadget
gadget=GadgetGroup(gadget)
Wend
Return Null
EndFunction

Public

'=======================================================================
' ****ing Windows Madness
'=======================================================================

Private

Global RequestFileHook()
Global RequestFileHelpButtonText$

Function lpfnHook:Int(hwnd:Int,uMsg:Int,lp:Int,pData:Byte Ptr) "win32"
Local hdlg:Int
Const CDN_HELP=-605
Select uMsg
Case WM_INITDIALOG
hdlg=GetDlgItem(GetParent(hwnd),$040e)
SetWindowTextA(hdlg,RequestFileHelpButtonText)
Case WM_NOTIFY
If pData<>Null
Local o:OFNOTIFY=New OFNOTIFY
MemCopy Varptr o.hwndFrom,pData,12
If o.code=CDN_HELP
hwnd=GetParent(hwnd)
EnableWindow(hwnd,0)
RequestFileHook()
EnableWindow hwnd,1
SetFocus hwnd
EndIf
EndIf
EndSelect
Return 0
EndFunction

Type NMHDR
Field hwndFrom:Int
Field idFrom:Int
Field code:Int
EndType

Type OFNOTIFY Extends NMHDR
Field lpOFN:Byte Ptr
Field pszFile:Byte Ptr
EndType

Const OFN_READONLY                 =$00000001
Const OFN_OVERWRITEPROMPT          =$00000002
Const OFN_HIDEREADONLY             =$00000004
Const OFN_NOCHANGEDIR              =$00000008
Const OFN_SHOWHELP                 =$00000010
Const OFN_ENABLEHOOK               =$00000020
Const OFN_ENABLETEMPLATE           =$00000040
Const OFN_ENABLETEMPLATEHANDLE     =$00000080
Const OFN_NOVALIDATE               =$00000100
Const OFN_ALLOWMULTISELECT         =$00000200
Const OFN_EXTENSIONDIFFERENT       =$00000400
Const OFN_PATHMUSTEXIST            =$00000800
Const OFN_FILEMUSTEXIST            =$00001000
Const OFN_CREATEPROMPT             =$00002000
Const OFN_SHAREAWARE               =$00004000
Const OFN_NOREADONLYRETURN         =$00008000
Const OFN_NOTESTFILECREATE         =$00010000
Const OFN_NONETWORKBUTTON          =$00020000
Const OFN_NOLONGNAMES              =$00040000
Const OFN_EXPLORER                 =$00080000
Const OFN_NODEREFERENCELINKS       =$00100000
Const OFN_LONGNAMES                =$00200000

Const CDERR_DIALOGFAILURE =$FFFF
Const CDERR_FINDRESFAILURE =$0006
Const CDERR_INITIALIZATION =$0002
Const CDERR_LOADRESFAILURE =$0007
Const CDERR_LOADSTRFAILURE =$0005
Const CDERR_LOCKRESFAILURE =$0008
Const CDERR_MEMALLOCFAILURE =$0009
Const CDERR_MEMLOCKFAILURE =$000A
Const CDERR_NOHINSTANCE =$0004
Const CDERR_NOHOOK =$000B
Const CDERR_NOTEMPLATE =$0003
Const CDERR_REGISTERMSGFAIL =$000C
Const CDERR_STRUCTSIZE =$0001
Const FNERR_BUFFERTOOSMALL =$3003
Const FNERR_INVALIDFILENAME =$3002
Const FNERR_SUBCLASSFAILURE =$3001

Type OPENFILENAME
Field lStructSize:Int=88
Field hwndOwner:Int
Field hInstance:Int=0
Field lpstrFilter:Byte Ptr' File filter
Field lpstrCustomFilter:Byte Ptr
Field nMaxCustFilter:Int=0
Field nFilterIndex:Int=0
Field lpstrFile:Byte Ptr
Field nMaxFile:Int
Field lpstrFileTitle:Byte Ptr'[4096]
Field nMaxFileTitle=4095
Field lpstrInitialDir:Byte Ptr'start directory
Field lpstrTitle:Byte Ptr' Dialog title
Field Flags:Int=0
Field nFileOffset:Short
Field nFileExtension:Short
Field lpstrDefExt:Byte Ptr
Field lCustData:Int
Field lpfnHook:Byte Ptr=Null' Callback function
Field lpTemplateName:Byte Ptr
Field pvReserved:Byte Ptr' not sure if from here on is needed
Field dwReserved:Int
Field FlagsEx:Int
EndType

Public

'C++ stuff:
Rem
typedef struct tagOFN {
  DWORD         lStructSize;
  HWND          hwndOwner;
  HINSTANCE     hInstance;
  LPCTSTR       lpstrFilter;
  LPTSTR        lpstrCustomFilter;
  DWORD         nMaxCustFilter;
  DWORD         nFilterIndex;
  LPTSTR        lpstrFile;
  DWORD         nMaxFile;
  LPTSTR        lpstrFileTitle;
  DWORD         nMaxFileTitle;
  LPCTSTR       lpstrInitialDir;
  LPCTSTR       lpstrTitle;
  DWORD         Flags;
  WORD          nFileOffset;
  WORD          nFileExtension;
  LPCTSTR       lpstrDefExt;
  LPARAM        lCustData;
  LPOFNHOOKPROC lpfnHook;
  LPCTSTR       lpTemplateName;
#If (_WIN32_WINNT >= =$0500)
  void *        pvReserved;
  DWORD         dwReserved;
  DWORD         FlagsEx;
#EndIf ' (_WIN32_WINNT >= =$0500)
} OPENFILENAME, *LPOPENFILENAME;
EndRem


 

SimplePortal 2.3.6 © 2008-2014, SimplePortal