Solved

VirtualDrawTree and Picture loading.

Posted on 2001-07-18
10
789 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

895 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

19 Experts available now in Live!

Get 1:1 Help Now