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

CreateStatusWindowA

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

シグネチャ

// COMCTL32.dll  (ANSI / -A)
#include <windows.h>

HWND CreateStatusWindowA(
    INT style,
    LPCSTR lpszText,
    HWND hwndParent,
    DWORD wID
);

パラメーター

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

戻り値の型: HWND

公式ドキュメント

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

戻り値

型: HWND

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

解説(Remarks)

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

メモ

commctrl.h ヘッダーは、UNICODE プリプロセッサー定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして CreateStatusWindow を定義します。エンコーディング中立のエイリアスと、エンコーディング中立でないコードを混在して使用すると、不一致が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

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

各言語での呼び出し定義

// COMCTL32.dll  (ANSI / -A)
#include <windows.h>

HWND CreateStatusWindowA(
    INT style,
    LPCSTR lpszText,
    HWND hwndParent,
    DWORD wID
);
[DllImport("COMCTL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreateStatusWindowA(
    int style,   // INT
    [MarshalAs(UnmanagedType.LPStr)] string lpszText,   // LPCSTR
    IntPtr hwndParent,   // HWND
    uint wID   // DWORD
);
<DllImport("COMCTL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreateStatusWindowA(
    style As Integer,   ' INT
    <MarshalAs(UnmanagedType.LPStr)> lpszText As String,   ' LPCSTR
    hwndParent As IntPtr,   ' HWND
    wID As UInteger   ' DWORD
) As IntPtr
End Function
' style : INT
' lpszText : LPCSTR
' hwndParent : HWND
' wID : DWORD
Declare PtrSafe Function CreateStatusWindowA Lib "comctl32" ( _
    ByVal style As Long, _
    ByVal lpszText As String, _
    ByVal hwndParent As LongPtr, _
    ByVal wID As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreateStatusWindowA = ctypes.windll.comctl32.CreateStatusWindowA
CreateStatusWindowA.restype = ctypes.c_void_p
CreateStatusWindowA.argtypes = [
    ctypes.c_int,  # style : INT
    wintypes.LPCSTR,  # lpszText : LPCSTR
    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')
CreateStatusWindowA = Fiddle::Function.new(
  lib['CreateStatusWindowA'],
  [
    Fiddle::TYPE_INT,  # style : INT
    Fiddle::TYPE_VOIDP,  # lpszText : LPCSTR
    Fiddle::TYPE_VOIDP,  # hwndParent : HWND
    -Fiddle::TYPE_INT,  # wID : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "comctl32")]
extern "system" {
    fn CreateStatusWindowA(
        style: i32,  // INT
        lpszText: *const u8,  // LPCSTR
        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.Ansi, SetLastError = true)]
public static extern IntPtr CreateStatusWindowA(int style, [MarshalAs(UnmanagedType.LPStr)] string lpszText, IntPtr hwndParent, uint wID);
"@
$api = Add-Type -MemberDefinition $sig -Name 'COMCTL32_CreateStatusWindowA' -Namespace Win32 -PassThru
# $api::CreateStatusWindowA(style, lpszText, hwndParent, wID)
#uselib "COMCTL32.dll"
#func global CreateStatusWindowA "CreateStatusWindowA" sptr, sptr, sptr, sptr
; CreateStatusWindowA style, lpszText, hwndParent, wID   ; 戻り値は stat
; style : INT -> "sptr"
; lpszText : LPCSTR -> "sptr"
; hwndParent : HWND -> "sptr"
; wID : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "COMCTL32.dll"
#cfunc global CreateStatusWindowA "CreateStatusWindowA" int, str, sptr, int
; res = CreateStatusWindowA(style, lpszText, hwndParent, wID)
; style : INT -> "int"
; lpszText : LPCSTR -> "str"
; hwndParent : HWND -> "sptr"
; wID : DWORD -> "int"
; HWND CreateStatusWindowA(INT style, LPCSTR lpszText, HWND hwndParent, DWORD wID)
#uselib "COMCTL32.dll"
#cfunc global CreateStatusWindowA "CreateStatusWindowA" int, str, intptr, int
; res = CreateStatusWindowA(style, lpszText, hwndParent, wID)
; style : INT -> "int"
; lpszText : LPCSTR -> "str"
; hwndParent : HWND -> "intptr"
; wID : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	comctl32 = windows.NewLazySystemDLL("COMCTL32.dll")
	procCreateStatusWindowA = comctl32.NewProc("CreateStatusWindowA")
)

// style (INT), lpszText (LPCSTR), hwndParent (HWND), wID (DWORD)
r1, _, err := procCreateStatusWindowA.Call(
	uintptr(style),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszText))),
	uintptr(hwndParent),
	uintptr(wID),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HWND
function CreateStatusWindowA(
  style: Integer;   // INT
  lpszText: PAnsiChar;   // LPCSTR
  hwndParent: THandle;   // HWND
  wID: DWORD   // DWORD
): THandle; stdcall;
  external 'COMCTL32.dll' name 'CreateStatusWindowA';
result := DllCall("COMCTL32\CreateStatusWindowA"
    , "Int", style   ; INT
    , "AStr", lpszText   ; LPCSTR
    , "Ptr", hwndParent   ; HWND
    , "UInt", wID   ; DWORD
    , "Ptr")   ; return: HWND
●CreateStatusWindowA(style, lpszText, hwndParent, wID) = DLL("COMCTL32.dll", "void* CreateStatusWindowA(int, char*, void*, dword)")
# 呼び出し: CreateStatusWindowA(style, lpszText, hwndParent, wID)
# style : INT -> "int"
# lpszText : LPCSTR -> "char*"
# hwndParent : HWND -> "void*"
# wID : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "comctl32" fn CreateStatusWindowA(
    style: i32, // INT
    lpszText: [*c]const u8, // LPCSTR
    hwndParent: ?*anyopaque, // HWND
    wID: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc CreateStatusWindowA(
    style: int32,  # INT
    lpszText: cstring,  # LPCSTR
    hwndParent: pointer,  # HWND
    wID: uint32  # DWORD
): pointer {.importc: "CreateStatusWindowA", stdcall, dynlib: "COMCTL32.dll".}
pragma(lib, "comctl32");
extern(Windows)
void* CreateStatusWindowA(
    int style,   // INT
    const(char)* lpszText,   // LPCSTR
    void* hwndParent,   // HWND
    uint wID   // DWORD
);
ccall((:CreateStatusWindowA, "COMCTL32.dll"), stdcall, Ptr{Cvoid},
      (Int32, Cstring, Ptr{Cvoid}, UInt32),
      style, lpszText, hwndParent, wID)
# style : INT -> Int32
# lpszText : LPCSTR -> Cstring
# hwndParent : HWND -> Ptr{Cvoid}
# wID : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* CreateStatusWindowA(
    int32_t style,
    const char* lpszText,
    void* hwndParent,
    uint32_t wID);
]]
local comctl32 = ffi.load("comctl32")
-- comctl32.CreateStatusWindowA(style, lpszText, hwndParent, wID)
-- style : INT
-- lpszText : LPCSTR
-- hwndParent : HWND
-- wID : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('COMCTL32.dll');
const CreateStatusWindowA = lib.func('__stdcall', 'CreateStatusWindowA', 'void *', ['int32_t', 'str', 'void *', 'uint32_t']);
// CreateStatusWindowA(style, lpszText, hwndParent, wID)
// style : INT -> 'int32_t'
// lpszText : LPCSTR -> 'str'
// hwndParent : HWND -> 'void *'
// wID : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("COMCTL32.dll", {
  CreateStatusWindowA: { parameters: ["i32", "buffer", "pointer", "u32"], result: "pointer" },
});
// lib.symbols.CreateStatusWindowA(style, lpszText, hwndParent, wID)
// style : INT -> "i32"
// lpszText : LPCSTR -> "buffer"
// hwndParent : HWND -> "pointer"
// wID : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* CreateStatusWindowA(
    int32_t style,
    const char* lpszText,
    void* hwndParent,
    uint32_t wID);
