|
Replace all "\" by "\\".
In this line:
PFPath.Insert(i,(CString)".\");
Why is it a ".\" ?? Why do you insert a '.' ?
|
|
|
|
|
I already tried replacing the "\" with "\\". the program can be compiled, but the result is erroneous:
Then i have at the beginning of the snippet PFPath: "C:\folder1\folder2" and
PFPath: "\" at the end of the snippet.
I don't have '.' normally, it was "\". It's a typo that occurred during copying here to the messageboard.
|
|
|
|
|
caykahve wrote:
// Here I have PFPath as "C:\folder1\folder2"
int i=0;
while( PFPath.Find("\",i)!=-1 )
{
PFPath.Insert(i,(CString)".\");
i+=2;
}
// Here I want to have PFPath as "C:\\folder1\\folder2"
Ok, another problem is here: the find function returns the starting position of the substring found in the string. So, when you insert the new character, it will insert it at the position 'i' that is left the same (so 0 in the first case). You must take the value returned by Find() and insert the new char there.
|
|
|
|
|
OK, you are right. But still the insert function does not work properly. Here is the changed code snippet:
int i=0; <br />
i = PFPath.Find("\\",i);<br />
while( i>-1 )<br />
{ <br />
CString found;<br />
found.Format("Backslash found at index: %d",i);<br />
MessageBox(found);<br />
<br />
PFPath.Insert(i,(CString)"\\"); <br />
MessageBox(PFPath);<br />
i += 2;<br />
i = PFPath.Find("\\",i); <br />
}<br />
if(i==-1)<br />
MessageBox("not found");<br />
MessageBox(PFPath);
Output:
Backslash found at index: 2
C:\folder1
\
not found
\
|
|
|
|
|
If C:\folder is something that you typed at a command prompt or in some text box, there is no need to replace one backslash with two. This is user input, which differs from string literals in your code. Whatever function is using the folder name will work correctly.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
C:\folder is actually is not a user input, it is
SHGetSpecialFolderPath(NULL,PFPath.GetBuffer(_MAX_PATH), CSIDL_PROGRAM_FILES, FALSE);<br />
and it gets "C:\Program Files" exactly.
I add something at the end of this string and then i try to use it in
<br />
CString WholePath = PFPath + (CString)"\\....\\file.exe;<br />
SHELLEXECUTEINFO shellInfo;<br />
...<br />
shellInfo.lpFile = WholePath;<br />
::ShellExecuteEx(&shellInfo);
If I do not use double slash, I get the error: "The program cannot find the file specified"
That's why I need double slash.
Why is it so hard to insert the required character in to a string I don't understand.
Is there some other way to obtain "C:\\Program Files"?
|
|
|
|
|
You are still have a bit confused. There is no need to change PFPath , and the string literal being appended to it is fine (because it contains the necessary double backslashes). You don't need to insert anything additional. The variable WholePath contains what it needs to.
caykahve wrote:
If I do not use double slash, I get the error: "The program cannot find the file specified"
Rightly so. But the code snippet you've shown does have a double backslash so I don't see the problem.
caykahve wrote:
Is there some other way to obtain "C:\\Program Files"?
Why, when you are already doing it correctly?
If you tried to access a file using code like:
"c:\program files\some_folder\mydata\file.dat" not only would the compiler complain about illegal escape characters (e.g., \p and \s and \m make no sense, but \f does), it would have interpreted that as
"c:rogram filesome_folderydata\file.dat" hence the file not being found.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hello,
I'm trying to develope a software to capture video from a webcam and sending it through internet.
The primary need is to view through the camera in my building, through the internet, from somewhere else.
I have the knowledge about how to program using CSocket in VC++.
Can any body tell me how to achieve this, please?
Or can you suggest any helpful link or something else?
Thank you.
|
|
|
|
|
Nishad S wrote:
The primary need is to view through the camera in my building, through the internet, from somewhere else.
This Will help you:-
http://www.codeproject.com/internet/shoonyaintntbrdcast.asp[^]
"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
|
|
|
|
|
I have a list view which needs to be sorted based on a click on header.I am using the ListCtrl.SortItems() function. But it is crashing when i clicked on the header.For better understanding i have listed the code.
void CDirTreeDemoView::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*) pNMHDR;
this->GetListCtrl().SortItems (CompareFunc, pNMListView->iSubItem);
*pResult = 0;
}
int CALLBACK CDirTreeDemoView::CompareFunc (LPARAM lParam1, LPARAM lParam2,LPARAM lParamSort)
{
ITEMINFO* pItem1 = (ITEMINFO*) lParam1;
ITEMINFO* pItem2 = (ITEMINFO*) lParam2;
int nResult = 0;
switch (lParamSort) {
case 0: // File name
nResult = pItem1->strFileName.CompareNoCase (pItem2->strFileName);
break;
case 1: // File size
nResult = pItem1->nFileSizeLow - pItem2->nFileSizeLow;
break;
case 2: // Date and time
nResult = ::CompareFileTime (&pItem1->ftLastWriteTime,
&pItem2->ftLastWriteTime);
break;
}
return nResult;
}
When i debuged lParam1 and lParam2 are getting value as '0'.
Any hekp please
Thanks
|
|
|
|
|
|
This link should help http://www.codeproject.com/buglist/listcontrolsortitemsbug.asp
|
|
|
|
|
When populating the list, are you also calling SetItemData() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I am automating MS-Word from my MFC application. My application can get the number of characters currently in the document, the number of sentences, praragraphs e.t.c. For these statistics, various functions are exposed by the Word Automation interface like GetCharCount(), GetWordCount() e.t.c
I want to find out that how many characters in the document are in bold and how many characters are in italics. Is there any way to calculate these values ?? What i am thinking is to iterate each character, but i also donn't know that how can we iterate each character of the document.
Imtiaz
|
|
|
|
|
I don't know about the automation part, but in MS Word you can search with wildcards and format, so if you can automate that, instead of iterating through each character you could specify a search for [*, use wildcards, bold] and repeat the search counting the hits.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I am in the mist of editing a legacy program which output the report to words format. I am require to add in images, but I am unable to set the position of the images. I am able to add the images but all at (0,0) range.
i'm using the following codes
_Document oDoc;
Shapes oShape;
oShape = oDoc.GetShapes();
oShape.AddPicture
// v is suppose to be the indicator of the top and left points
tagVARIANT v;
v.lVal = v.intVal = v.iVal = v.fltVal = 200;
("C:\\Logo.JPG",vtFalse,vtTrue,&v,&v,vtOptional,vtOptional,vtOptional);
the image still appear at point (0,0)
Is it correct to use Shapes class or should I use InlineShapes
can someone please advise me... where have I gone wrong
Thomas
|
|
|
|
|
Barm wrote:
tagVARIANT v;
v.lVal = v.intVal = v.iVal = v.fltVal = 200;
tagVariant is an union . That means all lVal , intVal , iVal , etc. share the same space, so assigning multiple fields makes no sense. You should assign only one of the value fields, and set the vt member to indicate which is the one you are using. As you didn't initialize vt , it must have remained as zero, which indicates an empty variant (i.e.: v.vt == VT_EMPTY ), and that may be why the image remains at 0,0
Try the following:
tagVariant v;
v.vt = VT_I4;
v.lVal = 200;
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
problem for position solved but I encounter another problem, i need to put the images into different cells in a table and some images are to be outside the table. The codes is able to work but all the images are inserted into the first cell in the first table. Is there a way to set the position with respect to the a cell?
Thomas
|
|
|
|
|
Using VC6 on Win2k...
I have a test app with the following characteristics:
- Dialog-base app with MFC dynamically linked
- Dialog has no titlebar, but it does have a thin border.
- There is a single static bitmap control on the dialog
- I created a CStatic-derived class to allow it to draw a DIB on the dialog using Chris Maunder's CDIBSectionLite class
- I put the derived control inside the AFX_DATA macros of the dialog
- there is no dynamic allocation going on in my app
When I shut a test app down, I get the following in the output window:
The thread 0x394 has exited with code 27 (0x1B).
The program 'K:\TEST APPS\bmploader\Debug\bmploader.exe' has exited with code 27 (0x1B).
Does anyone know why, and how to clean this up?
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Is there only one thread ? You're just getting this in the UI ? Are you sure it means anything important ? I doubt it does.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
John Simmons / outlaw programmer wrote:
I have a test app with the following characteristics:
- Dialog-base app with MFC dynamically linked
[...]
When I shut a test app down, I get the following in the output window:
The thread 0x394 has exited with code 27 (0x1B).
The program 'K:\TEST APPS\bmploader\Debug\bmploader.exe' has exited with code 27 (0x1B).
Does anyone know why
I think it means you closed the dialog with the Esc key (scan code of Esc is 0x1B = 27).
John Simmons / outlaw programmer wrote:
and how to clean this up?
These messages only appear in the output window in the IDE. Unless you need to use the app's exit code for something else, I wouldn't worry about it.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Jose Lamas Rios wrote:
I think it means you closed the dialog with the Esc key (scan code of Esc is 0x1B = 27).
That's probably it. I don't have any buttons on the dialog box, so I have to press escape to get out of it.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote:
The thread 0x394 has exited with code 27 (0x1B).
The program 'K:\TEST APPS\bmploader\Debug\bmploader.exe' has exited with code 27 (0x1B).
When you shut down the application using Alt+F4 instead, notice that the thread exists with a code of 2, which is Cancel/Close. What you are seeing is normal.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I write an plugin component for firefox 1.0,which contains an dialog.on the dialog,there 's an editbox with password style checked.now i run the component
on Windows XP.when i put password into the editbox ,It shows "||||||" instead of "*******"or".......". on windows 2000,It works normal.
that's strange.
anyone can help me?
Mike Shen
|
|
|
|