jp.hishidama.win32.api
クラス WinUser

java.lang.Object
  上位を拡張 jp.hishidama.win32.api.WinUser

public final class WinUser
extends Object

winuser.hの関数.

導入されたバージョン:
2007.10.01
バージョン:
2007.11.01
作成者:
ひしだま
関連項目:
JWnd

メソッドの概要
static boolean CheckDlgButton(long hdlg, int nIDButton, int uCheck)
          ダイアログボックス:チェックボタン設定.
static boolean CheckRadioButton(long hdlg, int nIDFirstButton, int nIDLastButton, int nIDCheckButton)
          ダイアログボックス:ラジオボタン設定.
static long ChildWindowFromPoint(long hwnd, int x, int y)
          指定位置子ウィンドウ取得.
static long ChildWindowFromPointEx(long hwnd, int x, int y, int flags)
          指定位置子ウィンドウ取得.
static boolean ClientToScreen(long wnd, Point point)
          スクリーン座標変換.
static boolean EnableScrollBar(long wnd, int bar, int arrows)
          スクロールバー可否設定.
static boolean EnableWindow(long wnd, boolean enable)
          入力可否設定.
static boolean EnumChildWindows(long hwnd, List list)
          子ウィンドウ列挙.
static boolean EnumWindows(List list)
          トップレベルウィンドウ列挙.
static long FindWindow(String className, String windowName)
          トップレベルウィンドウ検索.
static long GetActiveWindow()
          アクティブウィンドウ取得.
static long GetAncestor(long wnd, int flags)
          祖先ウィンドウ取得.
static String getClassName(long hwnd)
          ウィンドウクラス名取得.
static boolean GetClientRect(long wnd, Rectangle r)
          クライアント領域取得.
static long GetDesktopWindow()
          デスクトップ取得.
static int GetDlgCtrlID(long hctl)
          ダイアログボックス:コントロール識別子取得.
static long GetDlgItem(long hdlg, int id)
          ダイアログボックス:コントロール取得.
static int GetDlgItemInt(long hdlg, int id, boolean[] translated, boolean signed)
          ダイアログボックス:コントロール数値取得.
static String GetDlgItemText(long hdlg, int id, int len)
          ダイアログボックス:コントロールテキスト取得.
static long GetFocus()
          キーボードフォーカスウィンドウ取得.
static long GetForegroundWindow()
          フォアグラウンドウィンドウ取得.
static long GetNextDlgGroupItem(long hdlg, long hctl, boolean previous)
          ダイアログボックス:グループ内の次コントロール取得.
static long GetNextDlgTabItem(long hdlg, long hctl, boolean previous)
          ダイアログボックス:タブ移動可能な次コントロール取得.
static long GetNextWindow(long hwnd, int cmd)
          次ウィンドウ取得.
static long GetParent(long wnd)
          親ウィンドウ取得.
static long GetTopWindow(long hwnd)
          一番上の子ウィンドウ取得.
static long GetWindow(long wnd, int cmd)
          ウィンドウ取得.
static int GetWindowLong(long hwnd, int index)
          ウィンドウ情報取得.
static boolean GetWindowRect(long wnd, Rectangle r)
          ウィンドウ領域取得.
static String getWindowText(long wnd)
          ウィンドウテキスト取得.
static int GetWindowTextLength(long wnd)
          ウィンドウテキスト長取得.
static boolean IsChild(long hwndParent, long hwnd)
          子ウィンドウ判断.
static int IsDlgButtonChecked(long hdlg, int nIDButton)
          ダイアログボックス:チェックボタン状態取得.
static boolean IsIconic(long wnd)
          アイコン状態判断.
static boolean IsWindow(long hwnd)
          ウィンドウ存在判断.
static boolean IsWindowEnabled(long wnd)
          入力可否判断.
static boolean IsWindowVisible(long wnd)
          表示状態判断.
static boolean IsZoomed(long wnd)
          最大化状態判断.
static int MessageBox(long wnd, String text, String caption, int type)
          メッセージボックス.
