Code: Select all
#Include "windows.bi"
Dim Shared as Handle hEdit
Function WndProc(hWnd As HWND, msg As UINT, wParam As WPARAM, lParam As LPARAM) As LRESULT
Dim As RECT rc
Dim As PAINTSTRUCT ps
Dim As HANDLE PtDC
Select Case msg
Case WM_CREATE
hEdit=CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "Hello, I am an edit control",_
WS_CHILD Or WS_VISIBLE or ES_MULTILINE, 0, 0, 100, 100, hWnd, 100, 0, 0)
Case WM_PAINT
PtDC=BeginPaint(hWnd, @ps)
TextOut(PtDC, 3, 3, "TextOut in the WM_PAINT handler", 31)
EndPaint(hWnd, @ps)
Case WM_KEYDOWN
if wParam=VK_ESCAPE then SendMessage(hWnd, WM_CLOSE, 0, 0)
Case WM_SIZE
GetClientRect(hWnd, @rc)
MoveWindow(hEdit, 3, 23, rc.right-6, rc.bottom-26, 0)
Case WM_DESTROY
PostQuitMessage(0)
End Select
return DefWindowProc(hwnd, msg, wParam, lParam)
End Function
Function WinMain(hInstance As HINSTANCE, hPrevInstance As HINSTANCE, lpCmdLine As LPSTR, nShowCmd As Integer) As Integer
Dim As WNDCLASSEX wc
Dim As MSG msg
Dim As string classname="FbGui"
wc.cbSize = sizeof(WNDCLASSEX)
wc.hbrBackground = COLOR_BTNFACE+1
wc.hCursor = LoadCursor(0, IDC_ARROW)
wc.hIcon = LoadIcon(hInstance, IDI_APPLICATION)
wc.hIconSm = wc.hIcon
wc.hInstance = hInstance
wc.lpfnWndProc = @WndProc
wc.lpszClassName = StrPtr(classname)
wc.style = CS_HREDRAW Or CS_VREDRAW
RegisterClassEx(@wc)
if CreateWindowEx(0, wc.lpszClassName, "Hello World",_
WS_OVERLAPPEDWINDOW Or WS_VISIBLE, (GetSystemMetrics(SM_CXSCREEN) / 2) - 150,_
(GetSystemMetrics(SM_CYSCREEN) / 2) - 150, 300, 300, 0, 0, hInstance, 0)=0 then
MessageBox(0, "Creating hMain failed miserably", 0, MB_OK)
return 0
End If
While GetMessage(@msg, 0, 0, 0)
TranslateMessage(@msg)
DispatchMessage(@msg)
Wend
return msg.wParam
End Function
WinMain(GetModuleHandle(NULL), NULL, COMMAND(), SW_NORMAL)