Winapi: findwindow, find1_wex-search window

Source: Internet
Author: User
Findwindow (lpclassname, {Class Name of the window} lpwindowname: pchar {Title of the window}): hwnd; {handle of the returned window; returns 0} // find1_wex, which has two more handle parameters than findwindow: find1_wex (parent: hwnd; {the parent window handle for the Child window to be searched} Child: hwnd; {sub-window handle} classname: pchar; {} windowname: pchar {}): hwnd; {If parent is 0, the function uses the desktop window as the parent window, find all subwindows In the desktop window. If it is hwnd_message, the function only looks for all message windows. The subwindow must be a direct subwindow in the parent window. If the child is 0, searches start from the first subwindow of parent. If parent and child are both 0, the function searches for all top-level windows and message windows .}
  
   
 // Test 1: try to create a new one. Program Main Window handle var H: hwnd; begin {now we know the title of the window is: form1, the Class Name of the window is: tform1} H: = findwindow ('tform1 ', 'form1 '); showmessage (inttostr (h); {656180; this is random. Each start window must be different.} {if you do not know the class name} H: = findwindow (nil, 'form1 '); showmessage (inttostr (h); {656180} {if you do not know the title name} H: = findwindow ('tform1', nil ); showmessage (inttostr (h); {656180} {in fact, the handle of this window is not self. handle?} showmessage (inttostr (handle); {656180} end;
  
   
 // Test 2: Find the handle of the calculator window (open the calculator first) var H: hwnd; begin {if it is not a simplified Chinese system, this may not work} H: = findwindow (nil, 'calculator'); showmessage (inttostr (h); {1508334} {it is best to do this, but you must know in advance that the class name of the calculator window is: scic1c} h: = findwindow ('scical', nil); showmessage (inttostr (h); {1508334} end;
  
   
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.