|
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);
|
|
|
|
|
If those strings are declared serially in resource table, then you can loop and add, for instance,
UINT StringID = IDS_STR_610;
UINT EndStringID = IDS_STR_624;
while( StringID != EndStringID )
{
CString csMessage;
csMessage.LoadString( StringID );
++StringID;
}
This will work only if the strings are serially in string table. So take care.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
|
Why don't you report the problem in the article message board (at the bottom of the article) ?
|
|
|
|
|
Hi everyone.. I'm having a problem using lists in C++. I'm using Visual Studio 2008 express.
This is the output of build:
c:\programas\microsoft visual studio 9.0\vc\include\list(937) : error C2679: binary '==' : no operator found which takes a right-hand operand of type 'const Band' (or there is no acceptable conversion)
c:\documents and settings\francisco\os meus documentos\visual studio 2008\projects\band_manager\band_manager\band.h(44): could be 'bool Band::operator ==(const std::string &)'
while trying to match the argument list '(Band, const Band)'
c:\programas\microsoft visual studio 9.0\vc\include\list(927) : while compiling class template member function 'void std::list<_Ty>::remove(const _Ty &)'
with
[
_Ty=Band
]
c:\documents and settings\francisco\os meus documentos\visual studio 2008\projects\band_manager\band_manager\manager.h(26) : see reference to class template instantiation 'std::list<_Ty>' being compiled
with
[
_Ty=Band
]
The problem is when i try to use the remove():
void Manager::remove_band(const Band & bd)
{
available_bands_list.remove(bd);
}
I think I have the operator overloading right:
bool Band::operator == (const string & text)
{
return name == text;
}
Can anyone help me please?
Thank you!
|
|
|
|
|
FrankMookie wrote: I think I have the operator overloading right:
Not really no: your operator receives a std::string and the list will compare Band objects. So you need to provide an operator which receives a Band:
bool Band::operator == (const Band& other)
|
|
|
|
|
thank you so much for your help! It worked.
|
|
|
|
|
Hi all,
I am making an updating system for several softwares, now what I want to do is that my updating system should be able to download updates simultaneously. I have all the download functions sorted out I just dont know how to do the multiple downloads. Please advise me on what to do. This is my function btw:
bool DownloadFile(Updates* prd)
{
bool result = false;
DownloadThread((void*)prd);
return result;
}
Thanks,
Jayjay
|
|
|
|
|
May be your code is working correctly but why do you return false everytime. What is the implementation for DownloadThread?
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hi,
Yes its working correctly I have no problems with it whatsoever I just want to know how to implement multithreading. DownloadThread is just a function that downloads from a link.
thanks,
Jayjay
|
|
|
|
|
You can start two or n number of threads. I don't think you would need to synchronize the threads, you can call the function with different parameters to allow downloading of multiple files.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
When I use CreateIconFromResource to create cursor from rc file(.ani file),some .ani files succeeds,some fails.
the code like this:
HINSTANCE hInst=AfxGetInstanceHandle();
HRSRC hRes=FindResource(hInst,MAKEINTRESOURCE(nID),"ANICURSORS");
DWORD dwSize=SizeofResource(hInst,hRes);
HGLOBAL hGlob=LoadResource(hInst,hRes);
LPBYTE pBytes=(LPBYTE)LockResource(hGlob);
HCURSOR hCursor=(HCURSOR)CreateIconFromResource(pBytes,dwSize,FALSE,0x00030000);
Who can give me some advice,thank you!
当我用CreateIconFromResource函数从资源文件中提取ani文件来创建cursor时,有的ani文件能成功,有的会失败,GetLassErr返回为0,什么原因,该怎么解决,谢谢!
|
|
|
|
|
What is the error code? Check the error code by calling GetLastError() or by adding @err,hr to the watch window.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|