|
Hi,
I am implementing a FindAndReplace() in CRichEditView where a underscore "_" needs to be treated as a part of the word.
eg. a line has "gz, gz_New, Old_gz" and when I search for gz only the first occurance of gz should be matched, rest which are prefixed or suffixed by "_" shouldnt match.
I dont want the "_" to be considered as a valid word separator or word break, but as a part of the word.
I was told that there is s way to turn off the default word break behavior of MFC. But what I found was for CRichEditCtrl and the things I find for View says they are only available for Asian Languages.
Please Help!.
Thanks
Aruna
|
|
|
|
|
1. Can you not remove the prefixed and the suffixed '_' sign before/after the second gz. Replace the second occurrence with some other character.
2. Also you can take a counter/boolean variable and check for the first occurrence of the '_' sign and set it to non-zero/false value and then go ahead with what you want to do.
I hope I understood your query correctly and this solution helps
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Err!..I was looking for a mfc answer...more elegant..
I think I need to be overriding the EditWordBreakProc Function and change the behavior when the input flag is WB_ISDELIMITER and return false when the character is "_". Any pit falls to this approach?
http://msdn.microsoft.com/en-us/library/bb761709(VS.85).aspx[^]
|
|
|
|
|
Hi there,
I am facing a very strange problem in creating objects (by calling constructor with arguments) of one class inside another class. I have a situation where I want to create a object of class firstClass inside class secClass using constructor with arguments of firstClass e.g.:
class firstClass{
string abc;
public:
firstClass(string label):abc(label){}
};
class secClass{
public:
firstClass obj1("abc");
secClass(){}
};
I think the compiler is facing ambiguity regarding the declaration of object obj1 with a function prototype definition. Similar case arises with templates but they can be resolved using typename keyword. Since typename cannot be used outside template declaration, is there any way to achieve instantiation of obj1 ?? Plz help!!!
|
|
|
|
|
You can't construct to object in the class definition. What you have to do, is construct it in the constructor initialization list. In your cpp (or where your constructor is defined):
secClass::secClass() : obj1("abc")
{
}
|
|
|
|
|
Thanks a lot!! Problem solved.
|
|
|
|
|
Hello all..
I'm facing a problem regarding replacing string in _bstr_t type...
Say i've data in "bstr_Data" which is defined as
_bstr_t bstr_Data;
Now this data contain "#" in it.. I've to replace "#" with ";".. All the occurence..
How can i do it..
Thanks
|
|
|
|
|
You need to convert bstr to cstring and then use find method of it....
_bstr_t bstrStart(bstr);
CString s;
s.Format(_T("%s"), (LPCTSTR)bstrStart);
Thanks A Ton
Ash_VCPP
|
|
|
|
|
I forgot to tell it's WIN32... Will it work??
I mean CString??
|
|
|
|
|
it will work if u have taken mfc support while creating your project...
Thanks A Ton
Ash_VCPP
|
|
|
|
|
To use CString in Win32, include the file atlstr.h
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Including atlstr.h gives me lots of error... Isn't there any way to do with WIN32 functions only???
|
|
|
|
|
go to project menu select settings and from tab general select mfc support from the combo compile it n enjoy.....or include string.h file for ur purpose only.
Thanks A Ton
Ash_VCPP
|
|
|
|
|
Something base on the following?
#include "stdafx.h"
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
std::wstring str1;
str1 = L"abc#efg#ijk";
int found = str1.find_first_of(L"#");
while(found != str1.npos)
{
str1.replace(found, 1, L";");
found = str1.find_first_of(L"#",found+1);
}
return 0;
}
|
|
|
|
|
Yes that works..
Many thanks Jonathan...
|
|
|
|
|
One more question...
As i'm using _bstr_t.. So do i need to free it??
|
|
|
|
|
_bstr_t have destructors which free the internal string, so if its local the destructor will be called when it goes out of scope. If you created it using 'new' you have to delete it.
|
|
|
|
|
Right.. I'm not creating it using new...So i don't need to free it..
Cool..
Once again thanks Jonathan
|
|
|
|
|
One more question...
I'm giving something like this.
int found1 = wsVar.find_first_of(L"&&&&");
while(found1 != wsVar.npos)
{
wsVar.replace(found1, 1, L"\"");
found1 = wsVar.find_first_of(L"&&&&",found1+1);
}
So wherever it found one "&" it convert to ".. I need that whenever it found "&&&&" then only it replace with "(double quotes only)..
Is it possible???
Thanks
|
|
|
|
|
Hi All,
I am compiling my project in the release mode in VC++. I have a .def file where i have declared the setLog and now i am getting following error
Linking... Creating library Release/HKL.lib and object Release/HKL.exp HKL_libinterface.obj : error LNK2001: unresolved external symbol _SCTP_setLog@8
Please help me on the above to fix the problem.
Thanks
|
|
|
|
|
When the project was in Debug configuration perhaps you set the location of the library containing setlog in Project | Properties (but only in Debug config) and now it also needs setting in the properties for Release mode as well?
|
|
|
|
|
Hey can you tell me how to set this properties..
Thanks
|
|
|
|
|
Well I'm geussing this is the problem.
Have you managed to compile it in Debug mode?
|
|
|
|
|
yes i have compiled it in the debug mode..
and it is compiling fine in debug mode..
but when i compile in release mode i face this error which i mentioned
in my problem..
|
|
|
|
|
Depends on what version of Visual studio, but in 2008 its:
Project | Properties | Configuration Properties | Linker | General to see the Additional Library directories
and
Project | Properties | Configuration Properties | Linker | Input to see the Additional Dependancies
Look at these settings in Debug mode and then in Release mode, is there a setting in debug that is not in release?
|
|
|
|