Win32 API 日本語リファレンス
ホームUI.Controls › CreateStatusWindowW

CreateStatusWindowW

関数
ステータスウィンドウを作成する(Unicode版)。
DLLCOMCTL32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows Vista 以降

シグネチャ

// COMCTL32.dll  (Unicode / -W)
#include <windows.h>

HWND CreateStatusWindowW(
    INT style,
    LPCWSTR lpszText,
    HWND hwndParent,
    DWORD wID
);

パラメーター

名前方向説明
styleINTinステータスウィンドウのウィンドウスタイル。このパラメーターには WS_CHILD スタイルを含める必要があり、WS_VISIBLE スタイルも含めることを推奨します。
lpszTextLPCWSTRin最初のパートのステータステキストを指定する、null で終わる文字列へのポインター。
hwndParentHWNDin親ウィンドウへのハンドル。
wIDDWORDinステータスウィンドウのコントロール識別子。ウィンドウプロシージャは、この値を使用して親ウィンドウに送信するメッセージを識別します。

戻り値の型: HWND

公式ドキュメント

ステータスウィンドウを作成します。通常、アプリケーションの状態を表示するために使用されます。(Unicode)

戻り値

型: HWND

成功した場合はステータスウィンドウへのハンドルを返し、それ以外の場合は NULL を返します。拡張エラー情報を取得するには、GetLastError を呼び出します。

解説(Remarks)

CreateStatusWindow 関数は、ウィンドウを作成するために CreateWindow 関数を呼び出します。パラメーターは変更せずに渡され、位置・幅・高さの各パラメーターは CreateWindow の既定値に設定されます。

メモ

commctrl.h ヘッダーは、CreateStatusWindow を、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング非依存のエイリアスを、エンコーディング非依存ではないコードと混在して使用すると、不一致が生じ、コンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規約を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// COMCTL32.dll  (Unicode / -W)
#include <windows.h>

HWND CreateStatusWindowW(
    INT style,
    LPCWSTR lpszText,
    HWND hwndParent,
    DWORD wID
);
[DllImport("COMCTL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateStatusWindowW(
    int style,   // INT
    [MarshalAs(UnmanagedType.LPWStr)] string lpszText,   // LPCWSTR
    IntPtr hwndParent,   // HWND
    uint wID   // DWORD
);
<DllImport("COMCTL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateStatusWindowW(
    style As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPWStr)> lpszText As String,   ' LPCWSTR
    hwndParent As IntPtr,   ' HWND
    wID As UInteger   ' DWORD
) As IntPtr
End Function
' style : INT
' lpszText : LPCWSTR
' hwndParent : HWND
' wID : DWORD
Declare PtrSafe Function CreateStatusWindowW Lib "comctl32" ( _
    ByVal style As Long, _
    ByVal lpszText As LongPtr, _
    ByVal hwndParent As LongPtr, _
    ByVal wID As Long) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateStatusWindowW = ctypes.windll.comctl32.CreateStatusWindowW
