42 lines
1.6 KiB
Plaintext
42 lines
1.6 KiB
Plaintext
#Include "windows.bi"
|
|
|
|
Dim As HWND Window_Main, Edit_Number, Button_Inc, Button_Rnd
|
|
Dim As MSG msg
|
|
Dim As Integer n
|
|
Dim As String text
|
|
|
|
'Create a window with an input field and two buttons:
|
|
Window_Main = CreateWindow("#32770", "GUI Component Interaction", WS_OVERLAPPEDWINDOW Or WS_VISIBLE, 100, 100, 250, 200, 0, 0, 0, 0)
|
|
Var Static_Number = CreateWindow("STATIC", "Value:", WS_VISIBLE Or WS_CHILD, 10, 10, 100, 20, Window_Main, 0, 0, 0)
|
|
Edit_Number = CreateWindow("EDIT", "0", WS_BORDER Or WS_VISIBLE Or WS_CHILD Or ES_AUTOHSCROLL Or ES_Number, 110, 10, 100, 20, Window_Main, 0, 0, 0)
|
|
Button_Inc = CreateWindow("BUTTON", "Increment", WS_VISIBLE Or WS_CHILD, 110, 40, 100, 20, Window_Main, 0, 0, 0)
|
|
Button_Rnd = CreateWindow("BUTTON", "Random", WS_VISIBLE Or WS_CHILD, 110, 70, 100, 20, Window_Main, 0, 0, 0)
|
|
|
|
'Windows message loop:
|
|
While GetMessage(@msg, Window_Main, 0, 0)
|
|
TranslateMessage(@msg)
|
|
DispatchMessage(@msg)
|
|
Select Case msg.hwnd
|
|
Case Button_Inc
|
|
If msg.message = WM_LBUTTONDOWN Then
|
|
'Increment value:
|
|
text = Space(GetWindowTextLength(Edit_Number) + 1) 'Buffer for the text
|
|
GetWindowText(Edit_Number, text, Len(text))
|
|
n = Val(text)
|
|
SetWindowText(Edit_Number, Str(n + 1))
|
|
End If
|
|
Case Button_Rnd
|
|
If msg.message = WM_LBUTTONDOWN THEN
|
|
'Random value (max. 100000):
|
|
If MessageBox(0, "Set input field to random value?", "Please confirm", MB_ICONQUESTION Or MB_YESNO) = IDYES Then
|
|
n = 100000 * RND
|
|
SetWindowText(Edit_Number, Str(n))
|
|
End If
|
|
End If
|
|
Case Window_Main
|
|
If msg.message = WM_COMMAND Then End
|
|
End Select
|
|
Wend
|
|
|
|
End
|