|
You can use the Find method of the CString class in a loop by adjusting its iStart parameter.
|
|
|
|
|
I used Find method. But not get. can you please tell me something brief?
G.Paulraj
|
|
|
|
|
Create an integer variable iStart and set it to 0 .
Call str.Find("circle", iStart);
Check the return value.
If it is -1 , the word was not found.
Otherwise use str.Mid with the return value from Find as the first parameter.
Now increment iStart by the 6 , which is the length of the word "circle" .
Repeat the loop till Find returns -1 .
It is recommended to enclose all strings in the _T("") macro so that it works for both UNICODE and NON-UNICODE builds.
|
|
|
|
|
Thanks a lot...
G.Paulraj
|
|
|
|
|
Hope you tried your hand before getting the code.
CString csStr = _T( "Hello it is circle, how is this circle" );
LPCTSTR CIRCLE = _T( "Circle" );
int nPos = 0;
int nCountCircle = 0;
while( -1 != ( nPos = csStr.Find( CIRCLE, nPos ))
{
nPos++;
nCountCircle++;
}
Величие не Бога может быть недооценена.
|
|
|
|
|
Adam Roderick J 09 wrote: CString csStr = _T( "Hello it is circle, how is this circle" );LPCTSTR CIRCLE = _T( "Circle" );int nPos = 0;int nCountCircle = 0;while( -1 != ( nPos = csStr.Find( CIRCLE, nPos )){ nPos++;nCountCircle++;}
Could it will like this, possibly instead of nPos++ to nPos+= _tcslen(CIRCLE); , little more performance oriented code
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
The cheeky method:
Make a copy of the string and run CString::Replace() on it. It will return the number of replaced instances.
|
|
|
|
|
I download DFV_Demo from codeproject,I use my custom view doc mainframe to inherit interrelated class of DFV_Demo,but i cann't update view immediately as common .For example , when i click first button of toolbar, fistr button is press,and then i continue to click second button, sencond button is press ,but first is still press,i'm trouble in it,need your help,thank you first.
|
|
|
|
|
It's probably a 3-state button which remains pressed when it is clicked once and is released on the second click.
|
|
|
|
|
as you say it's a 3-state button ,it's a button in toolbar but i cann't understand how to update view in a dialog control
|
|
|
|
|
Can you please explain it clearly,
It is very difficult to understand whats you need.
I guess you want to update all the view of a MDI or SDI application.
Is it so then UpdateAllViews can be used [^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Yes,i need to update view,it's different from with traditional SDI, it's my custom view.
The view is on the dialog control,thanks for your reply
|
|
|
|
|
Hello everybody !
I select the menus from Resource View.
Now I want to hide/remove the menu when he is login faild !
just like this :
BOOL CSSCDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CLogin dlg;
int nDlg;
nDlg = dlg.DoModal();
if(nDlg == IDCANCEL)
{
......
}
}
Thanks for your reply !
Best Reguards !
|
|
|
|
|
|
I know the mean , thanks a lot !
|
|
|
|
|
Hello folks!
This isn't directly a C++ question, but i don't really know where to ask this, and it is kinda related to C++ since we do work with VC++ and use MFC so...i thought i try my luck here, sorry if i "heavily" misplaced this question. So...
We work on a project, every time we give out an RC (Release Candidate), we backup the PDB and the -that time- current source files for later usage. Then, after we receive a crash report from a test site, we check the logs what version they were created with, retriece the PDB, the EXE and the sources to analyze the minidump included with the logs. Now, my problem is that the PDB seems to have the paths to the source files "hardcoded" into it and because of this, every time when we get a dump to analyze, we have to replace our latest sources with the less recent ones which were archived when the given RC went out so we know where the crash occured, what threads were doing and so on. After we are done with it then we have to get back to our latest sources again to continue the development. As you can think this is a bit...uncomfortable. Is there a way to tell Visual Studio (2003, yes, i know, it is old...) to search for the source files somewhere else than where they originally were located when the PDB was made? What i mean is, for example let's say a given file is in c:\projects\the_thing\the_file.cpp when the project is being built. Once the RC is out we make changes to the_file.cpp, then we get a crash, instead of having to replace the_file.cpp with the earlier version to see where the crash occured, i would rather try to copy the earlier version to c:\dumpchecks\the_thing\the_file.cpp and then somehow tell VS to instead of c:\projectss\the_thing, use c:\dumpchecks\the_thing to locate the sources. Of course i wouldn't like to do this for every single file, just tell it once to use c:\dumpchecks instead of c:\projects. Is this duable, or is there some other simple way i don't know of to solve this? I tried to change some folders in project settings and such like the "Working folder" but nothing seems to change this. Thanks in advance for any help.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Not sure if you can do this in Visual Studio, but you can set a source path in a Windbg session.
|
|
|
|
|
We'd prefer VS (and couldn't find how to do it -if it is possible at all- yet) but i will give WinDbg a try, thanks.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Use Microsoft's Symbol Server[^]. Part of the release process for a build becomes adding its symbols to your downstream store and you set it up to pull symbols for the OS from upstream (from Microsoft). Look here[^] too.
Steve
|
|
|
|
|
Thanks, we will check it out to see if we can use it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
|
|
|
|
|
Hi,
I am having a list control with icon view in my application. I have populated the dialog with some items. I need to focus on the first item when the dialog containing the list control shows. Currently even if i set the selection with the SetITemState in the initdialog it is not showing because the default item in the dialog is a button so the focus goes there first.
Also, when i try to delete the first item of the list control by clicking on the item and selecting the button 'delete'[which is another element in the dialog] I am not getting some junk values from the function GetNextItem()
Please advice
Regards,
Joe
|
|
|
|
|
emmmatty1 wrote: I need to focus on the first item
You can set the tab order in the dialog, or set the focus in the function that handles the WM_INITDIALOG[^] message.
emmmatty1 wrote: Also, when i try to delete the first item of the list control by clicking on the item and selecting the button 'delete'[which is another element in the dialog] I am not getting some junk values from the function GetNextItem()
I guess you mean that you are getting some junk values. If you are iterating any sort of list and you delete an item then you should restart your loop, since the iterators may no longer be valid.
|
|
|
|
|
Try the GetFirstSelectedItemPosition / GetNextSelectedItem methods.
The selection not showing may be because the Always Show Selection property is not set to true .
Try doing a SetFocus to the list control in OnInitDialog at the end.
|
|
|
|
|
Hello ,
I can access the right pane of the Windows Explorer in XP ( 32 bit ) , by getting the handle to the "SysListView32" .
But in Windows 7 , the window class for the right hand side of the Windows Explorer is DirectUIHWND. I have used Spy++ to see the child windows, but I only find ControlNotifySink .
Any idea how do I get the list view .
Thanks in advance
Sujay
|
|
|
|
|
What are you trying to do?
I guess you should be writing a shell extension.
What you're doing is not a recommended way and this is exactly the situation why it is not recommended.
|
|
|
|