|
Go for it.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
yeap yeapp yeaaapp go for it!!!!!!!!!!!!!!!!
"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/xml>
|
|
|
|
|
We can't allow this to happen!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
i may have written my question improperly . Actually i have created a CDialog (Using resources)which contains user registration form in which i have to validate name, zip, country etc ... when i click the sumbit button.
i am not able to write validate for country.
|
|
|
|
|
samrw wrote: i am not able to write validate for country
What defines a valid country?
Do you check the user's entry against a list?
If so, you could provide the list in a combo box so
the user can't input an unknown value.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
the user registration form which i am making only contains CEdit(Edit control) from resources . so i can't use combobox.
|
|
|
|
|
Okay...but I thought validation was the problem?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I wanna convert the CString data to the _bstr_t,I need some advice.
|
|
|
|
|
aygrhnwms304 wrote: wanna convert the CString data to the _bstr_t,I need some advice.
isn't CString csSomeData = "CP";
_bstr_t csSomeBstrdta(csSomeData); doesn't work!
"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/xml>
|
|
|
|
|
if
CString csSomeData="CP";
_bstr_t csSomeBstrdta(csSomeData);
The result of the data 'csSomeBstrdta' is not "CP" but "CP (1)".
So I wanna look for a more correct way.
|
|
|
|
|
aygrhnwms304 wrote: The result of the data 'csSomeBstrdta' is not "CP" but "CP (1)".
its not "CP (1)" but "CP" (1) . The (1) is the reference count of the BSTR, not the part of string.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Thanks.
I have some code as follows:
_ConnectionPtr m_connection;
_RecordsetPtr m_Record;
......
m_connection->Open("","","",adModeUnknown);
the parameter 1 must be the _bstr_t.
So I convert the CString to the _bstr_t:
CString m_str=_T("abc");
_bstr_t m_bstr(m_str);
and I debug the code:
m_connection->Open(m_bstr,"","",adModeUnknown);
It seem to be correct,but it is wrong.
What should I do?
|
|
|
|
|
You may use the CString::SysAllocString() to assign the string stored in a CString to a BSTR variable. You must then use the SysFreeString(bstr_variable) to free the allocation after you're done with it.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: You may use the CString::SysAllocString() to assign the string stored in a CString to a BSTR variable. You must then use the SysFreeString(bstr_variable) to free the allocation after you're done with it.
this is good method, but i always want to leave memory allocation/deallocation stuff to smartpointers or wrapper classes like _bstr_t and CComBSTR
"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/xml>
|
|
|
|
|
I infact saw he was actually using _bstr_t , but I just wanted to point out how can he convert from CString to BSTR , which is what I thought he needed to understand.
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
sorry if i sound rude in above reply.. i just presenting my thought .. hope you don't mind!
"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/xml>
|
|
|
|
|
Nothing of that sort man. What makes you think that?
BTW, planning to attend the South Asia MVP summit?
Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal - Friedrich Nietzsche
.·´¯`·->Rajesh<-·´¯`·.
[Microsoft MVP - Visual C++]
|
|
|
|
|
Rajesh R Subramanian wrote: BTW, planning to attend the South Asia MVP summit?
Time will tell that.. still awaiting final dates for MVP summits!
"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/xml>
|
|
|
|
|
aygrhnwms304 wrote: The result of the data 'csSomeBstrdta' is not "CP" but "CP (1)".
are you checking that in debugger or actually printing it somewhere??
"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/xml>
|
|
|
|
|
I did have checked that in the debugger.I wanna take off the "(1)",how to make it?
|
|
|
|
|
this seems to be development enviornment feature, you either have to live with it or inform the Studio development team regarding it!#
"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/xml>
|
|
|
|
|
|
Hi guys,
Just check out the code snip
for(int iLabel = 0; iLabel < MAX_BARS; iLabel++)
{
strLable[iLabel] = " ";
CString strTemp = "";
strTemp.Format("%d", 610 + iLabel);
UINT Data = _T("IDS_STR_") + strTemp;
strLable[iLabel].LoadString(Data);
}
As the Load string will take UNIT as a parmeter.It i need to conver CString to UNIT
Is there any other efficient procedure to do?
|
|
|
|
|
The IDS_STR value that you've to provide for LoadString() is not string. Its an #define for UINT .
For instance if the id of your string in string table is IDS_STR_MYSTRING , then you can call it like,
strLable[iLabel].LoadString( IDS_STR_MYSTRING );
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I need to load array of strings.
IDS_STR_610 A1
IDS_STR_611 A2
IDS_STR_612 A3
;;;
'''
IDS_STR_624 A24
thes string i need to load in an CString array
strLable[10].LoadString(IDS_STR_610);
strLable[11].LoadString(IDS_STR_611;
strLable[24].LoadString(IDS_STR_624);
|
|
|
|