static boolean MoveWindow(long hwnd, int x, int y, int width, int height, boolean repaint)
          ウィンドウ移動.
static boolean PostMessage(long hwnd, int msg, int wparam, int lparam)
          メッセージキューへの送信.
static boolean ScreenToClient(long wnd, Point point)
          クライアント座標変換.
static int SendMessage(long hwnd, int msg, int wparam, byte[] lparam)
          メッセージ送信.
static int SendMessage(long hwnd, int msg, int wparam, int lparam)
          メッセージ送信.
static int SendMessage(long hwnd, int msg, int wparam, String lparam)
          メッセージ送信.
static long SetActiveWindow(long wnd)
          アクティブウィンドウ設定.
static boolean SetDlgItemInt(long hdlg, int id, int value, boolean signed)
          ダイアログボックス:コントロール数値設定.
static boolean SetDlgItemText(long hdlg, int id, String text)
          ダイアログボックス:コントロールテキスト設定.
static long SetFocus(long wnd)
          キーボードフォーカス設定.
static boolean SetForegroundWindow(long wnd)
          フォアグラウンドウィンドウ設定.
static long SetParent(long wnd, long wndParent)
          親ウィンドウ設定.
static int SetWindowLong(long hwnd, int index, int value)
          ウィンドウ情報設定.
static boolean SetWindowPos(long hwnd, long hWndInsertAfter, int x, int y, int cx, int cy, int flags)
          ウィンドウ位置設定.
static boolean SetWindowText(long wnd, String string)
          ウィンドウテキスト設定.
static boolean ShowScrollBar(long wnd, int bar, boolean show)
          スクロールバー表示状態設定.
static boolean ShowWindow(long wnd, int cmdShow)
          ウィンドウ表示状態設定.
static long WindowFromPoint(int x, int y)
          指定位置ウィンドウ取得.
 
クラス java.lang.Object から継承されたメソッド
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

メソッドの詳細

SendMessage

public static int SendMessage(long hwnd,
                              int msg,
                              int wparam,
                              int lparam)
メッセージ送信.

パラメータ:
hwnd - HWND
msg - メッセージ(WM_*)
wparam - WPARAM
lparam - LPARAM
戻り値:
メッセージにより異なる

SendMessage

public static int SendMessage(long hwnd,
                              int msg,
                              int wparam,
                              String lparam)
メッセージ送信.

パラメータ:
hwnd - HWND
msg - メッセージ(WM_*)
wparam - WPARAM
lparam - LPARAM(文字列)
戻り値:
メッセージにより異なる

SendMessage

public static int SendMessage(long hwnd,
                              int msg,
                              int wparam,
                              byte[] lparam)
メッセージ送信.

パラメータ:
hwnd - HWND
msg - メッセージ(WM_*)
wparam - WPARAM
lparam - LPARAM(バイト配列)
戻り値:
メッセージにより異なる

PostMessage

public static boolean PostMessage(long hwnd,
                                  int msg,
                                  int wparam,
                                  int lparam)
メッセージキューへの送信.

パラメータ:
hwnd - HWND
msg - メッセージ(WM_*)
wparam - WPARAM
lparam - LPARAM
戻り値:
メッセージにより異なる

IsWindow

public static boolean IsWindow(long hwnd)
ウィンドウ存在判断.

パラメータ:
hwnd - HWND
戻り値:
true:ウィンドウが存在しているとき

IsChild

public static boolean IsChild(long hwndParent,
                              long hwnd)
子ウィンドウ判断.

パラメータ:
hwndParent - 親ウィンドウのHWND
hwnd - 調査するHWND
戻り値:
true:子ウィンドウあるいは子孫ウィンドウのとき

ShowWindow

public static boolean ShowWindow(long wnd,
                                 int cmdShow)
ウィンドウ表示状態設定.

パラメータ:
wnd - HWND
cmdShow - 表示方法(WinUserConst.SW_HIDE等)
戻り値:
true:ウィンドウが以前から表示されていたとき
false:ウィンドウが以前は非表示だったとき

MoveWindow

