Solved

VirtualDrawTree and Picture loading.

Posted on 2001-07-18
10
781 Views
Last Modified: 2009-12-16
Hi!,

How can i load picture to the Image component at every time when i click Node's image data.

Now i use this code to load images:

procedure TView.VirtualDrawTree1Change(Sender: TBaseVirtualTree;
  Node: PVirtualNode);
var
  Data: PImageData;
  SR: TSearchRec;
  FileName: String;
  Picture: TPicture;
begin
  Data := Sender.GetNodeData(Node);
  ZoomedSizeToOriginal(Sender);
  Picture := TPicture.Create;
  View.Tag:=47;
  if Data <> NIL then
  begin
    FullPathandFileName := Data.FullPath;
    FileName := (Data.FullPath) +  '\' + SR.Name;
    if (SR.Attr and faDirectory <> 0) or CanDisplay(FileName) then
    begin
      Picture.LoadFromFile(Data.FullPath);
      ViewerForm.HorzScrollBar.Range := Picture.Width;
      ViewerForm.VertScrollBar.Range := Picture.Height;
      ViewerForm.ClientWidth := Picture.Width;
      ViewerForm.ClientHeight := Picture.Height;
      ViewerForm.Caption := Data.FullPath + ' - ' +
            Format(' (%d x %d)', [Picture.Width, Picture.Height]);
      ViewerForm.Image1.Picture:=Picture;
      ViewerForm.ClientWidth := Picture.Width;
      ViewerForm.ClientHeight := Picture.Height;
      ViewerForm.HorzScrollBar.Range := Picture.Width;
      ViewerForm.VertScrollBar.Range := Picture.Height;      
      RotatedSizeToOriginal(Sender);
      ViewerForm.Show;
      Picture.Free;
    end;
  end;
end;

But if i change abobe code to OnClick event, OnClick event doesn't include (Sender: TBaseVirtualTree;
  Node: PVirtualNode); those declarations. So if i change original OnClick event to this:

procedure TView.VirtualDrawTree1Click(Sender: TBaseVirtualTree;
  Node: PVirtualNode);
begin

end;

And also required changes to the "type section".
Then compiler complains to me at those changes.
So what can i do?? Because now it loads images every time when clickable content change to another content. And that's not my intention.

Regards Marko
0
Comment
Question by:mhieta
  • 6
  • 4
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6295358
? in a onclick event you could easily use the

ANode := VirtualDrawTree1.GetFirstSelected; like

(from a current project of mine)

  AData := TreeFP.GetNodeData(TreeFP.GetFirstSelected);
  If Assigned(AData) then
  ...

meikl ;-)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6295464
just to ask, whats wrong eith the onchange event,
because it is fired also if the keyboard is used
0
 
LVL 2

Author Comment

by:mhieta
ID: 6295588
Yes it's true that the OnChange event fired when keyboard are used. That is good thing. But when i click with mouse then it not load first selected image but it loads next image just fine. And also when i try to load image what is already selected/loaded then it not load again that same image.

Regards Marko
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 6297277
? happens not to me

maybe your problem is the SR-Var,
for what is it needed,
because there is no search and no reinit/reset/close
0
 
LVL 2

Author Comment

by:mhieta
ID: 6298552
I have changed above code to the:

procedure TView.VirtualDrawTree1DblClick(Sender: TObject);
var
  Data: PImageData;
  SR: TSearchRec;
  FileName: String;
  Picture: TPicture;
begin
  Data := VirtualDrawTree1.GetNodeData(VirtualDrawTree1.GetFirstSelected);
  ZoomedSizeToOriginal(Sender);
  Picture := TPicture.Create;
  View.Tag:=47;
  if Assigned(Data) then
  begin
    FullPathandFileName := Data.FullPath;
    FileName := (Data.FullPath) +  '\' + SR.Name;
.
.
.
.

I have tried also, OnClick Event at this same code but it not worked at all. OnDblClick works fine. Hmm.. this is strange... but if i want to handle files(ex.delete files) this OnDblClick event suits best for that purpose.

Regards Marko
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Author Comment

by:mhieta
ID: 6298553
I have changed above code to the:

procedure TView.VirtualDrawTree1DblClick(Sender: TObject);
var
  Data: PImageData;
  SR: TSearchRec;
  FileName: String;
  Picture: TPicture;
begin
  Data := VirtualDrawTree1.GetNodeData(VirtualDrawTree1.GetFirstSelected);
  ZoomedSizeToOriginal(Sender);
  Picture := TPicture.Create;
  View.Tag:=47;
  if Assigned(Data) then
  begin
    FullPathandFileName := Data.FullPath;
    FileName := (Data.FullPath) +  '\' + SR.Name;
.
.
.
.

I have tried also, OnClick Event at this same code but it not worked at all. OnDblClick works fine. Hmm.. this is strange... but if i want to handle files(ex.delete files) this OnDblClick event suits best for that purpose.

Regards Marko
0
 
LVL 2

Author Comment

by:mhieta
ID: 6298556
Oops, sorry for sending double...
0
 
LVL 2

Author Comment

by:mhieta
ID: 6299637
One thing is that OnDblClick event works under Win98, but not in the Win2k. What i have to change to get OnDblClick working ok??
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6299744
?? can't reproduce your problem,
all works perfect by me, with onchange, onclick and ondblclick
(but i have not win2k)
0
 
LVL 2

Author Comment

by:mhieta
ID: 6304924
I have now removed these unnecessary lines:
{   FileName := (Data.FullPath) +  '\' + SR.Name;
   if (SR.Attr and faDirectory <> 0) or CanDisplay(FileName) then
   begin }

So now it works ok also under Win2k.

BRgrds Marko
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now