|
Hi...I have a dialog box with a tree control that has check-boxes in it. What I need to do is, when any of the check-boxes in the tree control is checked, I need to do some processing, and for now let's just say, I need to put up a messagebox. I added a function for the 'NM_CLICK' message to intercept the left button clicks in the tree control, then I do a 'GetCheck' to see if the button is checked.
When I check the box, the 'GetCheck' function returns a 0 but a checkmark appers in the box. When I uncheck the box, the 'GetCheck' function returns a 1, and the checkmark is removed from the box. So this isn't really helping me figure out when the box is checked and not.
Any help would be greatly appericated.
Here is my code for the 'NM_CLICK'
void CDirectoryCheckDlg::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
{
CPoint pt;
GetCursorPos(&pt);
m_testTree.ScreenToClient(&pt);
UINT uFlags;
HTREEITEM ht = m_testTree.HitTest(pt, &uFlags);
if(ht != NULL)
{
// There is an item under the cursor.
m_testTree.SelectItem(ht);
// See what exactly was under the cursor:
switch(uFlags)
{
case TVHT_ONITEMSTATEICON:
{
// It is the icon (checkbox)
BOOL chkbox = m_testTree.GetCheck(ht);
if(chkbox)
MessageBox("Button is checked");
//CString str;
//str.Format("%d",chkbox);
//MessageBox(str,NULL,NULL);
break;
}
case TVHT_ONITEMBUTTON:
// It is the button
break;
}
}
*pResult = 0;
}
|
|
|
|
|
When the control issues the NM_CLICK notification, it hasn't changed the state of the checkbox yet.
You might try looking at the TVN_ITEMCHANGED [^] notification. Also look at the general tree control article here[^], especially the section entitled Working with state image indexes.
Software Zen: delete this;
|
|
|
|
|
This code works fine, but as I learn more about VC++ I wonder if it is OK. I think index exists only within the function, but I'm not sure if it can be returned to targetPrice without problem. There has been no problem so far, but my program isn't finished yet. (basePrice is global.)
int q = GetIndexForPrice(targetPrice );
...
...
...
int CTradingdemoDlg::GetIndexForPrice(double price)
{
int index;
index = (price - basePrice)/ .0025;
return index;
}
Thanks
|
|
|
|
|
Oliver123 wrote: I think index exists only within the function
Yes but int CTradingdemoDlg::GetIndexForPrice(double price)
and
return index;
is handled by the compiler by "copying" the value from the index variable inside the function into the value of the variable outside the function that receives it "int q".
led mike
|
|
|
|
|
hi guys
Could someone please help me to convert from dword to lpcvoid?
This is my code:
LPCVOID voider;
DWORD copytothis;
lpBaseAddress = FakeBF2Start;
but i get an error when i try that:
error C2440: '=' : cannot convert from 'DWORD' to 'LPCVOID'
(that code is not the entire code just so u no its just pseudo but thats the only part that is causing probs)
Thanks in advance
|
|
|
|
|
Cyclone02 wrote: lpBaseAddress = FakeBF2Start;
Perhaps:
lpBaseAddress = (LPCVOID) &FakeBF2Start;
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks a lot but when i use that code with this :
lpBaseAddress = (lpBaseAddress - (LPCVOID)&RealStart) + (LPCVOID)&FakeStart;
then it does not work it displays this error:
: error C2036: 'LPCVOID' : unknown size
: error C2036: 'LPCVOID' : unknown size
do u no how to fix this?
Thanks
-- modified at 14:33 Saturday 28th October, 2006
|
|
|
|
|
You're trying to do pointer arithmetic on void pointers. The compiler doesn't know the size
of void so it can't add the pointers. You need to use an appropriate pointer type (LPBYTE,
LPWORD, etc.) for the arithmetic then cast the result to a LPCVOID.
Without knowing what types lpBaseAddress, RealStart, and FakeStart are I can't show you example
code
Mark
|
|
|
|
|
LPCVOID lpBaseAddress
DWORD RealStart
DWORD FakeStart
can u please show me an example code as that would be very helpful.
Thanks
|
|
|
|
|
Ok it looks like you're adding/subtracting the VALUE of RealStart/FakeStart, not the address,
right?
lpBaseAddress = (LPCVOID)(((BYTE*)lpBaseAddress - RealStart) + FakeStart);
Subtracting the ADDRESS of RealStart then adding the ADDRESS of FakeStart doesn't make sense
to me so I assume that's what you're doing.
Is that what you had in mind?
Mark
|
|
|
|
|
thanks a lot m8 that worked
|
|
|
|
|
Hello everyone!
I was just wondering this... I have a variable that I want to write to a file that can have only 4 values, so only 2 bits needed... If I can't write plain 2 bits to a file, what's the most "efficient" thing I can use? char ?
Thanks! (and sorry if I'm being teh big n00b... )
Windows Calculator told me I will die at 28.
|
|
|
|
|
A single byte is the smallest size you can write to disk.
"Alot of the people on this forum are incredibly stupid, thinking that the internet is real" Score: 1.0 in the Soap Box
|
|
|
|
|
|
The smallest unit you can write is a WORD (32 bits is the most common WORD size, nowadays). However, if you wrote just a WORD to a hard drive that writes 4K sized blocks, you will have a lot of unutilized space.
|
|
|
|
|
You're thinking of a "CPU word" which is the size of the CPU's integer registers (32 or 64 bits on modern desktop CPUs).
The C/C++ type WORD is always two bytes.
|
|
|
|
|
I guess I am mixing up my words!
Thanks,
Geo
|
|
|
|
|
|
it will write 2 bytes but the minimum block for a file could be 4k or more depending upon how the harddisk was formated, i.e. fat16, fat32, NTFS, etc
-Prakash
|
|
|
|
|
Now THAT explains why Windows Explorer says a file is 211B but it says "Size on Disk: 4,00KB "... You learn something new everyday. Thanks!
Windows Calculator told me I will die at 28.
|
|
|
|
|
Lord Kixdemp wrote: Now THAT explains why Windows Explorer says a file is 211B but it says "Size on Disk: 4,00KB".
exactly .
-Prakash
|
|
|
|
|
Just for clarification, under Windows a WORD is 16 bits, or two bytes. A DWORD is 32 bits, or four bytes.
Software Zen: delete this;
|
|
|
|
|
Hmmm! A WORD to the wise. I think our answers to the posted question is a BIT much.
|
|
|
|
|
Hopefully someone can give me some pointer on how to deal with the following scenario:
I have a project that will be given to 3 clients. Although the core code (about 80%) is the same, some dialogs/resources are different for each client. Should I finish for a client first, then create 2 copies of the project folder and change 20% of each code to accomodate the other 2? This will mean the core 80% is duplicated 3 times, and whenever I fix something, I need to do it 3 times.
Is there a way to do all 3 projects in one folder, sharing the core 80%, but appears as 3 separate projects (3 .dsw's/dsp's) and hopefully 3 projects in SourceSafe?
I would really appreciate it if someone can help me here. Thanks a bunch.
|
|
|
|
|
You could have 3 projects in one solution.
Keep all the common code together in one folder. The 3 projects will all use the same common
code. I keep common code in a separate folder on disk as well as separate folder in the
projects. Files unique to each project (dialog-related/resource files in your case) go to the
usual "Source Files" and "Header Files" project folders.
Mark
|
|
|
|