public static boolean MoveWindow(long hwnd,
                                 int x,
                                 int y,
                                 int width,
                                 int height,
                                 boolean repaint)
                          throws Win32Exception
ウィンドウ移動.

ウィンドウの位置とサイズを変更する。
トップレベルウィンドウはスクリーン座標、親ウィンドウを持つウィンドウはクライアント座標で指定する。

パラメータ:
hwnd - HWND
x - X
y - Y
width - 幅
height - 高さ
repaint - 再描画オプション(true:ウィンドウにWM_PAINTが送られる)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

SetWindowPos

public static boolean SetWindowPos(long hwnd,
                                   long hWndInsertAfter,
                                   int x,
                                   int y,
                                   int cx,
                                   int cy,
                                   int flags)
                            throws Win32Exception
ウィンドウ位置設定.

ウィンドウの位置・サイズ・Zオーダーを変更する。

パラメータ:
hwnd - HWND
hWndInsertAfter - 配置順序のHWND
x - X
y - Y
cx - 幅
cy - 高さ
flags - ウィンドウ位置オプション(SWP_*)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

IsWindowVisible

public static boolean IsWindowVisible(long wnd)
表示状態判断.

パラメータ:
wnd - HWND
戻り値:
true:表示されている(WS_VISIBLEスタイルを持っている)

IsIconic

public static boolean IsIconic(long wnd)
アイコン状態判断.

パラメータ:
wnd - HWND
戻り値:
true:最小化(アイコン化)されている

IsZoomed

public static boolean IsZoomed(long wnd)
最大化状態判断.

パラメータ:
wnd - HWND
戻り値:
true:最大化されている

GetDlgItem

public static long GetDlgItem(long hdlg,
                              int id)
                       throws Win32Exception
ダイアログボックス:コントロール取得.

パラメータ:
hdlg - HWND
id - コントロールの識別子
戻り値:
コントロールのHWND
例外:
Win32Exception - 失敗時

SetDlgItemInt

public static boolean SetDlgItemInt(long hdlg,
                                    int id,
                                    int value,
                                    boolean signed)
                             throws Win32Exception
ダイアログボックス:コントロール数値設定.

パラメータ:
hdlg - HWND
id - コントロールの識別子
value - 値
signed - 符号を付けるかどうか
戻り値:
成功した場合、true
例外:
Win32Exception - 失敗時

GetDlgItemInt

public static int GetDlgItemInt(long hdlg,
                                int id,
                                boolean[] translated,
                                boolean signed)
                         throws Win32Exception
ダイアログボックス:コントロール数値取得.

パラメータ:
hdlg - HWND
id - コントロールの識別子
translated - 0番に、成功したかどうかの状態を返す(nullの場合は何も返さない)
signed - true:符号付きとして扱う
戻り値:
例外:
Win32Exception - 失敗時

SetDlgItemText

public static boolean SetDlgItemText(long hdlg,
                                     int id,
                                     String text)
                              throws Win32Exception
ダイアログボックス:コントロールテキスト設定.

パラメータ:
hdlg - HWND
id - コントロールの識別子
text - 文字列
戻り値:
成功した場合、true
例外:
Win32Exception - 失敗時

GetDlgItemText

public static String GetDlgItemText(long hdlg,
                                    int id,
                                    int len)
                             throws Win32Exception
ダイアログボックス:コントロールテキスト取得.

パラメータ:
hdlg - HWND
id - コントロールの識別子
len - 文字列の最大サイズ
戻り値:
文字列
例外:
Win32Exception - 失敗時

CheckDlgButton

public static boolean CheckDlgButton(long hdlg,
                                     int nIDButton,
                                     int uCheck)
                              throws Win32Exception
ダイアログボックス:チェックボタン設定.

パラメータ:
hdlg - HWND
nIDButton - コントロールの識別子
uCheck - 値(BST_*)
戻り値:
成功した場合、true
例外:
Win32Exception - 失敗時

CheckRadioButton

public static boolean CheckRadioButton(long hdlg,
                                       int nIDFirstButton,
                                       int nIDLastButton,
                                       int nIDCheckButton)
                                throws Win32Exception
ダイアログボックス:ラジオボタン設定.

パラメータ:
hdlg - HWND
nIDFirstButton - グループ内の最初のボタンの識別子
nIDLastButton - グループ内の最後のボタンの識別子
nIDCheckButton - 選択したいボタンの識別子
戻り値:
成功した場合、true
例外:
Win32Exception - 失敗時

IsDlgButtonChecked

public static int IsDlgButtonChecked(long hdlg,
                                     int nIDButton)
ダイアログボックス:チェックボタン状態取得.

パラメータ:
hdlg - HWND
nIDButton - ボタンの識別子
戻り値:
WinUserConst.BST_CHECKED

GetNextDlgGroupItem

public static long GetNextDlgGroupItem(long hdlg,
                                       long hctl,
                                       boolean previous)
                                throws Win32Exception
ダイアログボックス:グループ内の次コントロール取得.

パラメータ:
hdlg - HWND
hctl - コントロールのHWND
previous - 方向フラグ(true:前のコントロール、false:次のコントロール)
戻り値:
コントロールのHWND
例外:
Win32Exception - 失敗時

GetNextDlgTabItem

public static long GetNextDlgTabItem(long hdlg,
                                     long hctl,
                                     boolean previous)
                              throws Win32Exception
ダイアログボックス:タブ移動可能な次コントロール取得.

パラメータ:
hdlg - HWND
hctl - コントロールのHWND
previous - 方向フラグ(true:前のコントロール、false:次のコントロール)
戻り値:
コントロールのHWND
例外:
Win32Exception - 失敗時

GetDlgCtrlID

public static int GetDlgCtrlID(long hctl)
                        throws Win32Exception
ダイアログボックス:コントロール識別子取得.

パラメータ:
hctl - コントロールのHWND
戻り値:
コントロールの識別子
例外:
Win32Exception - 失敗時

SetFocus

public static long SetFocus(long wnd)
                     throws Win32Exception
キーボードフォーカス設定.

パラメータ:
wnd - HWND
戻り値:
以前にキーボードフォーカスを持っていたウィンドウのHWND
例外:
Win32Exception - 失敗時

GetFocus

public static long GetFocus()
キーボードフォーカスウィンドウ取得.

戻り値:
HWND キーボードフォーカスを持つウィンドウのHWND(該当ウィンドウが無い場合、0)
関連項目:
GetForegroundWindow()

SetActiveWindow

public static long SetActiveWindow(long wnd)
                            throws Win32Exception
アクティブウィンドウ設定.

ウィンドウをアクティブにする。

パラメータ:
wnd - HWND
戻り値:
以前アクティブだったウィンドウのHWND
例外:
Win32Exception - 失敗時

GetActiveWindow

public static long GetActiveWindow()
アクティブウィンドウ取得.

戻り値:
HWND アクティブなウィンドウのHWND(該当ウィンドウがない場合、null)
関連項目:
GetForegroundWindow()

EnableWindow

public static boolean EnableWindow(long wnd,
                                   boolean enable)
                            throws Win32Exception
入力可否設定.

無効にするとマウス入力やキーボード入力を受け付けない。グレーアウト状態?

パラメータ:
wnd - HWND
enable - true:有効、false:無効
戻り値:
true:既に無効になっていたとき
例外:
Win32Exception - 失敗時

IsWindowEnabled

public static boolean IsWindowEnabled(long wnd)
入力可否判断.

マウス入力やキーボード入力を受け付ける状態(グレーアウト?)かどうかを返す。

パラメータ:
wnd - HWND
戻り値:
true:有効、false:無効

SetForegroundWindow

public static boolean SetForegroundWindow(long wnd)
フォアグラウンドウィンドウ設定.

ウィンドウをフォアグラウンド(かつアクティブ)にする。

パラメータ:
wnd - HWND
戻り値:
true:フォアグラウンドになった

GetForegroundWindow

public static long GetForegroundWindow()
フォアグラウンドウィンドウ取得.

戻り値:
HWND

ShowScrollBar

