fb:porticula NoPaste
inc\CreateEditBox.bas
Uploader: | Eternal_Pain |
Datum/Zeit: | 19.03.2014 04:41:44 |
Hinweis: Dieser Quelltext ist Bestandteil des Projekts Windows Easy Gui (WEG), zu dem es auf FreeBASIC-Portal.de eine Projektseite gibt.
Type Item_Edit EXTENDS Item_Node
Declare Sub Destroy()
End Type
Sub Item_Edit.Destroy()
ID = "" : Title = ""
DestroyWindow(whwnd)
whwnd = 0
End Sub
Function CreateEditBox(byref ItemHandle as Item, byval px as Integer, byval py as Integer, byval iWidth as UInteger = 125, byval txt as String="") as Item
Dim as UInteger ExStyle = WS_EX_CLIENTEDGE
Dim as UInteger Style = WS_VISIBLE OR WS_CHILD OR ES_LEFT OR WS_CLIPSIBLINGS OR WS_TABSTOP OR ES_AUTOHSCROLL
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_Edit ptr newEditBox = new Item_Edit
newEditBox -> whwnd = CreateWindowEx(ExStyle, "EDIT", txt, Style, rx, ry, iWidth, 25, phwnd, NULL, Globals.hInstance, newEditBox)
If (newEditBox -> whwnd = 0) Then
Delete newEditBox
LOGSTRING(Time & " | ERROR | Failed to create " & EditBoxID)
MessageBox(NULL,"Failed to create " & EditBoxID, "Error", NULL)
Return NULL
End If
SendMessage(newEditBox -> whwnd, WM_SETFONT, Cast(WPARAM, Globals.hFont), Cast(LPARAM,TRUE))
SetWindowLongPtr(newEditBox -> whwnd, GWLP_USERDATA, Cast(LONG_PTR, newEditBox))
SendMessage(newEditBox -> whwnd, EM_LIMITTEXT, Cast(WPARAM, 255), NULL) 'Set Char Limit
SendMessage(newEditBox -> whwnd, DM_SETDEFID, Cast(wParam,IDOK), NULL)
newEditBox -> ID = EditBoxID
newEditBox -> Title = str(newEditBox -> whwnd)
LOGSTRING(Time & " | INFO | " & EditBoxID & " " & newEditBox -> Title & " created on " & ItemHandle -> ID & " " & ItemHandle -> Title & ".")
Globals.ItemList.AddItem(newEditBox)
return newEditBox
End Function