Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [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

inc\CreateCheckBox.bas

Uploader:MitgliedEternal_Pain
Datum/Zeit:19.03.2014 04:42:33
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Windows Easy Gui (WEG), zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.

Type Item_Check EXTENDS Item_Node
    Declare Sub Destroy()
End Type

Sub Item_Check.Destroy()
    ID = "" : Title = ""
    DestroyWindow(whwnd)
    whwnd = 0
End Sub

Function CreateCheckBox(byref ItemHandle as Item, byval px as Integer, byval py as Integer, byval txt as String="") as Item
    Dim as UInteger ExStyle = WS_EX_TRANSPARENT
    Dim as UInteger Style   = WS_VISIBLE OR WS_CHILD OR WS_CLIPSIBLINGS OR WS_TABSTOP OR BS_AUTOCHECKBOX

    If (ItemHandle = 0) Then return NULL

    Dim as RECT    prect
    Dim as HWND    phwnd
    Dim as Integer rx, ry

    If (ItemHandle -> ID = WindowID) Then
        phwnd = ItemHandle -> whwnd
        rx = px : ry = py
    ElseIf (ItemHandle -> ID = GroupBoxID) Then
        phwnd = GetParent(ItemHandle -> whwnd)
        GetClientRect(ItemHandle -> whwnd, @prect)
        MapWindowPoints(ItemHandle -> whwnd, phwnd, Cast(LPPOINT, @prect),2)
        rx = prect.left + px : ry = prect.top + py
    Else
        LOGSTRING(Time & " | ERROR | Parent is not an valid Item.")
        Return NULL
    End If

    Dim as Item_Check ptr newCheckBox = new Item_Check
    Dim as SIZE     cSIZE
    Dim as HDC      cDC  = GetDC(phwnd)
    Dim as String   dtxt = " "+txt

    GetTextExtentPoint32(cDC,dtxt,len(txt),@cSIZE)
    If cSIZE.cy<15 Then cSize.cy=15

    newCheckBox -> whwnd = CreateWindowEx(NULL, "BUTTON", txt, Style, rx, ry, 30+cSIZE.cx, cSIZE.cy, phwnd, NULL, Globals.hInstance, newCheckBox)

    If (NewCheckBox -> whwnd = 0) Then
        Delete newCheckBox
        LOGSTRING(Time & " | ERROR | Failed to create " & CheckBoxID)
        MessageBox(NULL,"Failed to create " & CheckBoxID, "Error", NULL)
        Return NULL
    End If

    SendMessage(newCheckBox -> whwnd, WM_SETFONT, Cast(WPARAM, Globals.hFont), Cast(LPARAM,TRUE))

    SetWindowLongPtr(newCheckBox -> whwnd, GWLP_USERDATA, Cast(LONG_PTR, newCheckBox))

    newCheckBox -> ID    = CheckBoxID
    newCheckBox -> Title = txt

    LOGSTRING(Time & " | INFO  | " & CheckBoxID & " " & newCheckBox -> Title & " created on " & ItemHandle -> ID & " " & ItemHandle -> Title & ".")

    Globals.ItemList.AddItem(newCheckBox)

    return newCheckBox
End Function

Function GetCheckBoxState(byref CheckBox as Item) as Integer
    If CheckBox = 0 orelse CheckBox -> ID <> CheckBoxID Then return NULL

    If (SendMessage(CheckBox -> whwnd, BM_GETCHECK, 0, 0) = BST_CHECKED) Then return TRUE
    return FALSE
End Function

Sub SetCheckBoxState(byref CheckBox as Item, byval State as Integer)
    If CheckBox andalso CheckBox -> ID = CheckBoxID Then
        If State Then
            SendMessage(CheckBox -> whwnd, BM_SETCHECK, BST_CHECKED,0)
        Else
            SendMessage(CheckBox -> whwnd, BM_SETCHECK, BST_UNCHECKED,0)
        End If
    End If
End Sub