|
Post by pablosl on Jun 15, 2024 14:17:32 GMT -5
Hello. I am trying to put the MAINWIN as a child window of my own #main Window. I came up with this code. The problem is, after put the MAINWIN as a child, I cannot PRINT or INPUT like I usually do with the normal MAINWIN. Can somebody make corrections to this?.
'Simplified MDI window, MAINWIN as Child of my own win #main
'(to interact in text mode?)
'Problem to correct: After make as a child, the MAINWIN is not responding.
CALLDLL #user32, "GetActiveWindow", mainwinhandle as long ' return mainwindow handle
TITLEBAR "My Console"
WindowWidth=350 : WindowHeight=350
childWide=550 : childHigh=300 'child window dims
MENU #main, "&File", "&Quit",[quit]
OPEN "Main Parent Window" for window as #main
PRINT #main, "trapclose [quit]"
PRINT #main, "resizehandler [resize]"
hMain=hwnd(#main) 'main window handle
calldll #user32, "GetWindowLongA",_
hMain as uLong,_ 'handle of window
_GWl_HINSTANCE as long,_ 'flag for instance handle
hInstance as uLONG 'returns instance handle of window
dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _
_WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control
CALLDLL #user32, "CreateWindowExA",_
0 as long,_ 'extended class style
"MDICLIENT" as ptr,_ 'class name
"" as ptr,_ 'title or string
dwStyle as long,_ 'window style
2 as long,_ 'x org
2 as long,_ 'y org
339 as long,_ 'width
302 as long,_ 'height
hMain as ulong,_ 'parent window
0 as ulong,_ 'handle to menu = 0 for class menu
hInstance as ulong,_ 'instance handle of parent window
"" as ptr,_ 'always NULL
hMDI as ulong 'returns handle of MDI Client
hChild=mainwinhandle ' handle of MainWin
CALLDLL #user32, "SetParent",_
hChild as ulong,_ 'make popup the child
hMDI as ulong,_ 'make MDI the parent
result as long
'use MoveWindow to force window resize
'so scrollbars will show
CALLDLL #user32, "MoveWindow",hMain As uLong,_
11 As Long, 11 As Long,_
333 As Long, 333 As Long,_
1 As long, r As long
PRINT
PRINT " Hello"
PRINT
INPUT " >";ANSWER$
PRINT ANSWER$
WAIT
[resize]
newWide=WindowWidth-4
newHigh=WindowHeight-4
ret=MoveWindow(hMDI,2,2,newWide,newHigh)
ret=MoveWindow(hChild,0,0,childWide,childHigh)
WAIT
[quit]
'CLOSE MAINWIN #child? but HOW?
CLOSE #main
END
Function MoveWindow(hWnd,x,y,wide,high)
CallDLL #user32, "MoveWindow",_
hWnd As uLong,_ 'handle
x As Long, y As Long,_ 'x,y pos
wide As Long,_ 'width
high As Long,_ 'height
1 As long,_ 'repaint flag
MoveWindow As long
end function
Thanks in advance.
Pablo.
|
|
|
Post by xxgeek on Jun 16, 2024 8:07:03 GMT -5
Good morning pablosi,
My knowledge with api ziltch to limited so I don't have the answer for you, but I may have stumbled onto some evidence that could point you, or someone else to the answer.
I commented out the resizehandler just for kicks, and then your code prints to the window, but the window is offset without the resizehandler in play.
'PRINT #main, "resizehandler [resize]"
Just need to get the windows lined up somehow.
Hope this helps with figuring out a solution.
|
|
|
Post by Brandon Parker on Jun 16, 2024 18:56:45 GMT -5
This is quick and dirty, so inspect the code to see what I did. The issue seems to be the underlying difference between the "Wait" command and the "Scan" command in Liberty BASIC somehow affects things sometimes. I would switch from Brand Labels to subroutines and use the "Scan" command in a loop as I have to ensure you get the full functionality.
Note that I do not think the user will be able to type anything into the MainWin unless the computer program prompts the user.
Hopefully, this will point you in the right direction...
'Simplified MDI window, MAINWIN as Child of my own win #main
'(to interact in text mode?)
'Problem to correct: After make as a child, the MAINWIN is not responding.
Global hMDI, hChild
CALLDLL #user32, "GetActiveWindow", mainwinhandle as long ' return mainwindow handle
TITLEBAR "My Console"
WindowWidth=750 WindowHeight=550
Global childWide : childWide=550 Global childHigh : childHigh=300 'child window dims
MENU #main, "&File", "&Quit",quitMenu
OPEN "Main Parent Window" for window as #main
PRINT #main, "trapclose quit"
PRINT #main, "resizehandler resize"
hMain=hwnd(#main) 'main window handle
calldll #user32, "GetWindowLongA",_ hMain as uLong,_ 'handle of window _GWl_HINSTANCE as long,_ 'flag for instance handle hInstance as uLONG 'returns instance handle of window
dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _ _WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control
CALLDLL #user32, "CreateWindowExA",_ 0 as long,_ 'extended class style "MDICLIENT" as ptr,_ 'class name "" as ptr,_ 'title or string dwStyle as long,_ 'window style 2 as long,_ 'x org 2 as long,_ 'y org 339 as long,_ 'width 302 as long,_ 'height hMain as ulong,_ 'parent window 0 as ulong,_ 'handle to menu = 0 for class menu hInstance as ulong,_ 'instance handle of parent window "" as ptr,_ 'always NULL hMDI as ulong 'returns handle of MDI Client
hChild=mainwinhandle ' handle of MainWin
CALLDLL #user32, "SetParent",_ hChild as ulong,_ 'make popup the child hMDI as ulong,_ 'make MDI the parent result as long
'use MoveWindow to force window resize
'so scrollbars will show
CALLDLL #user32, "MoveWindow",hMain As uLong,_ 11 As Long, 11 As Long,_ 333 As Long, 333 As Long,_ 1 As long, r As long
Input "Input something... ";something$ Print something$
Input "Input something else... ";somethingElse$ Print somethingElse$
Print "something = ";something$ Print "somethingElse = ";somethingElse$
While Hwnd(#main) Scan
result = Sleep(1) Wend
Sub resize handle$
newWide=WindowWidth-4
newHigh=WindowHeight-4
ret=MoveWindow(hMDI,2,2,newWide,newHigh)
ret=MoveWindow(hChild,0,0,childWide,childHigh)
End Sub
Sub quitMenu Call quit "#main" End Sub
Sub quit handle$
'CLOSE MAINWIN #child? but HOW?
CLOSE #handle$
END End Sub
Function MoveWindow(hWnd,x,y,wide,high)
CallDLL #user32, "MoveWindow",_ hWnd As uLong,_ 'handle x As Long, y As Long,_ 'x,y pos wide As Long,_ 'width high As Long,_ 'height 1 As long,_ 'repaint flag MoveWindow As long end function
Function Sleep(milliseconds) CallDLL #kernel32, "Sleep", milliseconds As ulong, _ ret As void End Function
{:0)
Brandon Parker
|
|
gaslouk
Full Member
![*](//storage.proboards.com/forum/images/stars/star.png) ![*](//storage.proboards.com/forum/images/stars/star.png)
Hi from beautiful Greece.
Posts: 132
|
Post by gaslouk on Jun 17, 2024 0:07:37 GMT -5
Hello. I am trying to put the MAINWIN as a child window of my own #main Window. I came up with this code. The problem is, after put the MAINWIN as a child, I cannot PRINT or INPUT like I usually do with the normal MAINWIN. Can somebody make corrections to this?. 'Simplified MDI window, MAINWIN as Child of my own win #main
'(to interact in text mode?)
'Problem to correct: After make as a child, the MAINWIN is not responding.
CALLDLL #user32, "GetActiveWindow", mainwinhandle as long ' return mainwindow handle
TITLEBAR "My Console"
WindowWidth=350 : WindowHeight=350
childWide=550 : childHigh=300 'child window dims
MENU #main, "&File", "&Quit",[quit]
OPEN "Main Parent Window" for window as #main
PRINT #main, "trapclose [quit]"
PRINT #main, "resizehandler [resize]"
hMain=hwnd(#main) 'main window handle
calldll #user32, "GetWindowLongA",_
hMain as uLong,_ 'handle of window
_GWl_HINSTANCE as long,_ 'flag for instance handle
hInstance as uLONG 'returns instance handle of window
dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _
_WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL
'create an MDI Client Control
CALLDLL #user32, "CreateWindowExA",_
0 as long,_ 'extended class style
"MDICLIENT" as ptr,_ 'class name
"" as ptr,_ 'title or string
dwStyle as long,_ 'window style
2 as long,_ 'x org
2 as long,_ 'y org
339 as long,_ 'width
302 as long,_ 'height
hMain as ulong,_ 'parent window
0 as ulong,_ 'handle to menu = 0 for class menu
hInstance as ulong,_ 'instance handle of parent window
"" as ptr,_ 'always NULL
hMDI as ulong 'returns handle of MDI Client
hChild=mainwinhandle ' handle of MainWin
CALLDLL #user32, "SetParent",_
hChild as ulong,_ 'make popup the child
hMDI as ulong,_ 'make MDI the parent
result as long
'use MoveWindow to force window resize
'so scrollbars will show
CALLDLL #user32, "MoveWindow",hMain As uLong,_
11 As Long, 11 As Long,_
333 As Long, 333 As Long,_
1 As long, r As long
PRINT
PRINT " Hello"
PRINT
INPUT " >";ANSWER$
PRINT ANSWER$
WAIT
[resize]
newWide=WindowWidth-4
newHigh=WindowHeight-4
ret=MoveWindow(hMDI,2,2,newWide,newHigh)
ret=MoveWindow(hChild,0,0,childWide,childHigh)
WAIT
[quit]
'CLOSE MAINWIN #child? but HOW?
CLOSE #main
END
Function MoveWindow(hWnd,x,y,wide,high)
CallDLL #user32, "MoveWindow",_
hWnd As uLong,_ 'handle
x As Long, y As Long,_ 'x,y pos
wide As Long,_ 'width
high As Long,_ 'height
1 As long,_ 'repaint flag
MoveWindow As long
end function
Thanks in advance. Εδώ έχω μια άλλη προσέγγιση, κάτι σαν του Brandon Parker.
'NOMAINWIN
' Αρχικοποίηση παραμέτρων παραθύρου WindowWidth = 450 WindowHeight = 450 childWide = 430 childHigh = 350
' Δημιουργία μενού MENU #main, "&File", "&Quit", [quit]
' Προσθήκη στατικών κειμένων και πεδίων εισόδου στο κάτω μέρος statictext #main.label, "Εισαγωγή:", 10, WindowHeight - 120, 80, 20 textbox #main.input, 100, WindowHeight - 120, 200, 20 button #main.submit, "Υποβολή", [submit], UL, 310, WindowHeight - 120, 80, 20 statictext #main.output, "", 10, WindowHeight - 90, 380, 20
' Άνοιγμα κύριου παραθύρου OPEN "Main Parent Window" FOR window AS #main PRINT #main, "trapclose [quit]" PRINT #main, "resizehandler [resize]"
' Λήψη handle του κύριου παραθύρου hMain = HWND(#main) hLabel = HWND(#main.label) hInput = HWND(#main.input) hSubmit = HWND(#main.submit) hOutput = HWND(#main.output)
' Έλεγχος αν το handle του κύριου παραθύρου είναι έγκυρο IF hMain = 0 THEN PRINT "Failed to get the handle of the main window." END END IF PRINT "hMain: "; hMain
' Λήψη του handle του instance του παραθύρου CALLDLL #user32, "GetWindowLongA", hMain AS ULONG, GWL.HINSTANCE AS LONG, hInstance AS ULONG PRINT "hInstance: "; hInstance
' Υπολογισμός των αρχικών διαστάσεων για το MDI Client initialMDIWidth = WindowWidth - 10 initialMDIHeight = WindowHeight - 130
' Δημιουργία MDI Client Control εντός των ορίων του κύριου παραθύρου dwStyle=_WS_CLIPCHILDREN OR _WS_CHILD OR _WS_VISIBLE OR _ _WS_BORDER or _WS_VSCROLL OR _WS_HSCROLL CALLDLL #user32, "CreateWindowExA", 0 AS LONG, "MDICLIENT" AS PTR, "" AS PTR, dwStyle AS LONG, _ 0 AS LONG, 0 AS LONG, initialMDIWidth AS LONG, initialMDIHeight AS LONG, hMain AS ULONG, 0 AS ULONG, hInstance AS ULONG, _ "" AS PTR, hMDI AS ULONG
' Έλεγχος αν το MDI Client δημιουργήθηκε επιτυχώς IF hMDI = 0 THEN PRINT "Failed to create MDI Client." END END IF PRINT "hMDI: "; hMDI
' Δημιουργία παιδικού παραθύρου gStyle = _WS_CHILD OR _WS_VISIBLE OR _WS_BORDER CALLDLL #user32, "CreateWindowExA", 0 AS LONG, "EDIT" AS PTR, "" AS PTR, gStyle AS LONG, _ 0 AS LONG, 0 AS LONG, childWide AS LONG, childHigh AS LONG, hMDI AS ULONG, 0 AS ULONG, hInstance AS ULONG, _ "" AS PTR, hChild AS ULONG
' Έλεγχος αν το παιδικό παράθυρο δημιουργήθηκε επιτυχώς IF hChild = 0 THEN PRINT "Failed to create child window." END END IF PRINT "hChild: "; hChild
' Χρησιμοποιούμε το MoveWindow για να αλλάξουμε το μέγεθος του MDI Client CALLDLL #user32, "MoveWindow", hMDI AS ULONG, 0 AS LONG, 0 AS LONG, initialMDIWidth AS LONG, initialMDIHeight AS LONG, 1 AS LONG, r AS LONG
WAIT
' Διαδικασία για το κλείσιμο του παραθύρου [quit] CLOSE #main END
' Διαδικασία για την υποβολή δεδομένων [submit] PRINT #main.input, "!contents?" INPUT #main.input, userInput$ notice "The title for your graph is: "; userInput$ CALLDLL #user32, "SendMessageA", hChild AS ULONG, _WM_SETTEXT AS ULONG, 0 AS ULONG, userInput$ AS PTR, result AS LONG PRINT #main.input, "" WAIT
' Διαδικασία για την αλλαγή μεγέθους του παραθύρου [resize] ' Ορισμός δομής rect STRUCT rect, left AS LONG, top AS LONG, right AS LONG, bottom AS LONG
' Λήψη των νέων διαστάσεων του παραθύρου CALLDLL #user32, "GetClientRect", hMain AS ULONG, rect AS STRUCT, result AS LONG PRINT "GetClientRect result: "; result newWide = rect.right.struct - rect.left.struct newHigh = rect.bottom.struct - rect.top.struct PRINT "newWide: "; newWide PRINT "newHigh: "; newHigh
' Υπολογισμός των νέων διαστάσεων newWideAdjusted = newWide - 10 newHighAdjusted = newHigh - 130
' Έλεγχος για να διασφαλιστεί ότι οι διαστάσεις δεν είναι αρνητικές ή μηδενικές IF newWideAdjusted <= 0 THEN newWideAdjusted = 1 IF newHighAdjusted <= 0 THEN newHighAdjusted = 1
' Προσαρμογή θέσης και μεγέθους των controls labelY = newHigh - 120 inputY = newHigh - 120 submitY = newHigh - 120 outputY = newHigh - 90 inputWidth = newWideAdjusted - 200 submitX = newWideAdjusted - 80 outputWidth = newWideAdjusted - 20
CALLDLL #user32, "MoveWindow", hLabel AS ULONG, 10 AS LONG, labelY AS LONG, 80 AS LONG, 20 AS LONG, 1 AS LONG, result AS LONG CALLDLL #user32, "MoveWindow", hInput AS ULONG, 100 AS LONG, inputY AS LONG, inputWidth AS LONG, 20 AS LONG, 1 AS LONG, result AS LONG CALLDLL #user32, "MoveWindow", hSubmit AS ULONG, submitX AS LONG, submitY AS LONG, 80 AS LONG, 20 AS LONG, 1 AS LONG, result AS LONG CALLDLL #user32, "MoveWindow", hOutput AS ULONG, 10 AS LONG, outputY AS LONG, outputWidth AS LONG, 20 AS LONG, 1 AS LONG, result AS LONG
' Προσαρμογή μεγέθους του MDI Client και του παιδικού παραθύρου retval = ResizeWindow(hMDI, newWideAdjusted, newHighAdjusted) retval = ResizeWindow(hChild, newWideAdjusted, newHighAdjusted)
WAIT
' Συνάρτηση για τη μετακίνηση παραθύρου FUNCTION MoveWindow(hWnd, x, y, wide, high) CALLDLL #user32, "MoveWindow", _ hWnd AS ULONG, _ x AS LONG, y AS LONG, _ wide AS LONG, _ high AS LONG, _ 1 AS LONG, _ MoveWindow AS LONG END FUNCTION
' Συνάρτηση για την αλλαγή διαστάσεων του παραθύρου FUNCTION ResizeWindow(hWnd, newWidth, newHeight) CALLDLL #user32, "MoveWindow", _ hWnd AS ULONG, _ 0 AS LONG, 0 AS LONG, _ newWidth AS LONG, _ newHeight AS LONG, _ 1 AS LONG, _ ResizeWindow AS LONG END FUNCTION
Ελπίζω να βοηθήσει.
Gaslouk.
|
|
|
Post by Brandon Parker on Jun 19, 2024 21:30:32 GMT -5
Pablo, I can not tell you why LB code misbehaves outside of LB. LB code that is run through that off-brand program is longer LB code. The underlying codebase becomes BBC Basic which, in my opinion, is not a good thing. Have you attempted to accomplish the background color change?
{:0) Brandon Parker
|
|
|
Post by metro on Jun 20, 2024 5:24:28 GMT -5
Pablo, I can not tell you why LB code misbehaves outside of LB. LB code that is run through that off-brand program is longer LB code. The underlying codebase becomes BBC Basic which, in my opinion, is not a good thing. Have you attempted to accomplish the background color change? {:0) Brandon Parker Interesting the loss of focus occurs with LINUX/WINE too, but (for me) focus works with WIN10 Although removing scan and using wait focus works with WINE
|
|