Solved

GetFileOpenName/GetFileSaveName is causing other stuff to bomb

Posted on 2004-03-22
7
1,523 Views
Last Modified: 2013-12-26
I need to use either the GetFileOpenName or GetFileSaveName to allow the user to browse to a specific file that they want to link to document.  (If there are any other ways to opening a windows file browser, please let me know.)  Anyway, it works fine, but after I browse and find the file, it causes other unrelated things to bomb.  For instance, the application is no longer able to retrieve data from my profile (.INI file)...and then icons in the treeview start disappearing.  It's almost like the GetFileOpenName/GetFileSaveName functions affected the memory or something...like the memory needs to be freed or something.  But I can't find anywhere that tells me I need to do that...

Does anyone have any insight to shed on this issue?  Thanks!
0
Comment
Question by:aznevon
7 Comments
 
LVL 22

Expert Comment

by:cookre
ID: 10654118
Presuming this is PowerBuilder, you may get better results posting in the PowerBuilder area:
http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/
0
 
LVL 23

Expert Comment

by:chensu
ID: 10654452
Have you specified the OFN_NOCHANGEDIR flag?
0
 
LVL 5

Accepted Solution

by:
berXpert earned 125 total points
ID: 10658334
Hi,

GetFileOpenName & GetFileSaveName actually change your working path, your icons need to be on that path to show in your application, so when you change your path they disappear.

To solve this you can include your icons and bmp's in your Resource file (.PBR file) so when you build your EXE you allways have them in memory.

BerX
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:Vikas_Dixit
ID: 10658711
Hi,

Here's the code that I used n One of my Apps for making sure my app picks up the ini form the correct path:

External functions:
Function ulong GetModuleFileName (ulong hinstModule, ref string lpszPath, ulong cchPath ) Library "KERNEL32.DLL" Alias for "GetModuleFileNameA"
Function ulong GetCurrentDirectory (ulong nBufferLength, ref string lpBuffer) Library "KERNEL32.DLL" Alias for "GetCurrentDirectoryA"

//If running from PB (development mode), Then INI file is in current dir,
//else it is in the same dir as the app exe.
if Handle(GetApplication()) <=0 then
      ls_modulepath = space(128)
      GetCurrentDirectory(128,ls_modulepath)
else
      ls_ModulePath = space(128)
      GetModuleFileName(Handle(loccount),ls_ModulePath ,128)
      ll_lastPos = lnv_string.of_lastpos(ls_ModulePath, "\")
      ls_modulepath = Left(ls_ModulePath, ll_lastPos -1)
end if

ls_IniPath = ls_modulepath +"\UtilDBquery.ini"

Other Options may be setting the path of the ini as an environemtn variable.

For Bitmaps, BerX's solution is prefrable.. another option may be to Overide the functions GetFileOpenName and GetFileSaveName, to chenge the current dir back to what was earlier:

Function boolean SetCurrentDirectory (ref string lpPathName) Library "KERNEL32.DLL" Alias for "SetCurrentDirectoryA"

function f_GetFileOpenName :

ls_CurrentDir = space(128)
GetCurrentDirectory(128,ls_CurrentDir)
GetFileOpenName (.......)
SetCurrentDirectory(ls_CurrentDir)

Regards,
Vikas D

0
 

Author Comment

by:aznevon
ID: 10658767
I knew what I had to do after reading berXpert's solution...I did the following:

ls_exe_dir = GetCurrentDirectory ()
GetFileSaveName("Browse to Document", ls_filepath, ls_filename, "", "All Files (*.*),*.*", ls_filedefault)
ChangeDirectory (ls_exe_dir)

And it works fine...

Thanks...
0
 
LVL 23

Expert Comment

by:chensu
ID: 10659808
You don't have to call GetCurrentDirectory() and ChangeDirectory(). As I said above, the OFN_NOCHANGEDIR flag does that for you automatically.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
netbeans not showing web project 3 91
What xml editor to use. 8 101
Java Help 2 89
Eclipse IDE - Cannot copy/paste from console output 8 306
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question