CreateStatusWindowW.restype = ctypes.c_void_p
CreateStatusWindowW.argtypes = [
    ctypes.c_int,  # style : INT
    wintypes.LPCWSTR,  # lpszText : LPCWSTR
    wintypes.HANDLE,  # hwndParent : HWND
    wintypes.DWORD,  # wID : DWORD
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('COMCTL32.dll')
CreateStatusWindowW = Fiddle::Function.new(
  lib['CreateStatusWindowW'],
  [
    Fiddle::TYPE_INT,  # style : INT
    Fiddle::TYPE_VOIDP,  # lpszText : LPCWSTR
    Fiddle::TYPE_VOIDP,  # hwndParent : HWND
    -Fiddle::TYPE_INT,  # wID : DWORD
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "comctl32")]
extern "system" {
    fn CreateStatusWindowW(
        style: i32,  // INT
        lpszText: *const u16,  // LPCWSTR
        hwndParent: *mut core::ffi::c_void,  // HWND
        wID: u32  // DWORD
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("COMCTL32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr CreateStatusWindowW(int style, [MarshalAs(UnmanagedType.LPWStr)] string lpszText, IntPtr hwndParent, uint wID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_CreateStatusWindowW' -Namespace Win32 -PassThru
# $api::CreateStatusWindowW(style, lpszText, hwndParent, wID)
#uselib "COMCTL32.dll"
#func global CreateStatusWindowW "CreateStatusWindowW" wptr, wptr, wptr, wptr
; CreateStatusWindowW style, lpszText, hwndParent, wID   ; 戻り値は stat
; style : INT -> "wptr"
; lpszText : LPCWSTR -> "wptr"
; hwndParent : HWND -> "wptr"
; wID : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global CreateStatusWindowW "CreateStatusWindowW" int, wstr, sptr, int
; res = CreateStatusWindowW(style, lpszText, hwndParent, wID)
; style : INT -> "int"
; lpszText : LPCWSTR -> "wstr"
; hwndParent : HWND -> "sptr"
; wID : DWORD -> "int"
; HWND CreateStatusWindowW(INT style, LPCWSTR lpszText, HWND hwndParent, DWORD wID)
#uselib "COMCTL32.dll"
#cfunc global CreateStatusWindowW "CreateStatusWindowW" int, wstr, intptr, int
; res = CreateStatusWindowW(style, lpszText, hwndParent, wID)
; style : INT -> "int"
; lpszText : LPCWSTR -> "wstr"
; hwndParent : HWND -> "intptr"
; wID : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procCreateStatusWindowW = comctl32.NewProc("CreateStatusWindowW")
)

// style (INT), lpszText (LPCWSTR), hwndParent (HWND), wID (DWORD)
r1, _, err := procCreateStatusWindowW.Call(
	uintptr(style),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpszText))),
	uintptr(hwndParent),
	uintptr(wID),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HWND
function CreateStatusWindowW(
  style: Integer;   // INT
  lpszText: PWideChar;   // LPCWSTR
  hwndParent: THandle;   // HWND
  wID: DWORD   // DWORD
): THandle; stdcall;
  external 'COMCTL32.dll' name 'CreateStatusWindowW';
result := DllCall("COMCTL32\CreateStatusWindowW"
    , "Int", style   ; INT
    , "WStr", lpszText   ; LPCWSTR
    , "Ptr", hwndParent   ; HWND
    , "UInt", wID   ; DWORD
    , "Ptr")   ; return: HWND
●CreateStatusWindowW(style, lpszText, hwndParent, wID) = DLL("COMCTL32.dll", "void* CreateStatusWindowW(int, char*, void*, dword)")
# 呼び出し: CreateStatusWindowW(style, lpszText, hwndParent, wID)
# style : INT -> "int"
# lpszText : LPCWSTR -> "char*"
# hwndParent : HWND -> "void*"
# wID : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "comctl32" fn CreateStatusWindowW(
    style: i32, // INT
    lpszText: [*c]const u16, // LPCWSTR
    hwndParent: ?*anyopaque, // HWND
    wID: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc CreateStatusWindowW(
    style: int32,  # INT
    lpszText: WideCString,  # LPCWSTR
    hwndParent: pointer,  # HWND
    wID: uint32  # DWORD
): pointer {.importc: "CreateStatusWindowW", stdcall, dynlib: "COMCTL32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "comctl32");
extern(Windows)
void* CreateStatusWindowW(
    int style,   // INT
    const(wchar)* lpszText,   // LPCWSTR
    void* hwndParent,   // HWND
    uint wID   // DWORD
);
ccall((:CreateStatusWindowW, "COMCTL32.dll"), stdcall, Ptr{Cvoid},
      (Int32, Cwstring, Ptr{Cvoid}, UInt32),
      style, lpszText, hwndParent, wID)
# style : INT -> Int32
# lpszText : LPCWSTR -> Cwstring
# hwndParent : HWND -> Ptr{Cvoid}
# wID : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
void* CreateStatusWindowW(
    int32_t style,
    const uint16_t* lpszText,
    void* hwndParent,
    uint32_t wID);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.CreateStatusWindowW(style, lpszText, hwndParent, wID)
-- style : INT
-- lpszText : LPCWSTR
-- hwndParent : HWND
-- wID : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const CreateStatusWindowW = lib.func('__stdcall', 'CreateStatusWindowW', 'void *', ['int32_t', 'str16', 'void *', 'uint32_t']);
// CreateStatusWindowW(style, lpszText, hwndParent, wID)
// style : INT -> 'int32_t'
// lpszText : LPCWSTR -> 'str16'
// hwndParent : HWND -> 'void *'
// wID : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("COMCTL32.dll", {
  CreateStatusWindowW: { parameters: ["i32", "buffer", "pointer", "u32"], result: "pointer" },
});
// lib.symbols.CreateStatusWindowW(style, lpszText, hwndParent, wID)
// style : INT -> "i32"
// lpszText : LPCWSTR -> "buffer"
// hwndParent : HWND -> "pointer"
// wID : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* CreateStatusWindowW(
    int32_t style,
    const uint16_t* lpszText,
    void* hwndParent,
    uint32_t wID);
