The following is almost EXACTLY what I want to accomplish:
KristopherWindsor wrote:I didn't write this, but I figured it should be in the Tips and Tricks section. ;-)
See also:
-> Run Open File Dialog Box on Load
Tags: kristopherwindsor_program_trickCode: Select all
#define WIN_INCLUDEALL #include once "windows.bi" Function filebrowser (Byref ititle As String, Byref idir As String = Curdir) As String Dim ofn As OPENFILENAME Dim filename As Zstring * (MAX_PATH + 1) Dim title As Zstring * 32 => ititle Dim initialdir As Zstring * 256 => idir With ofn .lStructSize = Sizeof(OPENFILENAME) .hwndOwner = NULL .hInstance = GetModuleHandle(NULL) '"All Files, (*.*)" '"*.*" '"Bas Files, (*.BAS)" '"*.bas" .lpstrFilter = Strptr(!"All Files, (*.*)\0*.*\0Bas Files, (*.BAS)\0*.bas\0\0") .lpstrCustomFilter = NULL .nMaxCustFilter = 0 .nFilterIndex = 1 .lpstrFile = @filename .nMaxFile = Sizeof(filename) .lpstrFileTitle = NULL .nMaxFileTitle = 0 .lpstrInitialDir = @initialdir .lpstrTitle = @title .Flags = OFN_EXPLORER Or OFN_FILEMUSTEXIST Or OFN_PATHMUSTEXIST .nFileOffset = 0 .nFileExtension = 0 .lpstrDefExt = NULL .lCustData = 0 .lpfnHook = NULL .lpTemplateName = NULL End With If (GetOpenFileName(@ofn) = FALSE) Then Return "" Return filename End Function Print filebrowser("Find a source code file...", "C:\Program Files") Sleep
That is beautiful!.
That routine is a few lines -- awesome.
My QB method (several hundred lines) reads the directory(& parent/child directories) & file names; requests a user response (changing directory as needed) and eventually the user selects the required file.
Is there a way to make the above FB code an object file and link it to a QB program?
That is:
When compiling a QB program (with #lang 'qb') this routine is rejected.
If it is compiled to an object file how can it linked to the QB module?
I realize that I could experiment and try several dozen different approaches and eventually get something meaningful (that is, either it can't be done or it can be).
I have not linked any object modules ( C, Pascal, FORTRAN, C++, etc) so I am a bit ignorant as to how it can be done.
Any information appreciated.
Thanks.