[win 10,c#] Interop - 最大化或正常最小化应用程序的通用方法 [英] [win 10, c#] Interop - Generic way to Maximized or Normal a Minimized application

查看:84
本文介绍了[win 10,c#] Interop - 最大化或正常最小化应用程序的通用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有问题通常把普通最小化的窗口放进去吗?

I have problem to generically put to Normal a Minimized window?

如果我记住它的hWnd它会很好用当它是正常的,但如果窗口已经被最小化,那么这对我不起作用。

It works great if I memorize its hWnd when it is normal, but if the window is already minimized then that doesn't work for me.

要重现,请使用此处的代码 -
castorix31

To reproduce, use the code from here - castorix31

1.  T 在win 10上启动计算器,注意hWnd在最小化时是不同的

1. Then start a Calculator on win 10, notice the hWnd is different when minimized or not.

2。将简单代码添加为

2. Add the simple code as

        [DllImport(" User32")]

        public static extern int ShowWindow(int hwnd,int nCmdShow);

        [DllImport("User32")]
        public static extern int ShowWindow(int hwnd, int nCmdShow);

       并调用"ShowWindow(hWnd.ToInt32(),1);"就在"最小化"之前返回false之前用例

        and call "ShowWindow(hWnd.ToInt32(), 1);" just before the return false in the "// minimized" use case

3。最小化计算器并再次按下按钮,注意它不会正常显示窗口,因为hWnd来自最小化版本,如果你在正常情况下记住它并用 ShowWindow 
最小化时,则此工作(calc将显示为Normal) ....但在我的情况下,应用程序从一开始就被最小化,那么如何获得正确的hWnd以便我可以调用此ShowWindow或MoveWindow?

3. minimized calculator and press the button again, notice it won't show the window as normal as the hWnd is from from the minimized version, if you memorize the one when Normal and call it with ShowWindow when minimized, then this work (calc will be displayed as Normal)....but in my case the application is minimized from the start, so how do I get the right hWnd so I can call this ShowWindow or MoveWindow?

感谢您的帮助

w。

推荐答案

我在"最小化"中添加了以下内容:获得正确的hWnd,但它总是返回0?

I added the following in the "minimized" case to get the right hWnd, but it always returns 0?

                         ep.hWnd =的hWnd;

                         ep.sExeName = sProcessImageName.ToString();

                         ep.nPID = nPID;

                         ep.nState = 1;

                         Marshal.StructureToPtr(EP,lParam的,假);

               &NBSP ;       的hWnd = FindWindowEx(HWND,IntPtr.Zero," Windows.UI.Core.CoreWindow" ;, NULL);

                         ShowWindow(hWnd.ToInt32(),1);

                        // SetVisualStat(HWND,WindowVisualState.Normal);

               &NBSP ;       返回false;

 

                        ep.hWnd = hWnd;
                        ep.sExeName = sProcessImageName.ToString();
                        ep.nPID = nPID;
                        ep.nState = 1;
                        Marshal.StructureToPtr(ep, lParam, false);
                        hWnd = FindWindowEx(hWnd, IntPtr.Zero, "Windows.UI.Core.CoreWindow", null);
                        ShowWindow(hWnd.ToInt32(), 1);
                        //SetVisualStat(hWnd, WindowVisualState.Normal);
                        return false;
 

(我在返回前添加了这个)

(I added this before the return)

你知道锄头做它吗工作?

Do you know hoe to make it work?

谢谢


这篇关于[win 10,c#] Interop - 最大化或正常最小化应用程序的通用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