|
LiYS wrote: How would you define a stack underflow?
Attempting to "pop" an item from an empty stack. Like Stephen said, you ain't popping, so you ain't underflowing.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have seen MSDN for the above but what is the real reason for the usage of GetBuffer/ReleaseBuffer? In the below code the value i comes out to be 3 then what is the intent of 1024 as the arguement in GetBuffer. If I change the value to 2 i still comes out to be 3. Please explain.
CString s;<br />
s = "abc";<br />
LPTSTR p = s.GetBuffer( 1024 );<br />
int i = _tcslen((LPCTSTR)p);<br />
_tcscpy(p, _T("abc"));
ASSERT( s.GetLength() == 3 );
s.ReleaseBuffer();
|
|
|
|
|
When you call GetBuffer with 1024, 1024 bytes will be allocated as an internal buffer but your string is still 3 characters long (it is still "abc", no matter how large the buffer is).
It is the same principle as:
char szBuf[1024];<br />
strcpy(szBuff,"abc");<br />
int Size = strlen(szBuff);
|
|
|
|
|
The function pair exists because CString object deallocates/reallocates internally its buffer.
The argument supplied to GetBuffer is the minumum warranted buffer size NOT the stringh length.
GetBuffer is used whenever you want to perform operation directly with the CString buffer (usually you don't have to do it). The call to GetBuffer gives to you, at least, the requested memory size. On the other hand, you need to call ReleaseBuffer to tell the CString object you've finished with you buffer raw operations, i.e. CString object can freely (and transparently) internally reallocates memory as needed.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
|
you'd better get to work on this -- so we can see the result!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Hi,
Can anybody tell me how to convert PLVOID[] into CSTRING?
Its urgent.
Regards
Atul
Atul Bhatt
|
|
|
|
|
You can't.
If the LPVOID points to character data, you can create a CString from that data. You'd need
to know the type of the characters (char or wchar_t) so the appropriate constructor is called.
Something like these should work:
// LPVOID pVoid = ...;
// pVoid points to unicode characters, null terminated
CString str((wchar_t *)pVoid);
// pVoid points to ANSI characters, null terminated
CString str((char *)pVoid);
If the character data is not null-terminated and you know the length, there's CString constructors
which take a length (int) as a second parameter.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I need to add a new message handler for a dialog box... but its giving "Cannot add a new member"...
...
i tried deleting clw file and the rebuliding it.but doesnt work.
Also all my classes are not getting displayed in class wizard.
Plz help me.
Thanks n Advance
|
|
|
|
|
How many controls do you have on the form?
|
|
|
|
|
I think you must add some member in header file , for example : in following
code , when you want add double click to add a new member in dialog, the
"Cannot add new member " message will be occur. please move the
private:
int m_iValue
below the ADX_DATA will be fixed!
// Dialog Data
//{{AFX_DATA(CDlg)
enum { IDD = IDD_DIALOG };
CButton m_ABC;
CRichEditCtrl m_RichEdit;
private:
int m_iValue
//}}AFX_DATA
Also this inidicates that the file is readonly, or that perhaps the various magic comments have
been corrupted
akt
|
|
|
|
|
I think you must add some member in header file , for example : in following
code , when you want add double click to add a new member in dialog, the
"Cannot add new member " message will be occur. please move the
private:
int m_iValue
below the ADX_DATA will be fixed!
// Dialog Data
//{{AFX_DATA(CDlg)
enum { IDD = IDD_DIALOG };
CButton m_ABC;
CRichEditCtrl m_RichEdit;
private:
int m_iValue
//}}AFX_DATA
Also this inidicates that the file is readonly, or that perhaps the various magic comments have
been corrupted
akt
|
|
|
|
|
Thanks 4 that....
but i dont have any member variable of class scope.. so the above doesn't fit the solution.
how to display all classes what i have in ma project in class wizard
Note : All my classes where not created using class wizard
Thanks in Advance.
Regards.
Arshad.
"I am just loving this....."
|
|
|
|
|
You can also declare your variables manualy.
|
|
|
|
|
hello,
I want to create a dynamic Bitmap (size + data), what is the way doing this?
I try to use CreateBitmap without big success.
Thanks.
|
|
|
|
|
Can you more explain about create a dynamic Bitmap
|
|
|
|
|
Please use the following code if u can use MFC.
UINT BITS_IN_A_BYTE = 8;
CBitmap BlankBmp;
BYTE *pbyBits = 0;
SIZE_T nBits;
nBits = m_uImgWidth * m_uImgHeight;
pbyBits = new BYTE[nBits + UNITY];
if( 0 == pbyBits )
{
return;
}
// Fill it with Black RGB values (R=0, G=0, B=0)
ZeroMemory( pbyBits, nBits + UNITY );
BlankBmp.CreateBitmap( m_uImgWidth, m_uImgHeight,
1, BITS_IN_A_BYTE, pbyBits );
delete[] pbyBits;
akt
|
|
|
|
|
Using Win32 APIs or MFC? Do you want a DIB, DDB, or a DIB section?
How many bits per pixel?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
What is the diffrent between the above ?
I need 32 bits per pixel (or 24).
Thanks
|
|
|
|
|
Hi,
I have one application which needs to notified whenever the my windows system was locked or unlocked.
so, can you plz give me the solution for this problem as soon as possible.
Thanks & Regards
swamy
|
|
|
|
|
Hi,
use "WTSRegisterSessionNotification()" to register your window to receive
the notification "WM_WTSSESSION_CHANGE" which has "WTS_SESSION_LOCK" & "WTS_SESSION_UNLOCK" parameter to identify that.
Best Regards
Raj
|
|
|
|
|
Thank U Very Much Raj.. for giving this solution !!
cheers
swamy..
|
|
|
|
|
swamy Narasimha wrote: I have one application which needs to notified whenever the my windows system was locked or unlocked.
Implement the ISensLogon interface. The DisplayLock() and DisplayUnLock() methods are of interest to you.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hi,
i am new to dll. i have developed a DLL with menu resources....
i want use that resources, which means if i call any one of the function from my exe ,it should call that DLL.... then particular menu in that DLL have to load in my exe application.....how to do that......?
please if any one know this,reply me...
Thanks in advance
|
|
|
|
|
D.Mani wrote: ,it should call that DLL.... then particular menu in that DLL have to load in my exe application.....how to do that......?
AfxGetResourceHandle, AfxSetResourceHandle and AfxFindResourceHandle
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|