|
I think you should use
GetLine( 0, SampleDocName, SampleDocNam_Len );
instead of
GetLine( 0, SampleDocName);
since for the latter you need to pass the line lenght on the first word of the buffer (MSDN):
lpszBuffer
Points to the buffer that receives a copy of the line. The first word of
the buffer must specify the maximum number of bytes that can be copied
to the buffer.
Also will be nicer if you use the C++ allocation pair new/delete
(you are free to use free of course, but as matter of style...).
|
|
|
|
|
Hi all,
Please any body tel me how to hide a tab control from the property sheet.
I tried
GetTabControl()->ShowWindow(SW_HIDE);
But when executing this all the tab control of the sheet goes to hide.
But i want to hide a single tab control.
Please tel me anybody knows it.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Ok..Now no need to any reply for me.
I solved it.
I tried RemovePage of Sheet.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
Hi, do you guys know how to set(change) the short file name of a specific file inside visual c++? Is there any API doing that?
Thanks!
|
|
|
|
|
The short file name of a long named file is the first six chars, a ~ and a number, starting with 1 ( depending on how many have those 6 chars ). Not sure if it goes to 5 chars for > 9 files.
You can't set it AFAIK
Christian Graus - C++ MVP
|
|
|
|
|
I think you actually cannot.
|
|
|
|
|
If you're on XP+ and the file is on an NTFS volume, you can use SetFileShortName() .
|
|
|
|
|
Can someone give me a real, WORKING - example(code) of how to "CreateDirectory" , "CopyFile" and "ChangeDirectory" in MFC.
I know how to use these "verbs/tokens" in non-MFC programs, but they aren't available to you in MFC; because you can't "#include <window.h>" in MFC.
So how do you do the same things in MFC. Example code PLEASE!
A C++ programming language novice, but striving to learn
|
|
|
|
|
windows.h is very much included in MFC.
Here's a working sample
::CreateDirectory(_T("C:\\TESTTEST"), NULL);
HANDLE hFile = ::CreateFile(_T("C:\\TESTTEST\\test.tst"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
::CloseHandle(hFile);
::CopyFile(_T("C:\\TESTTEST\\test.tst"), _T("C:\\test.tst"), TRUE);
::SetCurrentDirectory(_T("C:\\TESTTEST"));
|
|
|
|
|
Larry Mills Sr wrote: because you can't "#include <window.h>" in MFC.
Not true. MFC is a wrapper on Win32, you call any Win32 API you like. Sounds like you have another problem ?
Christian Graus - C++ MVP
|
|
|
|
|
Apparently <windows.h> is already included by MFC headers (AFXV_W32.H).
Regards
|
|
|
|
|
Thanks. Everyday I learn and learn and learn; but sometimes I forget what I learned.
I never realized that windows.h was included in MFC, so dumb me tried to do everything I wanted to do without using any API functions. You've just made my programming life much, much simpler,
Again thanks.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hi all,
in my application (MFC MDI Document/View) I use a datagrid and a chart control, each of them in a static splitter pane. Now, I want to provide a different view on my data and therefor I want to open a new child with a "different" view class (derived from CFormView) while the first view is still open. The menu which is displayed should depend on the View which is currently active.
Can anybody give me a hint and show me the pitfalls?
Thank you,
Frank.
|
|
|
|
|
Hi All,
This seems such a simple problem, I am embarrassed to ask for help, but I just can't seem to get the syntax correct for the CopyFile command. My application builds a vector of CStrings containing commands in format Copyfile( "source file", "dest file", FALSE ), using double quotes around the file specifications in case there are embedded spaces. The following is one of the commands:
CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
All of these commands fail with an error code of 123, which indicates invalid call syntax. What is wrong here? Can anyone help me with this dumb little problem?
Thanks,
Royce
|
|
|
|
|
RoyceF wrote: CopyFile( "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls", "Expense Report Form.xls", FALSE );
Don't you escape slashes?
|
|
|
|
|
Yes, in the CString.Format() method call you do:
CString str;<br />
str.Format( "C:\\Documents and Settings\\rfickling\\My Documents\\Expense Report Form.xls" );
I am actually formatting these file specs into CString variables so that it looks like the following:
strSrc = "C:\Documents and Settings\rfickling\My Documents\Expense Report Form.xls"; <br />
strDst = "Expense Report Form.xls"<br />
So the command in C++ syntax is:
CopyFile( strSrc, strDst, FALSE );
This should work, but I get a 123 error.
|
|
|
|
|
I think the problem is the target file name. You are giving just a filename, so Windows tries to create the file in the current directory.
And what's the current directory?
Try giving a targetname with a complete path, if possible.
Or make sure the current directory is set to where you want the file to be copied to.
SetCurrentDirectory();
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
The following code works fine on my computer (Win2k):
CString strSrc, strDst;
strSrc.Format( "C:\\Documents and Settings\\Carlo\\My Documents\\Donald Duck.txt" );
strDst.Format( "Donald Duck.txt" );
if ( CopyFile( strSrc, strDst, FALSE )==FALSE)
{
}
|
|
|
|
|
Error code 123 is "The filename, directory name, or volume label syntax is incorrect."
Does this help narrow it down?
*EDIT* You shouldn't have to add any double quotes because of spaces.
-- modified at 18:10 Wednesday 22nd November, 2006
|
|
|
|
|
RoyceF wrote: CopyFile(
instead of this use ShFileOperation
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Thanks for the help, guys. I found that my problem was using the double quotes around the file paths and not specifiying a filename in the 2nd parameter.
Royce
|
|
|
|
|
I recently had some code sent to me by a user of one of my articles that improved the functionality of my article. The code is designed to work with VC8. But as I want the code to work on VC6 and up I have to put guards around it. So my quuestion is what version of VC introduced the __FUNCTION__ macro and what version introduced the __noop keyword?
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
I believe __FUNCTION__ was first introduced in VC7, which was my final straw to upgrade from VC6. As for the __noop , I'm not sure.
-- modified at 15:16 Wednesday 22nd November, 2006
__noop also added in VC7
|
|
|
|
|
Thanks
I am assuming you mean VC7.0 (2002), not VC7.1 (2003)
You may be right I may be crazy -- Billy Joel --
Within you lies the power for good, use it!!!
|
|
|
|
|
PJ Arends wrote: I am assuming you mean VC7.0 (2002)
Probably a little late, but yes
|
|
|
|