|
cpp_prgmer wrote: lpstrFile member of GetOpenFileName function OPENFILENAME param returns me just the selected file name instead of prepending d string with dir path.
Here I get the full path.
cpp_prgmer wrote: How does defining _UNICODE affect the working of this function, and how does one resolve this problem??
We must convert the file name to a Wide Character string using MultiByteToWideChar(...)
MultiByteToWideChar(CP_ACP, 0, ofn.lpstrFile, -1, pszFile, 512);
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Sorry I guess you got me wrong. I have added _UNICODE among the preprocessor defn in d prj settings-> C++ tab, preprocessor combo value-> preprocessor directives.
Now the compiler interprets the ofn.lpstrFile as unsigned short * rather than char *.
So the question of conversion does not arise.
|
|
|
|
|
This works fine:
void main( void )
{
OPENFILENAME ofn = {0};
wchar_t szBuffer[MAX_PATH] = {0};
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.lpstrFile = szBuffer;
ofn.nMaxFile = sizeof(szBuffer);
GetOpenFileName(&ofn);
wprintf(L"%s\n", ofn.lpstrFile);
} How does it compare to what you have?
cpp_prgmer wrote:
Also I would like to hide the n/w btn on the placebar which im not able to inspite of the OFN_NONETWORKBUTTON option. Any suggestions on using this func 2 select multiple files w/o losing d explorer-style file browse dlg & placebar??
The "My Network Places" button cannot be removed from the My Places bar, but it can be hidden. You'll need to modify the registry at HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\Open Find\Places\StandardPlaces.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Oh thanks David, actually I apologize for the mistake I made. I had set the lpstrFileTitle member also pointing to the same buffer which caused the prob.
Abt hiding n/w places option in d placebar, won't modifying d registry entry affect d working of other appl?? or is it dat ur hinting at temp. registry entry modification
Well how abt multiple file selection using the same func. OFN_ALLOWMULTISELECT is not supported and I want to have it using explorer-style dlg. Have i to think of a diff work-around for the same??
|
|
|
|
|
cpp_prgmer wrote: Abt hiding n/w places option in d placebar, won't modifying d registry entry affect d working of other appl?? or is it dat ur...
How about making an effort at spelling words correctly? Otherwise your posts are very hard to decipher. Even though folks might know the answer to a problem you are having, they might just refrain from sharing it with you simply because they feel you are not doing your part by forming a coherent sentence. No charge for that advice.
cpp_prgmer wrote: Abt hiding n/w places option in d placebar, won't modifying d registry entry affect d working of other appl??
Yes, it affects Office as a whole.
cpp_prgmer wrote: Well how abt multiple file selection using the same func.
Multiple files can be selected just as easily as a single file.
cpp_prgmer wrote: OFN_ALLOWMULTISELECT is not supported
Sure it is. Why would you think otherwise?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
A file is selected in explorer. I am able to get the selected file info using listview class "SysListview23". Now i want to get the selected file full path. SHGetPathFromIDList is not returning the full path. It is returning the path respective of desktop folder. How to get the full path of the selcted file/folder?
Please help me
Thanks,
Arumugarani Sundaram
|
|
|
|
|
If you know the pathname relative to the Desktop folder, then simply get the Desktop folder path (use SHGetFolderPath() ) and merge the two together.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Hi,
Thanks for your reply.
But this is not my expected result. I explain here the scneario once again.
(ie) The actual path of the file is : let it be D:\Samples\sample.txt. But SHGetPathFromIDList returns the path as "c:\Documents and Settings\username\Desktop\sample.txt". But what my requirement is i need the full path "D:\Samples\sample.txt".
I was able to get the same using GetWindowText of cabinet class. But what the problem is suppose if the user unchecks the option "show full path in titlebar" via Tools->folder options->view, then i won't be able to the fullpath.
If you know how to get the fullpath, please help me
|
|
|
|
|
I'm not understanding your definitions of "actual path" vs. "full path." What's the distinction? Is D: mapped to some folder on the C: drive? How are you acquiring the IDL?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I have a setup program and it registers various Components, (DLL's and OCX's) but a problem is caused only when the setup is trying to register FM20.DLL, the error code is 0x80040151. All other files are getting registered. How can I resolve this problem? In some machines there is no problem, but in some machines (98 specifically) this error comes.
Regards,
Aljechin Alexander
-- modified at 1:32 Wednesday 25th January, 2006
|
|
|
|
|
Can you register that DLL manually?
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
Respected All
I have used PRINTDLG in VC++ in my program.
now it work fine but when I changed the Orientation or some changes to print dialog it work accordingly but only once and when i have to print 2nd time my previous changes made to print dialog could not saved and default print dialog settings picked up unlike other window packedges like MS Word when we set the printer dialog settings then it is saved as long as the document is open.
now plz guide me that how i make my program that i personlize the printer dialog and my changes to printer dialog makes permonent as long as my VC++ program is running.
hope +ve response very soon.
david
|
|
|
|
|
void CSaveTextDlg::OnRead()
{
FILE *f;
CString temp1;
if ( ( f = fopen("c:\\Log.txt","r") )==NULL)
{
AfxMessageBox("Unable to open file");
return;
}
while(fscanf(f,"%s",temp1)!=EOF)
{
str= CString(str) + CString(temp1);
}
fclose(f);
m_Text=str;
UpdateData(FALSE);
}
This is my code...I got full text of Log.txt...But i got full text without space.I need space also.My text contains some tables..I cudn't get tht.
Pls findout the problem
|
|
|
|
|
Why don't you use CFile :
CFile file;
if(!file.Open("c:\\log.txt",CFile::modeRead))
{
AfxMessageBox("Unable to Read File");
return;
}
char * str=new char[100];
file.Read((void*)str,100);
delete[] str;
str is the buffer that contains data retrieved from the file .
Does this solve your problem????
Now you can use file.Seek() to get the data from a certain location in the file
Regards
Anshuman
Happy Programming
-- modified at 22:57 Tuesday 24th January, 2006
|
|
|
|
|
why u used fscanf..? why fgets not..
fscanf returns when white space is encountered.
so you can use fgets which reads the file line by line.
Thanks and Regards
Laxman
FAILURE is the first step towards SUCCESS 
|
|
|
|
|
Laxman9 wrote: fscanf returns when white space is encountered.
Not exclusively.
Laxman9 wrote: so you can use fgets which reads the file line by line.
fscanf() can also do this.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
fscanf function reads a word from file. This is why you do not get any space.
If you want to get space then use another function instead of fscanf.
MANISH RASTOGI
|
|
|
|
|
it seems that you're using either c and C++ functions.
i suggest you using the standard STL library, with std::iostream and std::fstream .
there, you'll dispose of a getline() function whichcan be configured to read until a \n character (by default) of whatever other...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.20][VCalc 3.0 soon...]
|
|
|
|
|
Ok There are lots of good suggestions.
I thought to give the answer in your style only.
fscanf(f, "%[^\n], temp1);
this will read string of character until it will get a new line;
I just add as one of the answers. But the previous answers are more perfect.
|
|
|
|
|
While you may get it to work, your code is not very efficient as it reads from the disk way too often. If all you are doing is reading from a file and displaying the contents in an edit control (i.e., you wanted words and spaces), I suggest something like:
CFile file("c:\\log.txt", CFile::modeRead);
LPBYTE lpBuffer = new BYTE[file.GetLength() + 1];
UINT uBytesRead = file.Read(lpBuffer, file.GetLength());
lpBuffer[uBytesRead] = '\0';
file.Close();
m_Text.SetWindowText(lpBuffer);
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
I have some doubts with regards using the above method.
Now the data may need to b displayed on Editcontrol whih is on a different dlg than the one from which the read request has been initiated. So one needs to store the data on2 a CString or like to Xfer the data to dat dlg.
Secondly, when u read file data u wud not know in advance how large the file length wud b, so allocation of a very large buffer wud not b advisable. How abt having a fixed size buffer that reads data and does
CFile FileToRead;
FileToRead.Open(<filepath>);
DWORD dwBytesRemaining = FileToRead.GetLength();
while(dwBytesRemaining)
{
UINT nBytesRead = FileToRead.Read( buffer, sizeof(buffer) );
CString += buffer;
dwBytesRemaining -= nBytesRead;
}; ??
CString wud manage the hassles of mem mgmt and u have read all the data w/o any allocation work by urself. Does CString have any limitations of not being able 2 store large data or newline probs etc??
|
|
|
|
|
cpp_prgmer wrote: Now the data may need to b displayed on Editcontrol whih is on a different dlg than the one from which the read request has been initiated.
It makes no difference, as long as the data being read is accessible by the other dialog.
cpp_prgmer wrote: So one needs to store the data on2 a CString or like to Xfer the data to dat dlg.
The example I provided did store the data in a BYTE variable.
cpp_prgmer wrote: Secondly, when u read file data u wud not know in advance how large the file length wud b...
Sure you would. I also showed this in the example. Did you not see it? Strangly enough, you used the same CString::GetLength() call in your code snippet.
cpp_prgmer wrote: How abt having a fixed size buffer that reads data and does...
Like I previously indicated, multiple disk reads are not necessary, and can be detrimental to performance.
cpp_prgmer wrote: CString wud manage the hassles of mem mgmt and u have read all the data w/o any allocation work by urself.
Yes, CString does this, but how much trouble is it to use the new operator once with the tradeoff being less disk I/O? Furthermore, the CString += buffer statement can be a lot more expensive than a single use of the new operator.
cpp_prgmer wrote: Does CString have any limitations of not being able 2 store large data or newline probs etc??
No.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
hi~everyone
i hava a question puzzle me ! when i used "CreateDirectory" function make a file use unicode in windows 98
but it's allways fail !
please help me ande very thanks in advance!!
nothing
|
|
|
|
|
as far as i know, unicode support in win98 is not too good and unicode apis are not well documented.
-Prakash
|
|
|
|
|
You need MLU[^] to work with Unicode in 98 Machine :->.
Regards,
Aljechin Alexander.
|
|
|
|