![]() ![]() ![]() The applications executes, displaying a form with two diagonal crossing lines.Enter the following event handling code:Ĭanvas->LineTo( ClientWidth, ClientHeight ).In the Object Inspector, double-click the Form1 OnPaint event on the Events tab.The Code Editor displays with the cursor in the TForm1.FormPaint event handler block.In the form view, click the form, if necessary, to display Form1 in the Object Inspector.Choose File > New > Other > Delphi Projects or C++Builder Projects and double-click the VCL Forms Application icon.The VCL Forms Designer is displayed.To create a VCL form and place an image on it Code the form's OnPaint event handler to draw the straight lines.This procedure draws two diagonal straight lines on an image in a VCL form. Now it's very late, and I have to go.Go Up to How To Build a VCL Forms Application with Graphics The code above needs further testing, but is probably in the right direction. R.Top := Rect.Top + (Rect.Bottom - Rect.Top - size.cy) div 2 GetThemePartSize(h,, BP_CHECKBOX, CBS_CHECKEDNORMAL, nil, TS_DRAW, size) Size.cy := GetSystemMetrics(SM_CYMENUCHECK) Size.cx := GetSystemMetrics(SM_CXMENUCHECK) If (odSelected in State) and not UseThemes thenĭrawFocusRect(, ShrinkRect(r, -2, 6, 1, 1)) ĭT_SINGLELINE or DT_VCENTER or DT_LEFT or DT_END_ELLIPSIS) H := OpenThemeData(Sender.Handle, 'LISTVIEW') ĭrawThemeBackground(h,, LVP_GROUPHEADER, IfThen(odSelected in State, LVGH_CLOSESELECTED, LVGH_OPENHOT), ShrinkRect(r, -2, 6, 1, 1), nil) If not IsWindowVisible(ListView_GetEditControl(Sender.Handle)) then Set OwnerDraw := true, remove your OnCustomDrawSubItem routine, and add procedure TForm15.ListView1DrawItem(Sender: TCustomListView Item: TListItem įunction ShrinkRect(const r: TRect const X0, X1, Y0, Y1: integer): TRect inline įor i := 0 to TListView(Sender).Columns.Count - 1 do One relatively simple way to get rid of this bug is to owner-draw the entire item. Procedure TForm15.ListView1CustomDrawSubItem(Sender: TCustomListView Item: TListItem SubItem: Integer State: TCustomDrawState var DefaultDraw: Boolean) ĭx := (-GetSystemMetrics(SM_CXMENUCHECK)) div 2 UPDATE 2, following the Andreas suggestions the listview now look better, but still shown the black box UPDATE 1 : thanks to the sertac recomendattion setting the DefaultDraw value now the checkboxes are shown, but the another columns looks awfull. please don't suggest which use a thrid party component, i want use the TlistView control. The listview is in vsReport mode and had 3 columns, i want put the checkbox in the third column. DrawText(, StringGrid1.Cells, length(StringGrid1.Cells), r, DT_SINGLELINE or DT_VCENTER or DT_LEFT or DT_END_ELLIPSIS) īut i fail miserably in my attempt to draw a checkbox :(, can someone point me in the right direction to draw the checkbox in the listview, (the code does not draw any checkbox in the listview). r := Classes.Rect(r.Right + PADDING, Rect.Top, Rect.Right, Rect.Bottom) ![]() R.Top := Rect.Top + (Rect.Bottom - Rect.Top - s.cy) div 2 ĭrawThemeBackground(h,, BP_CHECKBOX, IfThen(CompareText(Item.SubItems,'True')=0, CBS_CHECKEDNORMAL, CBS_UNCHECKEDNORMAL), r, nil) ĭrawFrameControl(, r, DFC_BUTTON, IfThen(CompareText(Item.SubItems,'True')=0, DFCS_CHECKED, DFCS_BUTTONCHECK)) GetThemePartSize(h,, BP_CHECKBOX, CBS_CHECKEDNORMAL, nil, TS_DRAW, s) H := OpenThemeData(Sender.Handle, 'BUTTON') S.cy := GetSystemMetrics(SM_CYMENUCHECK) S.cx := GetSystemMetrics(SM_CXMENUCHECK) Rect.Right :=Rect.Left+ įillRect(, Rect, GetStockObject(WHITE_BRUSH)) ![]() I need to draw a checkbox in a particular column in a TListView, so i check this question How can I setup TListView with CheckBoxes in only certain columns? and in the accepted answer suggest use the method described in this another question How to set a Checkbox TStringGrid in Delphi?, now porting that code to work with a ListView i come with this : procedure TForm15.ListView1CustomDrawSubItem(Sender: TCustomListView Item: TListItem SubItem: Integer State: TCustomDrawState var DefaultDraw: Boolean) ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |