求解三个API问题,每个50分(150分)

  • 主题发起人 主题发起人 mllee
  • 开始时间 开始时间
M

mllee

Unregistered / Unconfirmed
GUEST, unregistred user!
1、如何根据句柄判断一个窗体是否当前活动窗体?<br>2、如何根据句柄判断一个控件是否拥有输入焦点?<br>3、如何判断一个进程和一个窗体的关系?<br><br>谢谢
 
1、ActiveForm &nbsp; <br>2、HasFocus<br>3、?
 
1.用GetActiveWindow,返回窗体句柄,在比较两者即可
 
没有HasFocus吧?我找不到<br>ActiveForm也不好用啊<br>
 
用GetActiveForm只能得到隶属于本程序的活动窗口,不能得到其他程序的(返回0)。
 
1: 判断 GetForegroundWindow是否为当前句柄值<br>2: ?<br>3:?
 
HWND GetActiveWindow(VOID)<br>HWND GetFocus(VOID)<br>DWORD GetWindowThreadProcessId(<br>&nbsp; &nbsp; HWND hWnd, // handle of window<br>&nbsp; &nbsp; LPDWORD lpdwProcessId // address of variable for process identifier<br>&nbsp; &nbsp;); <br>&nbsp;<br><br>
 
可以用<br>GetWindowThreadProcessId(WindowsHandle,ProcessID_Piont);<br>{<br>The GetWindowThreadProcessId function retrieves the identifier of the thread that created the specified window and, optionally, the identifier of the process that created the window. This function supersedes the GetWindowTask function. <br>DWORD GetWindowThreadProcessId(<br>&nbsp; &nbsp; HWND hWnd, // handle of window<br>&nbsp; &nbsp; LPDWORD lpdwProcessId // address of variable for process identifier<br>&nbsp; &nbsp;); <br>Parameters<br>&nbsp;hWnd: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Identifies the window. <br>&nbsp;lpdwProcessId: Points to a 32-bit value that receives the process identifier. If this parameter is not NULL, GetWindowThreadProcessId copies the identifier of the process to the 32-bit value; otherwise, it does not. <br><br>Return Values<br>&nbsp;The return value is the identifier of the thread that created the window. <br><br>Remarks<br><br>This function replaces the GetWindowTask function of Windows version 3.x
 
to tian_jian:<br>&nbsp; 你对第一个问题的回答是对的<br>to tseug, kylion:<br>&nbsp; 你们对第三个问题的回答是对的<br>第二个问题谁能回答???谢谢
 
The GetFocus function retrieves the handle of the window that has the keyboard<br>&nbsp;focus, if the window is associated with the calling thread's message queue. <br>HWND GetFocus(VOID)<br><br>MSDN 中有hasFocus 方法,但是好像Delphi里边没有提供!用GetFocus可以判断
 
GetFocus只能得到属于本程序的控件句柄,得不到其它程序的。<br>好象需要用借助AttachThreadInput,但我不知道怎样用这个函数……
 
找到答案了,散分!
 
后退
顶部