• Moin,

    hier ein kleines Beispiel wie man seine eigene Fensterklasse und Fensterprozedur erstellt und registriert ...
    (Danke an C. Petzold ... ;))

    Spoiler anzeigen
    [autoit]


    #NoTrayIcon
    #include-once
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #include 'HelloAutoIt.h.au3'
    ;;;

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Global $hWindowProc = DllCallbackRegister('WindowProc', 'long', 'hwnd;uint;wparam;lparam')
    Global $stAppName = DllStructCreate('char szAppName[128]')
    Global $szAppName = DllStructSetData($stAppName, 'szAppName', 'HelloWin')
    Global $hInst = GetModuleHandle()

    [/autoit] [autoit][/autoit] [autoit]

    WinMain()

    [/autoit] [autoit][/autoit] [autoit]

    Func WinMain()

    Global $hWnd
    Global $Msg = DllStructCreate($stMSG)
    Global $WndClassEx = DllStructCreate($stWNDCLASSEX)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    DllStructSetData($WndClassEx,'cbSize', DllStructGetSize($WndClassEx))
    DllStructSetData($WndClassEx,'style', BitOR($CS_HREDRAW, $CS_VREDRAW))
    DllStructSetData($WndClassEx,'lpfnWndProc', DllCallbackGetPtr($hWindowProc))
    DllStructSetData($WndClassEx,'cbClsExtra', 0)
    DllStructSetData($WndClassEx,'cbWndExtra', 0)
    DllStructSetData($WndClassEx,'hInstance', $hInst)
    DllStructSetData($WndClassEx,'hIcon', LoadIcon($NULL, $IDI_APPLICATION))
    DllStructSetData($WndClassEx,'hCursor', LoadCursor($NULL, $IDC_ARROW))
    DllStructSetData($WndClassEx,'hbrBackground', GetStockObject($WHITE_BRUSH))
    DllStructSetData($WndClassEx,'lpszMenuName', $NULL)
    DllStructSetData($WndClassEx,'lpszClassName', DllStructGetPtr($stAppName))
    DllStructSetData($WndClassEx,'hIconSm', LoadIcon($NULL, $IDI_APPLICATION))

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $lpMyWndClass = DllStructGetPtr($WndClassEx)
    $lpMsg = DllStructGetPtr($Msg)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    If Not RegisterClassEx($lpMyWndClass) Then
    MsgBox(266256, Default, 'Die Fensterklasse konnte nicht registriert werden !')
    Exit
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    $hWnd = CreateWindowEx($WS_EX_OVERLAPPEDWINDOW, _
    $szAppName, $szAppName, _
    $WS_OVERLAPPEDWINDOW, _
    $CW_USEDEFAULT, $CW_USEDEFAULT, _
    $CW_USEDEFAULT, $CW_USEDEFAULT, _
    $NULL, $NULL, $hInst, $NULL)

    ShowWindow($hWnd, 5)
    UpdateWindow($hWnd)

    [/autoit] [autoit][/autoit] [autoit]

    While GetMessage($lpMsg, $hWnd, 0, 0)

    TranslateMessage($lpMsg)
    DispatchMessage($lpMsg)

    WEnd

    Return DllStructGetData($Msg, 'wParam')

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc
    ;

    [/autoit] [autoit][/autoit] [autoit]

    Func WindowProc($hWnd, $uMsg, $wParam, $lParam)

    Switch $uMsg

    Case $WM_CREATE
    SoundPlay(@WindowsDir & "\media\tada.wav", 0)
    Return 0;

    Case $WM_PAINT
    $rect = DllStructCreate($stRECT)
    $ps = DllStructCreate($stPAINTSTRUCT)

    $hDC = BeginPaint($hWnd, DllStructGetPtr($ps))

    GetClientRect($hWnd, DllStructGetPtr($rect))

    DrawText($hDC, 'Hello AutoIt3 !', -1, DllStructGetPtr($rect), _
    BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER))

    EndPaint($hWnd, DllStructGetPtr($ps))
    Return 0;

    Case $WM_CLOSE
    DestroyWindow($hWnd)
    Return 0;

    Case $WM_DESTROY
    PostQuitMessage(0)
    Return 0;
    EndSwitch

    Return DefWindowProc($hWnd, $uMsg, $wParam, $lParam)

    EndFunc
    ;

    [/autoit] [autoit][/autoit] [autoit][/autoit]

    Gruß
    Greenhorn