Demo 0024 查詢頂層窗體及控制項

2022-04-07 10:22:40 字數 783 閱讀 4298

正如前面的幾節中我們講述的, windows是由一系列的窗體組合而成,而windows在對乙個窗體操作前需要得到這個窗體的控制代碼,那如何讀取乙個窗休的控制代碼呢,windows提供了許多的函式來達到這樣的目的,今天我們先了學習最常用和直接的二個方法:

(一) 函式宣告

hwnd findwindowex(hwnd hwndparent, hwnd hwndchildafter, lpctstr lpszclass, lpctstr lpszwindow );

獲取與窗體的類名和窗體名相匹配的窗休控制代碼,此函式在搜尋子窗體時以指定的子窗體控制代碼開始進行,  當後三引數都為null時返回此窗體的第乙個子窗體

hwnd findwindow(lpctstr lpclassname, lpctstr lpwindowname );

獲取與窗體的類名和窗體名相匹配的窗休控制代碼,此函式只用於查詢頂層窗體,它是findwindowex更高階的版本

code1:  以下**演示了:

1.  通過findwindow查詢notepad主窗體(頂層窗體)

2.  從notepad主窗體中查詢其子控制項edit;

3.  傳送字串文字到notepad子控制項edit中.

hwnd

hwndnotepad

= findwindow(_t

("notepad"

), null

);if

(null

!= hwndnotepad

&& iswindow

(hwndnotepad))}

演示**

每日一包0024 inquirer

好用的互動命令列工具方法 1.inquirer.prompt questions promise 啟動提示介面並返回promiseconst req require inquirer req.prompt then as catch err 請輸入您的名字 小明 您的名字是 小明 2.inquire...

簡訊攔截demo

簡訊攔截demo import android.content.broadcastreceiver import android.content.context import android.content.intent import android.os.bundle import android...

下拉重新整理Demo

引用了網上的demo 總結下使用 方便以後簡單使用。下拉重新整理 public class refreshlistview extends listview implements onscrolllistener public refreshlistview context context,attr...