public static boolean ShowScrollBar(long wnd,
                                    int bar,
                                    boolean show)
                             throws Win32Exception
スクロールバー表示状態設定.

パラメータ:
wnd - HWND
bar - 設定対象(SB_*)
show - true:表示、false:非表示
戻り値:
true:成功
例外:
Win32Exception - 失敗時

EnableScrollBar

public static boolean EnableScrollBar(long wnd,
                                      int bar,
                                      int arrows)
                               throws Win32Exception
スクロールバー可否設定.

パラメータ:
wnd - HWND
bar - 設定対象(SB_*)
arrows - 矢印の有効無効設定(ESB_*)
戻り値:
true:成功
false:既に設定されていた
例外:
Win32Exception - 失敗時

SetWindowText

public static boolean SetWindowText(long wnd,
                                    String string)
                             throws Win32Exception
ウィンドウテキスト設定.

ウィンドウのタイトルやコントロールのテキストを変更する。
他アプリケーションのテキストは変更できない。

パラメータ:
wnd - HWND
string - テキスト
戻り値:
true:成功
例外:
Win32Exception - 失敗時

getWindowText

public static String getWindowText(long wnd)
                            throws Win32Exception
ウィンドウテキスト取得.

ウィンドウのタイトルやコントロールのテキストを取得する。

パラメータ:
wnd - HWND
戻り値:
テキスト
例外:
Win32Exception - 失敗時

GetWindowTextLength

public static int GetWindowTextLength(long wnd)
                               throws Win32Exception
ウィンドウテキスト長取得.

パラメータ:
wnd - HWND
戻り値:
ウィンドウテキストの文字数
例外:
Win32Exception - 失敗時

GetClientRect

public static boolean GetClientRect(long wnd,
                                    Rectangle r)
                             throws Win32Exception
クライアント領域取得.

クライアント領域をクライアント座標で返すので、左上は常に(0,0)となる。

パラメータ:
wnd - HWND
r - 座標値(クライアント座標系)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

GetWindowRect

public static boolean GetWindowRect(long wnd,
                                    Rectangle r)
                             throws Win32Exception
ウィンドウ領域取得.

パラメータ:
wnd - HWND
r - 座標値(スクリーン座標系)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

MessageBox

public static int MessageBox(long wnd,
                             String text,
                             String caption,
                             int type)
                      throws Win32Exception
メッセージボックス.

パラメータ:
wnd - HWND
text - テキスト
caption - タイトル
type - スタイル(WinUserConst.MB_OK等)
戻り値:
戻り値(WinUserConst.IDOK等)
例外:
Win32Exception - 失敗時

ClientToScreen

public static boolean ClientToScreen(long wnd,
                                     Point point)
                              throws Win32Exception
スクリーン座標変換.

パラメータ:
wnd - HWND
point - クライアント座標(スクリーン座標に変換される)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

ScreenToClient

public static boolean ScreenToClient(long wnd,
                                     Point point)
                              throws Win32Exception
クライアント座標変換.

パラメータ:
wnd - HWND
point - スクリーン座標(クライアント座標に変換される)
戻り値:
true:成功
例外:
Win32Exception - 失敗時

WindowFromPoint

public static long WindowFromPoint(int x,
                                   int y)
指定位置ウィンドウ取得.

パラメータ:
x - X
y - Y
戻り値:
HWND(ウィンドウが無い場合、null)
関連項目:
ChildWindowFromPoint(long, int, int)

ChildWindowFromPoint

public static long ChildWindowFromPoint(long hwnd,
                                        int x,
                                        int y)
指定位置子ウィンドウ取得.

パラメータ:
x - X(クライアント座標系)
y - Y(クライアント座標系)
戻り値:
HWND(座標が親ウィンドウの外にある場合、null)
関連項目:
ChildWindowFromPointEx(long, int, int, int)

ChildWindowFromPointEx

public static long ChildWindowFromPointEx(long hwnd,
                                          int x,
                                          int y,
                                          int flags)
指定位置子ウィンドウ取得.