C, "COMCTL32.dll");
// $ffi->CreateStatusWindowW(style, lpszText, hwndParent, wID);
// style : INT
// lpszText : LPCWSTR
// hwndParent : HWND
// wID : DWORD
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。
import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;

public interface Comctl32 extends StdCallLibrary {
    Comctl32 INSTANCE = Native.load("comctl32", Comctl32.class, W32APIOptions.UNICODE_OPTIONS);
    Pointer CreateStatusWindowW(
        int style,   // INT
        WString lpszText,   // LPCWSTR
        Pointer hwndParent,   // HWND
        int wID   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("comctl32")]
lib LibCOMCTL32
  fun CreateStatusWindowW = CreateStatusWindowW(
    style : Int32,   # INT
    lpszText : UInt16*,   # LPCWSTR
    hwndParent : Void*,   # HWND
    wID : UInt32   # DWORD
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef CreateStatusWindowWNative = Pointer<Void> Function(Int32, Pointer<Utf16>, Pointer<Void>, Uint32);
typedef CreateStatusWindowWDart = Pointer<Void> Function(int, Pointer<Utf16>, Pointer<Void>, int);
final CreateStatusWindowW = DynamicLibrary.open('COMCTL32.dll')
    .lookupFunction<CreateStatusWindowWNative, CreateStatusWindowWDart>('CreateStatusWindowW');
// style : INT -> Int32
// lpszText : LPCWSTR -> Pointer<Utf16>
// hwndParent : HWND -> Pointer<Void>
// wID : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateStatusWindowW(
  style: Integer;   // INT
  lpszText: PWideChar;   // LPCWSTR
  hwndParent: THandle;   // HWND
  wID: DWORD   // DWORD
): THandle; stdcall;
  external 'COMCTL32.dll' name 'CreateStatusWindowW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "CreateStatusWindowW"
  c_CreateStatusWindowW :: Int32 -> CWString -> Ptr () -> Word32 -> IO (Ptr ())
-- style : INT -> Int32
-- lpszText : LPCWSTR -> CWString
-- hwndParent : HWND -> Ptr ()
-- wID : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let createstatuswindoww =
  foreign "CreateStatusWindowW"
    (int32_t @-> (ptr uint16_t) @-> (ptr void) @-> uint32_t @-> returning (ptr void))
(* style : INT -> int32_t *)
(* lpszText : LPCWSTR -> (ptr uint16_t) *)
(* hwndParent : HWND -> (ptr void) *)
(* wID : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library comctl32 (t "COMCTL32.dll"))
(cffi:use-foreign-library comctl32)

(cffi:defcfun ("CreateStatusWindowW" create-status-window-w :convention :stdcall) :pointer
  (style :int32)   ; INT
  (lpsz-text (:string :encoding :utf-16le))   ; LPCWSTR
  (hwnd-parent :pointer)   ; HWND
  (w-id :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateStatusWindowW = Win32::API::More->new('COMCTL32',
    'HANDLE CreateStatusWindowW(int style, LPCWSTR lpszText, HANDLE hwndParent, DWORD wID)');
# my $ret = $CreateStatusWindowW->Call($style, $lpszText, $hwndParent, $wID);
# style : INT -> int
# lpszText : LPCWSTR -> LPCWSTR
# hwndParent : HWND -> HANDLE
# wID : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い