TVirtualDrawtree

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

i looked into this thats moved selected items , i need to move up where subitem = myid

also i added tpanel with tshape and set them to visible and adding button and this is the code of what i did

Kod: Tümünü seç

procedure Ttestthreading.streamClick(Sender: TObject);
begin
if stream.Caption = 'stream' then
begin
stream.Caption := 'stopstream';
panel2.Visible := true;
//start stream
end else
if stream.Caption = 'stopstream' then
begin
stream.Caption := 'stream';
panel2.Visible := false;
//stopstream
end;
end;
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

- On the screencap, is there two different client with same nick "mia", isn't it...? Because, you don't need to see yourself on your own client... I excluded client itself with a simple if statement.

- You know which item you want to move UP.. First item number is (0) you know this too... So is there any problem to move up ?!

I gave you a link about TListView Item movement above...

Kod: Tümünü seç

procedure ExchangeItems(lv: TListView; var i, j: Integer);
var
  tempLI: TListItem;
begin
  lv.Items.BeginUpdate;
  try
    tempLI := TListItem.Create(lv.Items);
    tempLI.Assign(lv.Items.Item[i]);
    lv.Items.Item[i].Assign(lv.Items.Item[j]);
    lv.Items.Item[j].Assign(tempLI);
    tempLI.Free;
  finally
    lv.Items.EndUpdate
  end;
end;
Just say

Kod: Tümünü seç

ExchangeItems( ListView1, 1, 0);
to move the second item to first line. You just put your itemIndex to the second param which exists (1) value ...


Panel thing is good. It will work. Just be carefull that, while the transaction do not accept any GETLIST event, because it will change the Item quene again. After that you automaticaly update it.
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

i tried this i got this error in compiler

Kod: Tümünü seç

[dcc32 Error] mainunit.pas(372): E2033 Types of actual and formal var parameters must be identical
so i removed the var from parmeter to get it work

also i have to move item number ? i cant move items by there client id ? because this moved item by default index order and possibly maybe the client who showing to me dont have the same index order here is image example

Resim

also the shape inside panel looks not near to the subitem needed

here is the code

Kod: Tümünü seç

procedure Ttestthreading.streamClick(Sender: TObject);
begin
if stream.Caption = 'stream' then
begin
stream.Caption := 'stopstream';
panel2.Visible := true;
ExchangeItems( ListView1, 1, 0);
//start stream
end else
if stream.Caption = 'stopstream' then
begin
stream.Caption := 'stream';
panel2.Visible := false;
//stopstream
end;
end;
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

i been try all day to found equation its seems i totally fail , here what i try

Kod: Tümünü seç

procedure Ttestthreading.streamClick(Sender: TObject);
begin
if stream.Caption = 'stream' then
begin
stream.Caption := 'stopstream';
panel2.Visible := true;
ExchangeItems( ListView1, 1, 0);
 SendCommandWithParams( TCPClient, 'Startstream', IntToStr(UniqueID) + Sep);
//start stream
end else
if stream.Caption = 'stopstream' then
begin
stream.Caption := 'stream';
panel2.Visible := false;
//stopstream
SendCommandWithParams( TCPClient, 'Stopstream', IntToStr(UniqueID) + Sep);
end;
end;
the command send unique id and it should show the username and tha tpanel on top but its show index by default
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

You must free your mind and make free the magic of your brain.

- I only show you the way, you must configure it by your needs. I gave you I sample with

Kod: Tümünü seç

ExchangeItems( ListView1, 1, 0);
- Why do you use it static ? item number (1) is only for example purpose you must be know it. All users list may be different this is naturally. You must find the index from UniqueID then move that item to the first, so the index of (0). OR you just use ListView's selected Item Index to do this.

Kod: Tümünü seç

ExchangeItems( ListView1, ListView1.Selected.Index , 0);
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

the problem is using selected item index will not help i will show that iam streaming to myself and to other client , so selected item will work only for me , grabing item index from unique id this is what i hardly cannot do i tried things like search for each sub item where my id = unique id to get index of my sub item unique id here is the code

Kod: Tümünü seç

function TForm1.FindListIndex(const TextToMatch: string): Integer;
var
  i, j: Integer;
begin
  for i := 0 to ListView1.Items.Count - 1 do
    for j := 0 to ListView1.Items[i].SubItems.Count - 1 do
      if ListView1.Items[i].SubItems[j] = TextToMatch then
        Exit(i);
  Result := -1;