パラメータ:
x - X(クライアント座標系)
y - Y(クライアント座標系)
flags - 無視する対象を示すオプション(CWP_*)
戻り値:
HWND(座標が親ウィンドウの外にある場合や失敗した場合、null)

GetWindowLong

public static int GetWindowLong(long hwnd,
                                int index)
                         throws Win32Exception
ウィンドウ情報取得.

パラメータ:
hwnd - HWND
index - 情報のオフセット
戻り値:
情報(32bit)
例外:
Win32Exception - 失敗時
関連項目:
SetParent(long, long)

SetWindowLong

public static int SetWindowLong(long hwnd,
                                int index,
                                int value)
                         throws Win32Exception
ウィンドウ情報設定.

パラメータ:
hwnd - HWND
index - 情報のオフセット
value - 新しい値
戻り値:
変更前の値
例外:
Win32Exception - 失敗時
関連項目:
SetParent(long, long)

GetDesktopWindow

public static long GetDesktopWindow()
デスクトップ取得.

戻り値:
HWND
関連項目:
GetWindow(long, int)

GetParent

public static long GetParent(long wnd)
                      throws Win32Exception
親ウィンドウ取得.

パラメータ:
wnd - HWND
戻り値:
親ウィンドウ(またはオーナーウィンドウ)のHWND
トップレベルウィンドウの場合、0
例外:
Win32Exception - 失敗時
関連項目:
GetAncestor(long, int)

SetParent

public static long SetParent(long wnd,
                             long wndParent)
                      throws Win32Exception
親ウィンドウ設定.

パラメータ:
wnd - HWND
wndParent - 親ウィンドウ(nullの場合、デスクトップ)
戻り値:
直前の親ウィンドウのHWND
例外:
Win32Exception - 失敗時

EnumChildWindows

public static boolean EnumChildWindows(long hwnd,
                                       List list)
                                throws Win32Exception
子ウィンドウ列挙.

パラメータ:
hwnd - HWND
list - 子ウィンドウ(JWnd)が入れられる
戻り値:
true:成功
例外:
Win32Exception - 失敗時
関連項目:
GetWindow(long, int)

EnumWindows

public static boolean EnumWindows(List list)
                           throws Win32Exception
トップレベルウィンドウ列挙.

パラメータ:
list - ウィンドウ(JWnd)が入れられる
戻り値:
true:成功
例外:
Win32Exception - 失敗時
関連項目:
GetWindow(long, int)

FindWindow

public static long FindWindow(String className,
                              String windowName)
                       throws Win32Exception
トップレベルウィンドウ検索.

パラメータ:
className - クラス名
windowName - ウィンドウ名
戻り値:
HWND
例外:
Win32Exception - 失敗時
関連項目:
getClassName(long), getWindowText(long)

getClassName

public static String getClassName(long hwnd)
                           throws Win32Exception
ウィンドウクラス名取得.

パラメータ:
hwnd - HWND
戻り値:
クラス名
例外:
Win32Exception - 失敗時

GetTopWindow

public static long GetTopWindow(long hwnd)
                         throws Win32Exception
一番上の子ウィンドウ取得.

パラメータ:
hwnd - HWND
戻り値:
HWND(子ウィンドウを持たない場合、0)
例外:
Win32Exception - 失敗時

GetNextWindow

public static long GetNextWindow(long hwnd,
                                 int cmd)
                          throws Win32Exception
次ウィンドウ取得.

パラメータ:
hwnd - HWND
cmd - 方向(GW_HWNDNEXT または GW_HWNDPREV)
戻り値:
HWND
例外:
Win32Exception - 失敗時

GetWindow

public static long GetWindow(long wnd,
                             int cmd)
                      throws Win32Exception
ウィンドウ取得.

パラメータ:
wnd - HWND
cmd - 関係(GW_*)
戻り値:
HWND
例外:
Win32Exception - 失敗時

GetAncestor

public static long GetAncestor(long wnd,
                               int flags)
祖先ウィンドウ取得.

パラメータ:
wnd - HWND
flags - パラメータ(GA_*)
戻り値:
HWND
関連項目:
GetParent(long)