fb:porticula NoPaste
inc\CreateGroupBox.bas
Uploader: | Eternal_Pain |
Datum/Zeit: | 19.03.2014 04:41:07 |
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Windows Easy Gui (WEG), zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
Sub Item_Group.Destroy()
ID = "" : Title = ""
DestroyWindow(whwnd)
DeleteObject(FontBrush)
whwnd = 0 : FontColor = 0
FontBKColor = 0 : FontBrush = 0
End Sub
'Groupbox
Function CreateGroupBox(byref parent as Item, byval px as integer, byval py as integer, byval w as integer, byval h as integer, byval title as string, byval FontColor as Integer = &h000000, byval FontBkColor as Integer = TRANSPARENT) as Item
Dim as UInteger ExStyle = WS_EX_LEFT OR WS_EX_LTRREADING OR WS_EX_NOPARENTNOTIFY OR WS_EX_TOPMOST OR WS_EX_NOINHERITLAYOUT OR WS_EX_CONTROLPARENT OR WS_EX_TRANSPARENT
Dim as UInteger Style = WS_CHILD OR WS_VISIBLE OR BS_GROUPBOX OR WS_GROUP OR WS_CLIPSIBLINGS OR WS_CLIPCHILDREN
If parent=0 Then return NULL
Dim as HWND phwnd
Dim as Item SubParent
Select Case parent -> ID
Case WindowID
phwnd = parent -> whwnd
SubParent = parent
Case GroupBoxID
LOGSTRING(Time & " | ----- | GroupBox can not add as Child in a GroupBox!")
SubParent = Cast(any ptr,GetWindowLongPtr(GetParent(parent -> whwnd), GWLP_USERDATA))
If SubParent andalso SubParent -> ID = WindowID Then
phwnd = SubParent -> whwnd
Else
LOGSTRING(Time & " | ERROR | Could not find any Window to add GroupBox!")
return 0
End If
Case Else
LOGSTRING(Time & " | ERROR | Parent is not an valid Item.")
Return 0
End Select
Dim as Item_Group ptr group = NEW Item_Group
group -> whwnd = CreateWindowEx( ExStyle, "BUTTON", title, Style, px, py, w, h, _
phwnd, Cast(HMENU,123), Globals.hInstance, 0)
If (group = 0) Then
LOGSTRING(Time & " | ERROR | Failed to create " & GroupBoxID & " " & title)
MessageBox(NULL,"Failed to create " & GroupBoxID & " " & title, "Error", NULL)
Delete group
Return NULL
End If
SendMessage(group -> whwnd, WM_SETFONT, Cast(WPARAM, Globals.hFont), Cast(LPARAM,TRUE))
SetWindowLongPtr(group -> whwnd, GWLP_USERDATA, cast(LONG_PTR,group))
group -> ID = GroupBoxID
group -> Title = title
group -> FontColor = Convert_RGB_To_BGR(FontColor)
group -> FontBKColor = TRANSPARENT
If FontBKColor<>TRANSPARENT Then
group -> FontBKColor = Convert_RGB_To_BGR(FontBKColor)
group -> FontBrush = CreateSolidBrush(group -> FontBKColor)
End If
LOGSTRING(Time & " | INFO | " & GroupBoxID & " " & title & " created on " & SubParent -> ID & " " & SubParent -> Title & ".")
Globals.ItemList.AddItem(group)
return group
End Function