|
Technical answers from the trenches |
|
Trick: Creating Resizeable FileBrowser() Dialogs
| ||||
Posted: 1 April 2002 |
||||
  |
Applies to: Paradox 7.32 and later |
|||
  |
Audience: Experienced |
|||
Question: Is there a way to create resizeable dialogs using FileBrowser() or FileBrowserEx()?Answer: Yes, if you don't mind using an undocumented trick. Consider: method pushButton(var eventInfo Event)
var
fbiXFile FileBrowserInfo ; data for systemSaveAs() function.
loRetval Logical ; Value returned to calling process.
strValue String ; Holds filenames
endVar
; initialize local vars
loRetval = TRUE
strValue = "USERDATA.INI"
fbiXFile.Title = "Open File"
fbiXFile.AllowableTypes = "fbAll"
fbiXFile.Alias = ":WORK:"
fbiXFile.Options = 8388608 ; here's the trick.
; Call the SaveAs wrapper function
loRetval = getFileName( strValue, fbiXFile )
if loRetval then
msgInfo( "FYI", "The user chose to import " +
strValue + "." )
else
msgStop( "File Browser Cancelled", "The user either cancelled " +
"the FileBrowser or an invalid file was selected." )
endIf
endMethodThis works because FileBrowser and FileBrowserEx themselves call standard Windows dialog boxes, which can be controlling using additional constants and flags that are not officially documented by Corel. In turn, this means that you can add some additional functionality by leveraging the work that Microsoft has already invested in these functions. It takes some research and experimentation to pull off, but this investment is usually worth the effort. In this case, we reviewed the Windows SDK documentation for the options supported by the standard function (available here as of this writing). This led us to the OFN_ENABLESIZING constant. You may note, however, that Paradox doesn't officially support this constant, so we had to locate its value using other tools. To do this, we searched the source code files provided with Borland Delphi 5.0 Professional. This revealed the actual value of the OFN_ENABLERESIZING constant (0x00800000) which we converted to a decimal value using the Scientific Calculator provided with Windows itself. If you do not have Borland Delphi or other development tools, you may also be able to discover constant values with a reputable search engine. (For example, consider the results of this search.) Keep in mind, however, that this is undocumented behavior and therefore unsupported by Corel. While we've seen no ill effects using this particular technique in our Paradox applications, it's entirely possible that unexpected behavior may appear in certain circumstances. If you do run into such behvaior, it may be best to use a different approach. For example, you can use Borland Delphi, Visual Basic, or other tools to create a DLL that calls the GetOpenFileName or GetSaveFileName Windows API functions and then refer to that using an ObjectPAL USES block. For more information regarding the capabilities of the Windows GetOpenFilename and GetSaveFileName API functions, please refer to the appropriate Windows SDK documentation. A good resource is Microsoft's own MSDN site. Finally, please note that the above code sample refers to the custom method described in Prompting for Filenames. Related Articles: |
|||
|
||||||||
|
Copyright © 2000-2004, techtricks.com; All Rights Reserved. Acknowledgements, Disclaimers, Terms and Conditions. |
||||||||
|
Article last updated on 31 May 2003
|
||
|
|
||
|
[- End -]
|