Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VirtualDrawTree and Picture loading.

Posted on 2001-07-18
10
Medium Priority
?
852 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 27

Accepted Solution

by:
kretzschmar earned 300 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
 
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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

618 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