|
|
Handle the NM_CUTOME draw message and put the following code inside it.
void TreeCtrlEx::OnCustomDraw( NMHDR* pNMHDR_i, LRESULT* pResult_o )
{
NMTVCUSTOMDRAW* pLVCD = reinterpret_cast<nmtvcustomdraw *="">( pNMHDR_i );
NMCUSTOMDRAW &nMcd = pLVCD->nmcd;
*pResult_o = CDRF_DODEFAULT;
switch( nMcd.dwDrawStage )
{
case CDDS_PREPAINT:
// Item prepaint notification.
*pResult_o = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
{
// Set the color of the text according to its state.
HTREEITEM nRow = reinterpret_cast< HTREEITEM >( nMcd.dwItemSpec );
if( CDIS_SELECTED == ( nMcd.uItemState & CDIS_SELECTED ))
{
pLVCD->clrText = clrSelText;// Selected text color
pLVCD->clrTextBk = clrSelBk;// Selceted backgroung
}
else
{
pLVCD->clrText = clrNormal;// text color in normal state
pLVCD->clrTextBk = clrBk// bakck ground color in normal state
}
// Allow it to do the default painting.
*pResult_o = CDRF_DODEFAULT;
break;
}
default:
*pResult_o = CDRF_DODEFAULT;
break;
}
}
|
|
|
|
|
Hi,
I have assigned a huge string of about 32800 chars to CString object, but i am getting this "error C2026: string too big, trailing characters truncated", does any one know how can i resolve it, or is there any work around?
Best Regards,
Mushq
Mushtaque Ahmed Nizamani
Software Engineer
Ultimus Pakistan
"English is my second language, so please don't mind if i do some grammatical or spelling mistakes in my messages."
|
|
|
|
|
Can you tell me why you want to have this string? and what is it?
|
|
|
|
|
There is a compiler limit on string literals of 2048 characters, so this has nothing to do with CString .
"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
|
|
|
|
|
How do you create this string in the First Place. You hardly typed it by hand!
Anyways:
Try CString MyString;
MyString.GetBuffer(32000);
The problem occurs with items such as strings which are zero terminated. If the compiler does not find a 0 after a reasonable number of chars, ( and 2048 is a reasonable limit in most cases)the compiler decides that there must be a syntax error (forgotten a terminating ") etc.
LateNightsInNewry
|
|
|
|
|
I have done an application in which i need to interact with 2 other systems using RS 232 cables.
Individually i am able to communicate with either systems but facing problems when executed and trying to interact with 2 systems simultaneously. The main reason for this is the I am using a Pentium 3 processor which is a must for me.Can anyone help me out to overcome this problem in pentium 3 processor.
NAVEEN
|
|
|
|
|
naveen27gupta wrote: The main reason for this is the I am using a Pentium 3 processor
Why the above is the main reason?
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.
|
|
|
|
|
Your not trying to just connect the PCs together like this are you?
PC 1 <---\
PC 2 <---|
PC 3 <---/
Just connect all 3 ports together... RxD to RxD to RxD etc.
|
|
|
|
|
A simple question.
I define an array.How to calculate its length?
int[] arInt = { 1, 2, 3 ,4, 5 };
Thanks in advance.
|
|
|
|
|
Peter, Chan wrote: int[] arInt = { 1, 2, 3 ,4, 5 };
The correct syntax should be:
int arInt[] = {....
int nSize = sizeof(arInt) / sizeof(int);
this is this.
|
|
|
|
|
Then if it is a array of string.Should I write like this.
char * arLang[] = {"english", "chinese"};
int nSize = sizeof(arLang) / sizeof(char);
|
|
|
|
|
Nope
Then you get the number of char's in the array, not the number of strings
You can't count it this way, because each string has a different lenght.
You can determine the length of arLang, then loop on it and count the occurence of \0 (End of a String)
So you get the number of strings in the array, if i tell no mistakes
Good luck
|
|
|
|
|
No, it can't be done with multi-dimensional arrays.
You can only do it with single-dimensional arrays like:
char arLang[] = {"english"};
And the length will be 8 bytes.
And whenever you get the operator * anywhere, you just can't be sure of the size.
But you can write:
int nSize1 = strlen(arLang[0]) + 1;<br />
int nSize2 = strlen(arLang[1]) + 1;
etc.
this is this.
|
|
|
|
|
Peter, Chan wrote: int nSize = sizeof(arLang) / sizeof(char);
Mistake!
change as follows:
int nSize = sizeof(arLang) / sizeof(char *);
or (better):
int nSize = sizeof(arLang) / sizeof(arLang[0]);
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.
|
|
|
|
|
Peter, Chan wrote: I define an array.How to calculate its length
Did you have a look at the sizeof()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
It depends on what you want. If the array is dynamically declared, i.e. You used 'malloc', there is no knowing, unless if you build in your own scheme of determining these things. At any rate, the size of the array is known to you, because you had to give the size to the malloc function. In these cases, you need to devine a scheme to pass this knowledge on to where it is needed.
in statically declared arrays, you can use the sizeof() operator to get the size of an array in bytes. But, still again, beware and look at the language definition.
i.e.:
char * Arr[]={"First Item","Second Item"};
This is an array of pointers to character strings. Arr contains two 4-Bit Items ( or 2 8-Bit items in a 64 bit Compiler), namely the Addresses of the two strings, "First Item" and "Second Item". So in the above example,
sizeof(ARR) would always give 8 ( or 16 in a 64 bit Compiler environment). If you need to know wat's needed to store the structure ans it's data, you need:-
size_t GetTotalDataSize(){
size_t NrOfItems= sizeof(Arr)/sizeof(char*);
size_t TotalSize=sizeof(Arr);
for(int i=0;i<NrOfItems;i++)TotalSize+=(strlen(Arr+i)+1);
return TotalSize;
}
LateNightsInNewry
|
|
|
|
|
Your description is very clear. I now know clearly how to use sizeof().
I still just have one question.
Just as your sample.
char * Arr[]={"First Item","Second Item"};
Do I need to delete Arr when it is useless.
<br />
delete Arr[0];<br />
delete Arr[1];
|
|
|
|
|
Peter, Chan wrote: Do I need to delete Arr when it is useless.
In this case, no. Since you did not allocate the strings using new , you do not have to free them using delete .
|
|
|
|
|
I've got a bitmap on a button and I want the user to be only able to click the area of the button that is covered by the bitmap.
For circular bitmaps I've used the following code:
CRect button_rect ;
HRGN rgn ;
button->GetClientRect ( &button_rect ) ;
rgn = CreateEllipticRgn( 0,
0,
button_rect.Width(),
button_rect.Height() );
button->SetWindowRgn ( rgn,
TRUE ) ;
However I've got a bitmap that has a rectangle that is diagonal across the bitmap, does anyone know how I can create a HRGN object with the points for the diagonal rectangle.
TIA,
|
|
|
|
|
I think you can use CreatePolygonRgn(...)
Also, you can use the CRgn wrapper instead of HRGN:
CRgn rgn;<br />
CPoint pt[3];<br />
pt[0].x = 10;<br />
pt[0].y = 10;<br />
pt[1].x = 100;<br />
pt[1].y = 100;<br />
pt[2].x = 10;<br />
pt[2].y = 100;<br />
<br />
rgn.CreatePolygonRgn(pt,3,ALTERNATE);
this is this.
|
|
|
|
|
thanks for your reply, got it semi working using this just need to get my polygon region the right shape/size now!
cheers,
|
|
|
|
|
I cant get SACL structure of a file , however i call a function : Privilege(SE_SECURITY_NAME,TRUE);
How can i get sacl ??
BOOL Privilege(LPTSTR pszPrivilege, BOOL bEnable)
{
HANDLE hToken;
TOKEN_PRIVILEGES tp;
//
// obtain the token, first check the thread and then the process
//
if (!OpenThreadToken(GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, TRUE, &hToken)){
if (GetLastError() == ERROR_NO_TOKEN){
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return FALSE;
}
else
return FALSE;
}
//
// get the luid for the privilege
//
if (!LookupPrivilegeValue(NULL, pszPrivilege, &tp.Privileges[0].Luid))
return FALSE;
tp.PrivilegeCount = 1;
if (bEnable)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
//
// enable or disable the privilege
//
if (!AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES)NULL, 0))
return FALSE;
if (!CloseHandle(hToken))
return FALSE;
return TRUE;
}
|
|
|
|
|
Hi all,
Lets say one has a struct like: And this struct has data in it. Is it possible to empty the struct without using a loop (to clear out each of the variables data in the struct?)
#define BUF_SIZE 100
struct fee
{
char bufOne[128];
char bufTwo[128];
}FOO[BUF_SIZE];
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
::ZeroMemory(&Foo[0], sizeof(fee) * BUF_SIZE);
or
memset(&FOO[0], 0, sizeof(fee) * BUF_SIZE);
Manish Rastogi
|
|
|
|