Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shell integration always open restored window in Windows10 #2322

Closed
JairoMartinezA opened this issue Dec 12, 2019 · 18 comments
Closed

Shell integration always open restored window in Windows10 #2322

JairoMartinezA opened this issue Dec 12, 2019 · 18 comments

Comments

@JairoMartinezA
Copy link

Hi @Alexey-T

I was testing the plugin Explorer Integration and the new shell-dll developed by @dinkumoil, but the result is the same, when I have CudaText in minimized or closed state, after launch the "Open with CudaText" context menu option, it always open the CudaText in restored window. Is there a config to open in Maximized window? as when you open CudaText with icon click?

@Alexey-T
Copy link
Owner

If CudaText was closed in maximized state, it must open maximized- this is ok in separate run but not so with shell dll?

@JairoMartinezA
Copy link
Author

Hi @Alexey-T,
I am doing my testing using this shell-integration-dll:

Result OK - Maximized view:

  1. Open CudaText.
  2. Set window in maximized view.
  3. Close CudaText.
  4. Open file using "Open with CudaText" contextual menu option.
  5. CudaText opens the file in maximized view.

Result OK - Restored view:

  1. Open CudaText.
  2. Set window in restored view.
  3. Close CudaText.
  4. Open file using "Open with CudaText" contextual menu option.
  5. CudaText opens the file in restored view.

Result FAIL:

  1. Open CudaText.
  2. Set window in maximized view if it is in restored view.
  3. Minimize CudaText.
  4. Open file using "Open with CudaText" contextual menu option.
  5. CudaText opens the file in restored view. I expect CudaText in maximized view.

Another result FAIL:

  1. Proceed with all previous steps. CudaText is in restored view.
  2. Maximize CudaText
  3. Minimize CudaText
  4. Open another file using "Open with CudaText" contextual menu option.
  5. The file is opened but CudaText remains minimized.

@Alexey-T
Copy link
Owner

@dinkumoil

procedure TfmMain.UniqInstanceOtherInstance
...
  if WindowState=wsMinimized then
  begin
    WindowState:= wsNormal;
    Application.ProcessMessages;
  end;
...

so app don't know that it was maximized before it was minimized, and makes normal view (restored). can we do something here?

@dinkumoil
Copy link
Contributor

The test cases 3 and 4 (the ones which failed) only fail when I test under Windows 10 x64 v1809 with CudaText v1.91.0. When I test under Windows 7 x64 with same version of CudaText the program behaves as expected.

Seems like this issue is a combination of a "special behaviour" (not to call it "bug") of Windows 10 and the current state of the related LCL code. Not sure how to handle that. I would have to set up a development environment on a Windows 10 machine or VM to debug that. But currently I'm out of time for that.

@dinkumoil
Copy link
Contributor

Maybe it's worth a try to replace WindowState := wsNormal; with ShowWindow(Handle, SW_RESTORE);

@dinkumoil
Copy link
Contributor

if WindowState=wsMinimized then could be replaced by if IsIconic(Handle) then.

@JairoMartinezA
Copy link
Author

Hi @Alexey-T

At the end I proceeded with the uninstall of the Shell-Integration-Dll (of @dinkumoil) for the above issues, then I installed cuda-explorer-integration that uses registry entries for add context menu options, but the behavior is the same, even If I launch CudaText as a external tool from others programs (IDE, DB Manager, etc) I am getting the same issues, it opens in restored view or no showing the editor.
Sorry is little unmanageable :'(.

Its possible that the problem is with the editor itself?

Thanks in advance.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 18, 2020

  • In settings/history.json, see the option "max"
{
  "dialog" : {
    "posx" : 120,
    "posy" : 158,
    "max" : true,

it is "true"? If not then Cud must not be maximized.

  • how Cud opens when you just open Cud window w/o shell extension?

@dinkumoil
Copy link
Contributor

I found another fail that happens only under Windows 10 (tested with v1809 x64):

  1. Open CudaText
  2. Set window in maximized view if it is in restored view.
  3. Click on its task bar symbol.
  4. The CudaText window should be minimized, instead nothing happens. Only when clicking a second time on the task bar symbol the window minimizes.

When in step 3. the "Minimize" button in the window's title bar is clicked, the window minimizes immediately.

If the sequence above is tested under Windows 7 x64, everything works as expected. The window minimizes after a single click on its task bar symbol.

This whole issue is related to Windows 10 and the window handling code of the LCL only, my shell integration DLL is not involved.

@Alexey-T
Copy link
Owner

@dinkumoil I will give this info to Lazarus dev's, in the mailing list.

@JairoMartinezA
Copy link
Author

Hi @Alexey-T

This is my config:

"dialog" : {
"max" : true,
"posx" : 53,
"posy" : 67,
"sizex" : 1193,
"sizey" : 595
},

I suppose that @dinkumoil is enough. I am testing it on a Windows 10 Pro v1909 x64.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 18, 2020

@jairomtzant I guess (not sure) that when Win runs Cud, it uses ShellExecute with SW_SHOW* flag to open program in a normal window- so the maximized state is lost... Cud must restore maximized state but OS may overdo it

@JairoMartinezA
Copy link
Author

Hi @Alexey-T

What you mention is something that I can verify? o_O?

But is ok, when I open Cud the first time It can be opened in Maximized state, If I don't change that status (Alt+Tab by example) Cud remembers this status even If I open some file using a Shell/Integration Explorer/Launching as ExternalTool from another program, but, but If I Minimize Cud, is when happens what I mention, its open in Restored View, and I If Maximize and then Minimize, the second time, Cud is not restored anymore when I open a new file.

@Alexey-T
Copy link
Owner

Alexey-T commented Feb 18, 2020

I see what code does it

{$ifdef windows}
procedure TfmMain.SecondInstance(const Msg: TBytes);
...
  DoLoadCommandParams(Params, '');

  if WindowState = wsMinimized then
  begin
    WindowState:= wsNormal;
    Application.ProcessMessages;
  end;
end;
{$endif}
         

here we set Normal state. Will see how to fix it.

@Alexey-T
Copy link
Owner

@dinkumoil It's fixed, see very simple patch linked above.

1.94.5 beta-- https://yadi.sk/d/XBA6P9Hmxl2yGA

@JairoMartinezA
Copy link
Author

I have tested quickly, Cud shows to work properly.

@dinkumoil
Copy link
Contributor

I can confirm that the two failing test cases from @jairomtzant initial posting are working now. But the test case I elaborated about in my last posting is still failing.

@Alexey-T
Copy link
Owner

Moving to #2411

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants