Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
85
Task/Window-management/FreeBASIC/window-management.basic
Normal file
85
Task/Window-management/FreeBASIC/window-management.basic
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
#include "windows.bi"
|
||||
|
||||
Function WindowProc(Byval hWnd As HWND, Byval uMsg As UINT, Byval wParam As WPARAM, Byval lParam As LPARAM) As LRESULT
|
||||
Select Case uMsg
|
||||
Case WM_DESTROY
|
||||
PostQuitMessage(0)
|
||||
Return 0
|
||||
Case Else
|
||||
Return DefWindowProc(hWnd, uMsg, wParam, lParam)
|
||||
End Select
|
||||
End Function
|
||||
|
||||
Function CreateSimpleWindow(titulo As String, ancho As Integer, alto As Integer) As HWND
|
||||
Dim As HWND hWnd
|
||||
Dim As WNDCLASS wc
|
||||
|
||||
wc.style = CS_HREDRAW Or CS_VREDRAW
|
||||
wc.lpfnWndProc = @WindowProc
|
||||
wc.cbClsExtra = 0
|
||||
wc.cbWndExtra = 0
|
||||
wc.hInstance = GetModuleHandle(NULL)
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION)
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW)
|
||||
wc.hbrBackground = GetStockObject(WHITE_BRUSH)
|
||||
wc.lpszMenuName = NULL
|
||||
wc.lpszClassName = @"SimpleWindowClass"
|
||||
|
||||
RegisterClass(@wc)
|
||||
|
||||
hWnd = CreateWindowEx(0, @"SimpleWindowClass", titulo, WS_OVERLAPPEDWINDOW, _
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, ancho, alto, NULL, NULL, _
|
||||
GetModuleHandle(NULL), NULL)
|
||||
|
||||
ShowWindow(hWnd, SW_SHOW)
|
||||
UpdateWindow(hWnd)
|
||||
|
||||
Return hWnd
|
||||
End Function
|
||||
|
||||
Dim As HWND hWnd = CreateSimpleWindow("Rosetta code", 400, 300)
|
||||
|
||||
If hWnd = 0 Then
|
||||
Print "Error: Could not create window.."
|
||||
Else
|
||||
Print "Let's go... "
|
||||
|
||||
Print "Show window"
|
||||
ShowWindow(hWnd, SW_SHOW)
|
||||
Sleep 1000
|
||||
|
||||
Print "Hide window"
|
||||
ShowWindow(hWnd, SW_HIDE)
|
||||
Sleep 1000
|
||||
|
||||
Print "Minimize window"
|
||||
ShowWindow(hWnd, SW_MINIMIZE)
|
||||
Sleep 1000
|
||||
|
||||
Print "Maximize window"
|
||||
ShowWindow(hWnd, SW_MAXIMIZE)
|
||||
Sleep 1000
|
||||
|
||||
Print "Restore window"
|
||||
ShowWindow(hWnd, SW_RESTORE)
|
||||
Sleep 1000
|
||||
|
||||
Print "Move window"
|
||||
MoveWindow(hWnd, 100, 100, 800, 600, True)
|
||||
Sleep 1000
|
||||
|
||||
Print "Resize the window"
|
||||
MoveWindow(hWnd, 100, 100, 400, 300, True)
|
||||
Sleep 1000
|
||||
|
||||
Print "Close window"
|
||||
PostMessage(hWnd, WM_CLOSE, 0, 0)
|
||||
End If
|
||||
|
||||
Dim uMsg As MSG
|
||||
While GetMessage(@uMsg, NULL, NULL, NULL)
|
||||
TranslateMessage(@uMsg)
|
||||
DispatchMessage(@uMsg)
|
||||
Wend
|
||||
|
||||
Print "That's all folks!"
|
||||
Loading…
Add table
Add a link
Reference in a new issue