Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

GetFileOpenName/GetFileSaveName is causing other stuff to bomb

Posted on 2004-03-22
7
Medium Priority
?
1,543 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 500 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
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 column That will then direct you to their download page. From that p…
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 perform CRUD operations on a MySql database.

604 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