 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Curtis Richards Guest
|
Posted: Tue Jun 28, 2005 6:22 pm Post subject: Help with mousedown |
|
|
I am using the following code to add a checkbox into
a certain column of my listview. I can't seem to get
the checkbox to check using the OnMouseDown()
event.
// draw the checkbox in the listview
DrawFrameControl(ListView1->Canvas->Handle, &Rect, DFC_BUTTON,
DFCS_BUTTONCHECK);
void __fastcall TForm1::ListView1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
TListItem* Item = ListView1->GetItemAt(X, Y);
THitTests HitTests = ListView1->GetHitTestInfoAt(X, Y);
if((Item) && (HitTests.Contains(htOnButton)))
ShowMessage("Checkbox was clicked on");
}
//---------------------------------------------------------------------------
If i use htOnStateItem the message will fire whenever i click on the
row. But i only want it to check the checkbox whenever i click on
the checkbox, and not the entire row.
One more thing, how do you actually check and uncheck the checkbox?
Thanks.
Curtis
|
|
| Back to top |
|
 |
Curtis Richards Guest
|
Posted: Wed Jun 29, 2005 8:38 pm Post subject: Re: Help with mousedown |
|
|
Can't seem to get an answer to that question, let me try a
different procedure.
This is my code to draw the items on the listview.
void __fastcall TForm1::ListView1DrawItem(TCustomListView *Sender,
TListItem *Item, TRect &Rect, TOwnerDrawState State)
{
if( State.Contains(odSelected) )
{
ListView1->Canvas->Brush->Color = clHighlight;
ListView1->Canvas->Font->Color = clHighlightText;
}
else
{
ListView1->Canvas->Brush->Color = ListView1->Color;
ListView1->Canvas->Font->Color = ListView1->Font->Color;
}
ListView1->Canvas->FillRect(Rect);
DrawCheckBox(&Status, Rect);
}
Then i use an imagelist to place a bitmap in the listview, there are two
bitmaps,
one unchecked and one checked.
void __fastcall TForm1::ListView1MouseDown(TObject *Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
if(Button == mbLeft)
{
if(ListView1->GetHitTestInfoAt(X, Y).Contains(htOnStateIcon))
{
// clicking on the check box, do something to toggle the
check...
TListItem *Item = ListView1->GetItemAt(X, Y);
if(Item)
{
ListView1->UpdateItems(Item->Index, Item->Index);
ShowMessage("Checkbox Checked!!");
}
}
}
}
void TForm1::DrawCheckBox(Status* Info, TRect &Rect)
{
Rect.Left += 100; //ListView1->Columns->Items[3]->Width;
int ImgWidth = ImageList2->Width;
int ImgHeight = ImageList2->Height;
int X = (Rect.Left + ((Rect.Width() - ImgWidth) / 2));
int Y = (Rect.Top + ((Rect.Height() - ImgHeight) / 2));
ImageList2->Draw(ListView1->Canvas, X, Y, Info->Processing, true);
}
What do i have to do to make the checkbox check and uncheck? This is
getting
pretty tough.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|