を見つける私は http://improve.dk/archive/2007/04/07/finding-specific-windows.aspx見えるボタン
からコードを「盗んだ」が、代わりにクラス名、タイトルを書いて、私は、特定のボタンが表示されているかどうかを確認したいコンソールに扱うの。ボタンが表示されている場合、私はウィンドウを最大化したい。
私は=>
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
最新の編集 この部分を変更し、私はちょうど "getClassNameメソッド" でクラス名を見つけることを試みました。私はハンドルあたり190〜クラスを見つけるが、私が必要とするクラスはそこにない。私は、誰かが私を助けることができると思います IAM本当に必死 、 おかげ
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;
}
ありがとう、 私は子供を反復しようとしましたが、それは仕事をしませんでした。コントロールにハンドルをキャストし、そのメンバーを使って反復する例を教えてください。 は、私はちょうどこの@のMSDNを見つけました:http://msdn.microsoft.com/en-us/library/ms908149.aspx SRYが、IAM完全に混乱し –
@MaikKleinがOK –
を更新し、 しかしIAMまだ少し混乱して。私は型変換を持っています。System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle(hWnd); 私はcontrolのメンバ関数をすべて調べましたが、control.containsを助けることができる唯一の関数ですが、パラメータとしてコントロールが必要です コントロールオブジェクトでクラスをチェックするのはどうですか? 、または前に投稿した "lpszWindow"でクラスをチェックすることはできますか? –