RegisterClassEx

機能
ウィンドウクラスを登録する
Declare Function RegisterClassEx Lib "user32"  _
Alias "RegisterClassExA" (wcl As WNDCLASSEX) As Long
Declare Function RegisterClassEx Lib "user32"  _
Alias "RegisterClassExA" (wcl As WNDCLASSEX) As Integer

ATOM RegisterClassEx(
CONST WNDCLASSEX *lpwcx
);
引数
wcl

登録するウィンドウクラスの情報を含むWNDCLASSEX構造体
戻り値
OKボタンを押したとき  0以外
キャンセル or クローズのとき 0
サンプル
ダウンロード(RegisterClassEx.lzh 7.85KB)

Public Sub Main() '<-----------C++では「WinMain」に当たる
Dim hWnd As Long, MSG As Message, wcl As WNDCLASSEX
Dim ClassName As String, hParentWnd As Long

'クラス名
ClassName = "Test"
With wcl
    .cbSize = Len(wcl)
    .hInstance = App.hInstance
    .lpszClassName = ClassName
    .lpfnWndProc = ChangeAddressOf(AddressOf TestProc)
    .style = 0
    
    .hIcon = LoadIcon(0, ByVal IDI_APPLICATION)
    .hIconSm = LoadIcon(0, ByVal IDI_APPLICATION)
    .hCursor = LoadCursor(0, 32512)
    .lpszMenuName = 0
    .cbClsExtra = 0
    .cbWndExtra = 0
    .hbrBackground = GetStockObject(LTGRAY_BRUSH)
End With
Call RegisterClassEx(wcl)

hParentWnd = CreateWindowEx(WS_EX_APPWINDOW Or WS_EX_WINDOWEDGE _
        , wcl.lpszClassName, "Now Testing!", _
        WS_CAPTION Or WS_VISIBLE Or WS_SYSMENU Or WS_MINIMIZEBOX _
        , CW_USEDEFAULT _
        , CW_USEDEFAULT _
        , 500 _
        , 400 _
        , 0, 0, App.hInstance, 0)
Call ShowWindow(hParentWnd, SW_SHOW)
Call UpdateWindow(hParentWnd)

Do While (GetMessage(MSG, 0, 0, 0))
    Call TranslateMessage(MSG)
    Call DispatchMessage(MSG)
Loop
End Sub

Public Function TestProc(ByVal hWnd As Long, ByVal MSG As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Select Case MSG Case WM_CREATE '--------初期化 Case WM_DESTROY '終了 Call DestroyWindow(hWnd) PostQuitMessage (0) End Select TestProc = DefWindowProc(hWnd, MSG, wParam, lParam) End Function
Public Function ChangeAddressOf(ByVal Address As Long) As Long 'AddressOf演算子は変数として使えないので、間接的に使えるようにする ChangeAddressOf = Address End Function