C, "COMCTL32.dll");
// $ffi->CreateStatusWindowA(style, lpszText, hwndParent, wID);
// style : INT
// lpszText : LPCSTR
// 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.ASCII_OPTIONS);
    Pointer CreateStatusWindowA(
        int style,   // INT
        String lpszText,   // LPCSTR
        Pointer hwndParent,   // HWND
        int wID   // DWORD
    );
}
@[Link("comctl32")]
lib LibCOMCTL32
  fun CreateStatusWindowA = CreateStatusWindowA(
    style : Int32,   # INT
    lpszText : UInt8*,   # LPCSTR
    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 CreateStatusWindowANative = Pointer<Void> Function(Int32, Pointer<Utf8>, Pointer<Void>, Uint32);
typedef CreateStatusWindowADart = Pointer<Void> Function(int, Pointer<Utf8>, Pointer<Void>, int);
final CreateStatusWindowA = DynamicLibrary.open('COMCTL32.dll')
    .lookupFunction<CreateStatusWindowANative, CreateStatusWindowADart>('CreateStatusWindowA');
// style : INT -> Int32
// lpszText : LPCSTR -> Pointer<Utf8>
// hwndParent : HWND -> Pointer<Void>
// wID : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function CreateStatusWindowA(
  style: Integer;   // INT
  lpszText: PAnsiChar;   // LPCSTR
  hwndParent: THandle;   // HWND
  wID: DWORD   // DWORD
): THandle; stdcall;
  external 'COMCTL32.dll' name 'CreateStatusWindowA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

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

let createstatuswindowa =
  foreign "CreateStatusWindowA"
    (int32_t @-> string @-> (ptr void) @-> uint32_t @-> returning (ptr void))
(* style : INT -> int32_t *)
(* lpszText : LPCSTR -> string *)
(* 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 ("CreateStatusWindowA" create-status-window-a :convention :stdcall) :pointer
  (style :int32)   ; INT
  (lpsz-text :string)   ; LPCSTR
  (hwnd-parent :pointer)   ; HWND
  (w-id :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $CreateStatusWindowA = Win32::API::More->new('COMCTL32',
    'HANDLE CreateStatusWindowA(int style, LPCSTR lpszText, HANDLE hwndParent, DWORD wID)');
# my $ret = $CreateStatusWindowA->Call($style, $lpszText, $hwndParent, $wID);
# style : INT -> int
# lpszText : LPCSTR -> LPCSTR
# hwndParent : HWND -> HANDLE
# wID : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い