本文整理汇总了C#中EnumWindowProc类的典型用法代码示例。如果您正苦于以下问题:C# EnumWindowProc类的具体用法?C# EnumWindowProc怎么用?C# EnumWindowProc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EnumWindowProc类属于命名空间,在下文中一共展示了EnumWindowProc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FindChildClassHwnd
/**/
/// <summary>
/// Find the child window, if found m_classname will be assigned
/// </summary>
/// <param name="hwndParent">parent's handle</param>
/// <param name="lParam">the application value, nonuse</param>
/// <returns>found or not found</returns>
//The C++ code is that lParam is the instance of FindWindow class , if found assign the instance's m_hWnd
private bool FindChildClassHwnd(IntPtr hwndParent, IntPtr lParam)
{
EnumWindowProc childProc = new EnumWindowProc(FindChildClassHwnd);
IntPtr hwnd = FindWindowEx(hwndParent, IntPtr.Zero, this.m_classname, string.Empty);
if (hwnd != IntPtr.Zero)
{
this.m_hWnd = hwnd; // found: save it
return false; // stop enumerating
}
EnumChildWindows(hwndParent, childProc, IntPtr.Zero); // recurse redo FindChildClassHwnd
return true;// keep looking
}
示例2: FindChildClassHwnd
private bool FindChildClassHwnd(IntPtr hwndParent, IntPtr lParam)
{
EnumWindowProc callback = new EnumWindowProc(this.FindChildClassHwnd);
IntPtr ptr = FindWindowEx(hwndParent, IntPtr.Zero, this.m_classname, string.Empty);
if (ptr != IntPtr.Zero)
{
this.m_hWnd = ptr;
callback = null;
return false;
}
EnumChildWindows(hwndParent, callback, IntPtr.Zero);
callback = null;
return true;
}
示例3: TryFindHandle
/// <summary>
/// Chrome's message-loop Window isn't created synchronously, so this may not find it.
/// If so, you need to wait and try again later.
/// </summary>
public static bool TryFindHandle(IntPtr browserHandle, out IntPtr chromeWidgetHostHandle)
{
var classDetails = new ClassDetails();
var gcHandle = GCHandle.Alloc(classDetails);
var childProc = new EnumWindowProc(EnumWindow);
EnumChildWindows(browserHandle, childProc, GCHandle.ToIntPtr(gcHandle));
chromeWidgetHostHandle = classDetails.DescendantFound;
gcHandle.Free();
return classDetails.DescendantFound != IntPtr.Zero;
}
示例4: EnumDesktopWindows
public static extern bool EnumDesktopWindows(IntPtr hDesktop, EnumWindowProc lpfn, IntPtr lParam);
示例5: GetChildWindows
/// <summary>
/// Returns a list of child windows
/// </summary>
/// <param name="parent">Parent of the windows to return</param>
/// <returns>List of child windows</returns>
public static List<IntPtr> GetChildWindows(IntPtr parent)
{
List<IntPtr> result = new List<IntPtr>();
GCHandle listHandle = GCHandle.Alloc(result);
try {
EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
EnumChildWindows(parent, childProc, GCHandle.ToIntPtr(listHandle));
}
finally {
if (listHandle.IsAllocated)
listHandle.Free();
}
return result;
}
示例6: GetAllChildHandles
// Bir List<IntPtr> listesi yarat ve istenilen uygulamaya ait ana window altındaki tüm çocuk
// window'ların handle kimliklerini listeye doldur.
public List<IntPtr> GetAllChildHandles()
{
List<IntPtr> childHandles = new List<IntPtr>();
GCHandle gcChildhandlesList = GCHandle.Alloc(childHandles);
IntPtr pointerChildHandlesList = GCHandle.ToIntPtr(gcChildhandlesList);
try
{
EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
EnumChildWindows(this.m_MainHandle, childProc, pointerChildHandlesList);
}
finally
{
gcChildhandlesList.Free();
}
return childHandles;
}
示例7: Test
public void Test()
{
// ���TextWriter�йܶ��ᱻ���ݸ�Win32 API����
// �������һֱ���ڣ�ֱ�����ý���
TextWriter outputWriter = System.Console.Out;
// ʹ��GCHandle����ֹTextWriter������������������
GCHandle gch = GCHandle.Alloc(outputWriter, GCHandleType.Normal);
EnumWindowProc cb = new EnumWindowProc(DisplayWindowsTitleProc);
// P/Invoke���ڵ��ý���ǰ���Զ���ֹ����
// ��������ί�н��л���
EnumDesktopWindows(IntPtr.Zero, cb, (IntPtr)gch);
// ��������ҪGCHandleʱ���������Free���������ͷŵ�
gch.Free();
}
示例8: FindChildClassHwnd
/**/
/// <summary>
/// Find the child window, if found m_classname will be assigned
/// </summary>
/// <param name="hwndParent">parent's handle</param>
/// <param name="lParam">the application value, nonuse</param>
/// <returns>found or not found</returns>
//The C++ code is that lParam is the instance of FindWindow class , if found assign the instance's m_hWnd
private bool FindChildClassHwnd(IntPtr hwndParent, IntPtr lParam)
{
EnumWindowProc childProc = new EnumWindowProc(FindChildClassHwnd);
IntPtr hwnd = FindWindowEx(hwndParent, IntPtr.Zero, m_classname, m_caption);
if (hwnd != IntPtr.Zero)
{
this.m_hWnd = hwnd; // found: save it
m_IsTimeOut = false;
return false; // stop enumerating
}
DateTime end = DateTime.Now;
if (start.AddSeconds(m_timeout) < end)
{
m_IsTimeOut = true;
return false;
}
EnumChildWindows(hwndParent, childProc, IntPtr.Zero); // recurse redo FindChildClassHwnd
return true;// keep looking
}
示例9: GetChildWindows
/// <summary>
/// </summary>
/// <param name = "parent"></param>
/// <returns></returns>
private static IEnumerable<IntPtr> GetChildWindows( IntPtr parent )
{
var windowPointers = new List<IntPtr>();
GCHandle listHandle = GCHandle.Alloc( windowPointers );
try
{
var childProc = new EnumWindowProc( EnumWindow );
EnumChildWindows( parent, childProc, GCHandle.ToIntPtr( listHandle ) );
}
finally
{
if ( listHandle.IsAllocated )
{
listHandle.Free();
}
}
return windowPointers;
}
示例10: EnumThreadWindows
public static extern bool EnumThreadWindows(int dwThreadId, EnumWindowProc lpfn, IntPtr lParam);
示例11: EnumChildWindows
public static extern bool EnumChildWindows(IntPtr window, EnumWindowProc callback, IntPtr lParam);
示例12: EnumWindows
public static extern int EnumWindows(EnumWindowProc x, int y);
示例13: EnumWindows
public static int EnumWindows(EnumWindowProc lpEnumFunc, IntPtr lParam)
{
return -1;
}
示例14: Update
// 子ハンドルのリスト更新
public void Update()
{
hWndList.Clear();
this.hWnd = GetWindowHandle(windowName);
if (hWnd.Equals((IntPtr)0))
{
this.hWnd = GetWindowHandle(windowName+"*");
if (hWnd.Equals((IntPtr)0))
{
string str = "\"" + windowName + "\"は起動していません";
throw new ApplicationException(str);
}
this.windowName = windowName + "*";
}
GCHandle listHandle = GCHandle.Alloc(hWndList);
try
{
EnumWindowProc childProc = new EnumWindowProc(EnumWindow);
EnumChildWindows(hWnd, childProc, GCHandle.ToIntPtr(listHandle));
}
finally
{
if (listHandle.IsAllocated)
{
listHandle.Free();
}
}
}
示例15: EnumDesktopWindows
static extern bool EnumDesktopWindows(
IntPtr desktopHandle,
EnumWindowProc cb,
IntPtr param);