English 中文(简体)
A. 寻找可见的纽芬兰
原标题:Finding a visible button

i "stole" the code from http://improve.dk/archive/2007/04/07/finding-specific-windows.aspx

而不必写上阶级名称、名称和处理,而是想检查某个州是否明显。 并且如果能够看到纽子,则希望尽量扩大窗口。

i 改变这一部分=和;

    private static bool foundWindow(int handle)    
    {
        bool buttonCheck = false;
        IntPtr hButton = FindWindowEx((IntPtr)handle, IntPtr.Zero, "AfxWnd90u21", null);
        if (hButton != IntPtr.Zero)
        {
            buttonCheck = true;
        }

        if (buttonCheck)
        {
            ShowWindowAsync(handle, (int)3); // maximize the window
        }

        return true;
    }
the button class is `AfxWnd90u` and the instance is `21`. I wrote this in autoit before and AfxWnd90u21 is 100 % correct. 

the problem is that i cant find the button with AfxWnd90u21. if i only use 

    IntPtr hButton = FindWindowEx((IntPtr)handle, IntPtr.Zero, "AfxWnd90u", null);

all windows get maximized.

It has to be something with the instance.

i hope you can help me,

thanks

Newest Edit i just tried to find the class name with "GetClassName". I find 190~ classes per handle, but the class that i need is not in there. iam really desperate I hope someone can help me, thanks

       private static bool foundWindow(int handle)
            {
                int i = 0;
                IntPtr hWnd = (IntPtr)handle;

               // System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(hWnd);
                StringBuilder sbClass = new StringBuilder(256);

                while (hWnd != IntPtr.Zero)
                {
                    ++i;


                    ///////////////////////////////////////////////////
                    ////////////// Compare if the classname exists/////
                    GetClassName((int)hWnd, sbClass, sbClass.Capacity);
                    if (sbClass.ToString().Equals("AfxWnd90u21"))
                    {
                        MessageBox.Show(sbClass.ToString());
                    }
                    ///////////////////////////////////////////////////


                    ////// trying to find the correct class with findwindowEX//////////
                    IntPtr hButton = FindWindowEx(hWnd, IntPtr.Zero, "AfxWnd90u21", null);



                    if (hButton != IntPtr.Zero)
                    {
                        MessageBox.Show("true");
                        ShowWindowAsync(handle, (int)2); // maximize the window
                    }
                    hWnd = FindWindowEx(IntPtr.Zero, hWnd, null, null);
                }
                MessageBox.Show(""+i);
                return true;
            }
问题回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签