|
I've finally found out what's wrong!! i need to put the file at the same folder as i specify the m_binfile in order to open the text file in OnLoad. But, now the question is, how can i specify the location if i were to open the file in a predetermine location?
Anyway, thanks everybody...u all are gifts from heaven
|
|
|
|
|
cyn8 wrote: i need to put the file at the same folder as i specify the m_binfile in order to open the text file in OnLoad.
In other words, you need to use an absolute path instead of a relative path.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Doh!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Besides the potential memory problems that DavidCrow has mentioned...
I'm trying to narrow it down without being able to debug your code
Try this, replacing "c:\\path\\abc.txt" with a fully qualified pathname (drive letter/path/filename)
that you are absolutely sure exists.
The open should succeed. If it still only succeeds when you don't use the fileopen dialog then
you are trashing memory somewhere and you need to fix that code. If it succeeds always then
you have a pathname problem in OnLoad().
void CICTesterDlg::OnLoad()
{
UpdateData();
CString file;
file="c:\\path\\abc.txt";
std::ifstream outputdata;
outputdata.open(file), ios::in);
if ( !outputdata.is_open() )
{
MessageBox(_T("Unable to open file!"),_T("WARNING"),MB_ICONEXCLAMATION);
return;
}
outputdata.close();
}
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery wrote: That's something you'll have to check in the debugger.
Debugging is a lost art, Mark.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
cyn8 wrote: actually i modify the code pasted here as the original code is too long.
So how are we supposed to help if the code snippet does not match what you are referring to?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I didn't change the OnBrowse function,but only simplify the OnLoad function. So the scenario should be the same.
|
|
|
|
|
cyn8 wrote: CString ext=m_binfile.Right(3);
This is assuming the rightmost 3 characters are the extension. What if they are not? Use PathFindExtension() instead.
cyn8 wrote: binfile=binfile.Mid(binfile.ReverseFind('\\')+1);
Use PathFindFileName() here.
cyn8 wrote: file[0]=0;
Unnecessary initialization.
cyn8 wrote: When i debug, i found out that under outputdata>_Fb>_Str, _Str value is 0x00000000 {???}.
When, and where? What value should it have?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
By using PathFindExtension() and PathFindFileName(), the error"error C2039: 'PathFindExtension' : is not a member of 'CString'" is generated.
And "When, and where? What value should it have? "
,the value should be{""} instead of{???}.
Is there any hope?
|
|
|
|
|
cyn8 wrote: By using PathFindExtension() and PathFindFileName(), the error"error C2039: 'PathFindExtension' : is not a member of 'CString'" is generated.
I never implied they were CString methods.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hey guys,
im trying to build a project with a .lib file included. however, when i try to run the project i get
"This application failed to start because _______.dll was not found. Re-installing the application may fix this problem"
under properties -> librarian -> general, i have the library under "additional dependencies" and under "additional library directories" i have the file path to the library...
any ideas?
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
Is this with VS6 or VS200x?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
this is with VS2005
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
VonHagNDaz wrote: under properties -> librarian -> general, i have the library under "additional dependencies" and under "additional library directories" i have the file path to the library...
These are build-time settings.
The error is a run-time error - the system can't find a dll the application requires to run.
Where is the missing DLL?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
the dll file is in the folder containing the lib, which is a separate folder than the project
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
It should work if you move the dll to the same folder as the exe.
The documented search path order for dlls at runtime is:
The directory from which the application loaded.
The current directory.
The system directory. Use the GetSystemDirectory function to get the path of this directory.
The 16-bit system directory. There is no function that obtains the path of this directory, but it is searched. Windows Me/98/95: This directory does not exist.
The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
The directories that are listed in the PATH environment variable.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
putting it in the directory worked. thanks.
general programming practice question:
once this utility is complete, it will need at least 20 more dlls for the different printer libs. what i was trying to do was link each lib from their path in the repository. will i have to add each dll to the executable directory, or is their a cleaner way so when the libs are updated i wont have to recopy the dlls.
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
Linking the import libraries is done at build time so you're fine there. If it links, you're
good!
Runtime, however, you'll need to make sure the DLLs are in the paths indicated by the search
sequence I mentioned.
Loading DLLs at runtime with LoadLibrary (Run-Time Dynamic Linking)[^], you have more flexibility
since you can specify a path that's stored in the registry, or better yet, stored where you're
supposed to - in the shell "special" folders.
In this case though, the DLLs are bound at link time (Load-Time Dynamic Linking)[^] so you'll
need to have the DLLs available somewhere in the search path. The exe folder is always easiest
but not always convenient. Modifying the PATH environment variable is an installation-time
thing - so is specifying a current directory at application startup. With newer security issues,
I'm not sure what the current stance is on putting them in the Windows system directory. That
used to be where everyone dumped all their common DLLs
Whatever best fits your needs (vague, I know)
*edit* Also search on "DLL Hell" for more info and tips on avoiding it )
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
thanks man. much appreciated
------------------------------
I win because I have the most fun in life...
|
|
|
|
|
You're welcome! Good luck
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi
How can I paint a button,tab control etc.For example I want to change the color of background and text of a button.I saw that CWnd::OnCtlColor method was used in somewhere but I couldn't apply it in my project.How can I use this method or how can I change colors of controls easily.
Thanks
|
|
|
|
|
WM_CTLCOLORBTN you can set a button's text and background color
WM_CTLCOLOREDIT for edit control
WM_CTLCOLORLISTBOX for listbox
|
|
|
|
|
In my application i am using stretchblt bitmap function. it works fine in windows xp and 2000. But it fails in windows 98. Can anyone help me to solve this?
|
|
|
|
|
fails how? Can you post the code you use to set up the DCs and make the StretchBlt call?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|