http://cbuilder.borlandforum.com/impboard/impboard.dll?action=read&db=bcb_tip&no=1161
내용으로 대체합니다.
KDHS 님이 쓰신 글 :
: 본 코드는 ListView SubItem 영역에 버튼을 생성 후 삭제 하는 코드입니다.
:
: 델파이 코드를 씨빌더 코드로 변환중인데 잘 안되는 부분이 있네요...
:
: 델파이 문법이 헷갈리는게 좀 있어서 ...
:
: 아이템 삭제 시에 델파이로는 아이템 라인 전체가 삭제 되는데
:
: 씨빌더에서는 현재 해당 아이템만 삭제되고 서브아이템은 살아 있네요...
:
: 잘못된 점 좀 알려주실분.....계시나요??
:
:
:
:
: procedure TfmMain.do_MoveListViewControls(IdxOfDeleted: Integer);
: var
: Control: TControl;
: i: Integer;
: begin
: for i := IdxOfDeleted to ListView.Items.Count - 1 do
: begin
: Control := TControl(ListView.Items.Item[i].Data);
: Control.Top := Control.Top -
: (Control.BoundsRect.Bottom - Control.BoundsRect.Top);
: end;
: end;
:
: procedure TfmMain.ButtonDeleteClick(Sender: TObject);
: var
: i: Integer;
: begin
: if ListView.Selected = nil then
: Exit;
:
: ListView.Items.BeginUpdate;
: try
: for i := ListView.Items.Count - 1 downto 0 do
: begin
: if not ListView.Items[i].Selected then
: Continue;
:
: TControl(ListView.Items[i].Data).Free;
: ListView.Items[i].Delete;
: do_MoveListViewControls(i);
: end;
: finally
: ListView.Items.EndUpdate;
: end;
: end;
:
:
:
:
: void __fastcall TForm2::do_MoveListViewControls(int IdxOfDeleted) {
: TControl *Control;
: for (int i = IdxOfDeleted; i < ListView->Items->Count; i++) {
: // Control = TControl(ListView->Items->Item[i]->Data);
: ListView->Items->Item[i]->Data = Control;
: Control->Top = Control->Top - (Control->BoundsRect.Bottom - Control->BoundsRect.Top);
: }
: }
:
: void __fastcall TForm2::ButtonDeleteClick(TObject *Sender) {
: TControl *Control;
: if (ListView->Selected == NULL) {
: exit;
: }
: // ListView->Items->BeginUpdate();
:
: try {
: for (int i = 0; i < ListView->Items->Count; i++) {
: if (ListView->Items->Item[i]->Selected) {
: ListView->Items->Item[i]->Data = Control;
: ListView->Items->Item[i]->Delete();
: do_MoveListViewControls(i);
: }
: }
: }
:
: catch (...) {
: ListView->Items->EndUpdate();
: }
: }
:
:
:
:
|