|
Actually i tried all assignments of CString and insert was one of it.
I tried name =..., name.Format("%s",...
But it doesnt work.
KIRAN PINJARLA
|
|
|
|
|
it's not what i'm asking. how is declared name ?
1. CString name;
2. char* name;
3. char[] name;
4. other...
|
|
|
|
|
its declared as
CString name;
KIRAN PINJARLA
|
|
|
|
|
then, where you wrote
pUser->strName.Insert(0,name); -----******* HERE WHERE IT IS CRASHED
what happens with the following code if you dirrecly affect strName ?? :
ASSERT(pUser != NULL);
pUser->strName = _T("hello");
|
|
|
|
|
The first thing i did was that. It failed there, then i tried differenct ways.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: It failed there
well, i cannot help you much ; i'm pretty sure you don't show us all the code...
|
|
|
|
|
Its going to afx.inl and showing error at
// CString
_AFX_INLINE CStringData* CString::GetData() const
{ ASSERT(m_pchData != NULL); return ((CStringData*)m_pchData)-1; }
showing m_pchData : NULL;
KIRAN PINJARLA
|
|
|
|
|
You have a few problems here. The biggest one is the cause of the problem you see:
kiran.pinjarla wrote: ZeroMemory(pUser, sizeof(USER));
Doing this destroys the memory that CString's constructor worked so hard to set up. Your options here are to either make USER into a class and have its constructor do proper initialization, or to make the CString part of the structure into a CString* (and obviously make sure you create it before using it). The first option would be a better choice:
class User
{
User()
{
m_pPtr = NULL;
m_strData = _T("");
}
private:
MYINTERFACEPTR* m_pPtr;
CString m_strData;
};
kiran.pinjarla wrote: name = BSTRtoStr(bstr);// THIS IS MY FUNCTION
This isn't such a big problem, but it is reinventing the wheel. I'm assuming that bstr is some BSTR value that is passed to this function/area of code somehow. That being the case, the type should be changed from BSTR to _bstr_t (which has a constructor and an explicit cast operator to BSTR). Then, to copy that string to your CString object, you would just do the following:
pUser->SetData((const char*)bstr); // SetData being the accessor for your CString member variable
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
kiran.pinjarla wrote: ZeroMemory(pUser, sizeof(USER));
What's this for?
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Have you tried the following:
#pragma pack(push, 1)<br />
your struct declaration<br />
#pragma pack(pop)
Thanks!
jpyp
|
|
|
|
|
Why dont you just do this???
CString s;
s.Format("%s",::ConvertBSTRToString(BSTR));
ConvertBSTRToString is a standard function that should be available to you.
Chris
|
|
|
|
|
I would like to write my own ICQ client. How can I log on to an ICQ server and process messages?
thanks!
modified 9-Mar-17 17:15pm.
|
|
|
|
|
Hi all,
Is there a way to make a control visible/invisible
at runtime ?
Moreover: may i change the position af a control
at runtime ?
Thanx in advance,
Desmo16.
|
|
|
|
|
Please mention some thing about wat language u r using???
do u mean controls in MFC dialg based application???
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
GetDlgItem(IDC_MY_CONTROL)->ShowWindow(SW_HIDE);<br />
GetDlgItem(IDC_MY_CONTROL)->ShowWindow(SW_SHOW);
|
|
|
|
|
also to move controls
BOOL MoveWindow( int x, int y,int nWidth, int nHeight, BOOL bRepaint = TRUE )
or
SetWindowPos ( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
say this to the OP... i didn't ask the question.
|
|
|
|
|
Whats in my mind is, he can also see the answer from here naaa???
I just want to add my point with your answer.
Dream bigger... Do bigger...Expect smaller
aji
|
|
|
|
|
sure
|
|
|
|
|
Yes you can change the position of a control at runtime.
See MoveWindow()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
See
<br />
MoveWindow(...)
ShowWindow(SW_SHOW or SW_HIDE) for visible or not<br />
|
|
|
|
|
POSITION pos = TouchAreaList->GetHeadPosition();
while (pos != NULL)
{TouchAreaList->GetNext(pos);}
wt next...
i want a seperate pointer to point to a specific node in this list how to do that. pos will traverse alright but i want modify the data in a particular node how to do it???
-- modified at 4:42 Monday 31st July, 2006
|
|
|
|
|
<br />
POSITION pos;<br />
Item *pNode;<br />
<br />
for ( pos = GetHeadPosition(); pos != NULL; )<br />
{<br />
pNode = (Item *)GetNext( pos );<br />
if ( pNode )<br />
{<br />
}<br />
}<br />
cje
|
|
|
|
|
hi
Can someone give me a link which contains the comprehensive list of Format Specifiers for all data types including Double,Byte,LPSTR etc.??
Thanx in advance
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
See MSDN
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|