latest version in Delphi and Lazarus issue

General TRichView support forum. Please post your questions here
Post Reply
snorkel
Posts: 57
Joined: Mon Dec 19, 2005 6:29 am
Location: Milwaukee,WI

latest version in Delphi and Lazarus issue

Post by snorkel »

Hi,
I ported my old app from Delphi 2009 to Lazarus but I am having a issue with a embedded component that shows a image thumbnail and when the user clicks the thumbnail it uses shellexecute in the embedded control to view the image.
The problem is when I do this it corrupts all the menus in my application.
It also does it in the latest Delphi community edition.
The embedded control is from one of your examples and is called imagebutton.pas

If I remove the shellexecute it does not corrupt the menus.


Capture.PNG
Capture.PNG (38.03 KiB) Viewed 18228 times

Code: Select all

procedure TImgButton.open;
var
   tpath,fpath:string;
   outstream:tmemorystream;
begin
      //Save the file to temp directory and use shell execute to open it.
      tpath:=GetTempPath;
      fpath:= format('%s%s',[tpath,ffile_name]);
      outstream:=tmemorystream.Create;
      try
         try
            fstream.Position:=0;
            ZDecompressStream(fstream,outstream);
            outstream.Position:=0;
            outstream.SaveToFile(fpath);
            ShellExecute(0, nil, pchar(fpath), nil, nil, SW_SHOWNORMAL);
         except
               on e:EZDecompressionError do
                  raise exception.Create('TFileButton.open zlib error:'+e.Message);
               on e:Exception do
                  raise;
         end;
      finally
       outstream.Free;
      end;
end;
Sergey Tkachenko
Site Admin
Posts: 17559
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: latest version in Delphi and Lazarus issue

Post by Sergey Tkachenko »

Sorry, I do not remember an example with imagebutton.pas. Are you sure that it is from our examples?

A memory may be corrupted somehow. What's the code of GetTempPath?
snorkel
Posts: 57
Joined: Mon Dec 19, 2005 6:29 am
Location: Milwaukee,WI

Re: latest version in Delphi and Lazarus issue

Post by snorkel »

Hi Sergey,
I was actually this ( I modified it to embedded a image instead of a wav and called the new one timagebutton :

{*******************************************************}
{ }
{ TWavButton }
{ Button playing WAV file on click }
{ }
{ Copyright (c) Sergey Tkachenko }
{ svt@trichview.com }
{ http://www.trichview.com }
{ }
{*******************************************************}
snorkel
Posts: 57
Joined: Mon Dec 19, 2005 6:29 am
Location: Milwaukee,WI

Re: latest version in Delphi and Lazarus issue

Post by snorkel »

the temp dir function just calls GetTempDir in sysutils.

I found that in Delphi and Lazarus if I enable the DPI aware option in the project manager the menu corruption goes away.
With DPI aware disabled it only does the corruption if shellexecute opens a image file. Anything else like a URL, some other file like a word doc etc and it's fine.
This is on windows 7, I will have to try it on windows 10 and see if it does the same thing. I could be that some common DLL is being used that the windows image viewer also uses and it's a bug in the windows image viewer.

Also thanks for porting it to Lazarus, I have my app completely ported over and it works spectacular.
Capture.PNG
Capture.PNG (228.73 KiB) Viewed 18166 times
Post Reply