Buchempfehlung
Windows System Programming
Windows System Programming
Das Kompendium liefert viele interessante Informationen zur Windows-Programmierung auf Englisch. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

Steuerelemente... ohne Funktion...

Uploader:Mitgliedraph ael
Datum/Zeit:21.02.2008 21:21:17

#Include "windows.bi"

Declare Function WinMain(hInstance As HINSTANCE, hpi As HINSTANCE,_
        szCmdLine As String, hts As Integer) As Integer

End WinMain(GetModuleHandle(NULL), NULL, Command, SW_SHOW)

Function WndProc(hWnd As HWND, wMsg As UINT, wParam As WPARAM,_
        lParam As LPARAM) As LRESULT

    Select Case wMsg
        Case WM_CREATE
            Return 0
        Case WM_DESTROY
            ExitProcess(0)
            PostQuitMessage(0)
            Return 0
        Case Else
            Return DefWindowProc(hWnd, wMsg, wParam, lParam)
    End Select
End Function

Function WinMain(hInstance As HINSTANCE, hpi As HINSTANCE, szCmdLine As String,_
         hts As Integer) As Integer

    Dim wMsg As MSG
    Dim wCls As WNDCLASS
    Dim hWnd As HWND
    Dim label As HWND
    Dim textbox As HWND
    Dim button As HWND

    With wCls
        .style = CS_HREDRAW Or CS_VREDRAW
        .lpfnWndProc = @WndProc
        .cbClsExtra = 0
        .cbWndExtra = 0
        .hInstance = hInstance
        .hIcon = LoadIcon(NULL, IDI_APPLICATION)
        .hCursor = LoadCursor(NULL, IDC_ARROW)
        .hbrBackground = GetStockObject(LTGRAY_BRUSH)
        .lpszMenuName = NULL
        .lpszClassName = @"Steuerelemente"
    End With

    If RegisterClass(@wCls) = FALSE Then
        MessageBox(NULL, "Konnte Fenterklasse nicht registrieren", "Steuerelemente", MB_OK Or MB_ICONERROR)
        Return 1
    EndIf

    hWnd = CreateWindowEx(0, @"Steuerelemente", "WinAPI: Steuerelemente", WS_OVERLAPPEDWINDOW,_
        CW_USEDEFAULT, CW_USEDEFAULT, 400, 100, NULL, NULL, hInstance, NULL)

    label = CreateWindowEx(0, @"STATIC", "Gib deinen Namen ein:", SS_CENTER Or WS_CHILDWINDOW, 0, 0, 160, 16,_
        hWnd, NULL, hInstance, NULL)

    textbox = CreateWindowEx(0, @"EDIT", "Max Mustermann", WS_CHILDWINDOW, 170, 0, 180, 16,_
        hWnd, NULL, hInstance, NULL)

    button = CreateWindowEx(0, @"BUTTON", "OK", WS_OVERLAPPED Or WS_CHILDWINDOW, 0, 20, 60, 20, hWnd, NULL,_
        hInstance, NULL)

    ShowWindow(hWnd, SW_SHOW)
    ShowWindow(label, SW_SHOW)
    ShowWindow(textbox, SW_SHOW)
    ShowWindow(button, SW_SHOW)
    UpdateWindow(hwnd)
    UpdateWindow(label)
    UpdateWindow(textbox)
    UpdateWindow(button)

    While GetMessage(@wMsg, hWnd, 0, 0) <> FALSE
        TranslateMessage(@wMsg)
        DispatchMessage(@wMsg)
    Wend

    Return wMsg.wParam
End Function