Recent

Author Topic: Shellexecute and windows photo viewer corrupts all menus in app.  (Read 6414 times)

snorkel

  • Hero Member
  • *****
  • Posts: 817
I have this app that I have not looked at in a long time.
Anyways I compiled it and it uses shellexecute to open a image file and when I do that it corrupts all the menus in the app, the main menu gets messed up the worst and even the popup menus start showing up not attached the app anymore.

Shellexecute launches the image file in the windows photo viewer.  If I put a URL in instead of a path to a image the menu corruption does not happen.  This is on Windows 7.

it also does it in the Delphi community edition.

I put a coinitilize call to see if it was something with com threading or something but that made no difference.  It only does it with the windows photo viewer.

Here is the code:
Code: Pascal  [Select][+][-]
  1. ShellExecute(0, nil, pchar(fpath), nil, nil, SW_RESTORE)
« Last Edit: August 17, 2018, 08:23:21 pm by snorkel »
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

440bx

  • Hero Member
  • *****
  • Posts: 3944
Re: Shellexecute and windows photo viewer corrupts all menus in app.
« Reply #1 on: August 17, 2018, 08:48:11 pm »
Hi there,

Here is something I would try, I'd explicitly set the verb (second parameter.)  Passing nil makes things somewhat unpredictable and dependent on whatever is specified in the registry.

I don't know if that will solve the problem but, it is the first thing I'd try.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Shellexecute and windows photo viewer corrupts all menus in app.
« Reply #2 on: August 17, 2018, 09:00:05 pm »
ok, I will give that a shot.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

wp

  • Hero Member
  • *****
  • Posts: 11856
Re: Shellexecute and windows photo viewer corrupts all menus in app.
« Reply #3 on: August 17, 2018, 09:03:04 pm »
Why don't you do it in the Lazarus way?
Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLIntf;
  3. ...
  4.   OpenDocument(fpath);

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Shellexecute and windows photo viewer corrupts all menus in app.
« Reply #4 on: August 17, 2018, 09:12:35 pm »
Why don't you do it in the Lazarus way?
Code: Pascal  [Select][+][-]
  1. uses
  2.   LCLIntf;
  3. ...
  4.   OpenDocument(fpath);

I tried that already and it does the same thing, on windows Opendocument must call shellexecute.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

snorkel

  • Hero Member
  • *****
  • Posts: 817
Re: Shellexecute and windows photo viewer corrupts all menus in app.
« Reply #5 on: August 17, 2018, 09:14:48 pm »
well, this is weird.  This app was old and if I turn on the newer project option for DPI awareness, guess what?  It does not corrupt the menus.
Why on earth the windows photo viewer would have anything to do with this is super odd.
It's only when the path sent to shellexecute or opendocument is a image, anything else is fine.
***Snorkel***
If I forget, I always use the latest stable 32bit version of Lazarus and FPC. At the time of this signature that is Laz 3.0RC2 and FPC 3.2.2
OS: Windows 10 64 bit

 

TinyPortal © 2005-2018