end;
but it does not get my current index number to be abl to send it
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

You allready move the item first, don't you?
Then your (active clients) avatar must beside the first item.
There is only one variable exists, that is the selected item.
Your avatar is allready been selected before. Then draw it to the item (0)
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

what i tried to do is nested loop , i didnt sleep from yesterday to try to have equation the last hope by showing example of the last sentences
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

so, what is the point? Are you surrender or going ahead...
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

i got equation finally , now i can send command with my index to other client using variable R here is the code for others help

Kod: Tümünü seç

procedure Ttestthreading.streamClick(Sender: TObject);
var
i,R : integer;
begin
if stream.Caption = 'stream' then
begin
 for i := 0 to ListView1.Items.Count-1
 do if ListView1.Items[i].SubItems[3] = IntToStr(UniqueID)
then
begin
R:= listview1.Items[i].Index;
end;
stream.Caption := 'stopstream';
panel2.Visible := true;
ExchangeItems( ListView1, R, 0);
 SendCommandWithParams( TCPClient, 'Startstream', IntToStr(UniqueID) + Sep);
//start stream
end else
if stream.Caption = 'stopstream' then
begin
stream.Caption := 'stream';
panel2.Visible := false;
//stopstream
SendCommandWithParams( TCPClient, 'Stopstream', IntToStr(UniqueID) + Sep);
end;
end;
i didnt sleep from yestrday i can go to sleep now .
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

congratulations, good to you.
you deserved to rest.
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

thank you mrmarman i couldnt do that without you
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

you did it totally yourself. Success is yours.
Best regards.
Resim
Resim ....Resim
Kullanıcı avatarı
mia
Üye
Mesajlar: 239
Kayıt: 17 Nis 2015 02:18

Re: TVirtualDrawtree

Mesaj gönderen mia »

thank you mrmarman , iam trying to align the tpanel to the bottom of selected item height

as this example

Resim

things i have tried

Kod: Tümünü seç

procedure Ttestthreading.streamClick(Sender: TObject);
var
  i, R: integer;
begin
  if stream.Caption = 'stream' then
  begin
    for i := 0 to ListView1.Items.Count - 1 do
      if ListView1.Items[i].SubItems[3] = IntToStr(UniqueID) then
      begin
        R := ListView1.Items[i].Index;
        panel2.Top := ListView1.Items[i].Position.Y;// this what i try mrmarman
      end;
 
end;
بِسْمِ اللهِ الرَّحْمنِ الرَّحِيمِ
in god i trust with every movement i do
graduated student and looking for knowledge
Kullanıcı avatarı
mrmarman
Üye
Mesajlar: 4741
Kayıt: 09 Ara 2003 08:13
Konum: İstanbul
İletişim:

Re: TVirtualDrawtree

Mesaj gönderen mrmarman »

Hi.

- Think simple please... You are very clever but your huge knowledge shadows your mind...
- You have the best instruments that to get / backup items location. RECT on the DrawItem. Use this.
- if Item.Selected result is TRUE then state is selected. This is what you want. You backup items location on that point.
- Last word, you only need is to make the item selected before

Kod: Tümünü seç

Var
  xSelItemLeft : Integer = 0;
  xSelItemTop  : Integer = 0;

procedure TForm1.ListView1DrawItem(Sender: TCustomListView; Item: TListItem;
  Rect: TRect; State: TOwnerDrawState);
begin
  if Item.Selected then // if selected you backup items location where you want... You only need is to make the item selected before Streaming 
  begin
    xSelItemLeft := Rect.Left + sender.Left + sender.Column[0].Width;
    xSelItemTop  := Rect.Bottom;
    // You may reshape the panel with RECT width/height/column width ext..
  end;
end;

procedure TForm1.streamClick(Sender: TObject);
begin
  if stream.caption = 'stream' then
  begin
    stream.Caption := 'idle';
    Panel1.Visible := False;
  end else
  begin
    if ListView1.Selected = nil then Exit; // if not selected then abort

    stream.Caption := 'stream';
    Panel1.Left := xSelItemLeft;
    Panel1.Top  := xSelItemTop;
    Panel1.Visible := True;
  end;
end;
- The object programming like Chain Reaction Toys you know. Don't forget it...

Resim
Resim
Resim ....Resim
Cevapla