User Tools

Site Tools


saving_20previous_20load_20and_20save_20paths

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

saving_20previous_20load_20and_20save_20paths [2018/03/31 13:19]
127.0.0.1 external edit
saving_20previous_20load_20and_20save_20paths [2018/04/17 18:35] (current)
tbest3112 Added syntax highlighting
Line 2: Line 2:
  
 **Please see the [[http://​bb4w.wikispaces.com/​message/​list/​Saving+previous+load+and+save+paths|discussion]] page**\\ \\  It is often useful if a program remembers where a file was last loaded from or saved to so that the next time a file open or file save dialogue is used it opens on the same directory as last time. Repeated calls of **SYS "​GetOpenFileName"​** re-open on the same directory as last time (unless overridden). However, that is a system-wide setting, not a program setting, and your program may have different dialogues that should start from different directories. The following code saves the loaded or saved filename in the registry so that next time it opens on the same directory again. The Save dialogue also pre-fills the filename with the last used filename.\\ ​ **Please see the [[http://​bb4w.wikispaces.com/​message/​list/​Saving+previous+load+and+save+paths|discussion]] page**\\ \\  It is often useful if a program remembers where a file was last loaded from or saved to so that the next time a file open or file save dialogue is used it opens on the same directory as last time. Repeated calls of **SYS "​GetOpenFileName"​** re-open on the same directory as last time (unless overridden). However, that is a system-wide setting, not a program setting, and your program may have different dialogues that should start from different directories. The following code saves the loaded or saved filename in the registry so that next time it opens on the same directory again. The Save dialogue also pre-fills the filename with the last used filename.\\ ​
 +<code bb4w>
         DEF FNFile_Open         DEF FNFile_Open
         ft$="​Select file to load"​+CHR$0         ft$="​Select file to load"​+CHR$0
Line 35: Line 36:
         IF result%:​ff$=$$fp{}:​PROCReg_Wr(KeyRoot$+"​LastSave",​ff$):​=ff$         IF result%:​ff$=$$fp{}:​PROCReg_Wr(KeyRoot$+"​LastSave",​ff$):​=ff$
         =""​         =""​
 +</​code>​
 They are called with, for example, **in$=FNFile_Open:​out$=FNFile_Save**. They need the usual file open dialogue structure set up with:​\\ ​ They are called with, for example, **in$=FNFile_Open:​out$=FNFile_Save**. They need the usual file open dialogue structure set up with:​\\ ​
 +<code bb4w>
         DIM fs{lStructSize%,​ hwndOwner%, hInstance%, lpstrFilter%,​ \         DIM fs{lStructSize%,​ hwndOwner%, hInstance%, lpstrFilter%,​ \
         \      lpstrCustomFilter%,​ nMaxCustFilter%,​ nFilterIndex%,​ \         \      lpstrCustomFilter%,​ nMaxCustFilter%,​ nFilterIndex%,​ \
Line 43: Line 46:
         \      lpstrDefExt%,​ lCustData%, lpfnHook%, lpTemplateName%}         \      lpstrDefExt%,​ lCustData%, lpfnHook%, lpTemplateName%}
         DIM fp{t&​(260)}         DIM fp{t&​(260)}
 +</​code>​
 The registry calls need **KeyRoot$** set to your program'​s registry branch which must be of the form:​\\ ​ The registry calls need **KeyRoot$** set to your program'​s registry branch which must be of the form:​\\ ​
 +<code bb4w>
         KeyRoot$="​Software\MySoftwareHouse\MyApplicationName\"​         KeyRoot$="​Software\MySoftwareHouse\MyApplicationName\"​
 +</​code>​
 See [[/​Simple%20Registry%20Usage|Simple Registry Usage]] for the **Reg_Rd()** and **Reg_Wr()** routines. See [[/​Simple%20Registry%20Usage|Simple Registry Usage]] for the **Reg_Rd()** and **Reg_Wr()** routines.
saving_20previous_20load_20and_20save_20paths.txt ยท Last modified: 2018/04/17 18:35 by tbest3112