mdb
New Member
Posts: 3
|
Post by mdb on Nov 20, 2023 5:23:24 GMT -5
I need to fill my PC monitor window with a specific programmable colour. Is there any way I can create a full-screen graphics window, ie without the menu bar at the top?
I am trying to use the "Fill" command using the code line:
print #Cwin, "fill ";red;" ";green;" ";blue,
where red, green, blue have values in the range 0-255 and Cwin is the window to be filled..
This works OK except for the menu bar which appears at the top of the window.
Any thoughts?
|
|
|
Post by Rod on Nov 20, 2023 6:59:07 GMT -5
To completely fill the screen put a graphicbox in a window style popup. Be sure to have programmed an exit strategy. The essential code, but browse for fuller examples.
nomainwin WindowWidth = DisplayWidth WindowHeight = DisplayHeight UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main.g, 0, 0, WindowWidth, WindowHeight open "Dance" for window_popup as #main 'since we go full screen you need option to allow user to quit
|
|
mdb
New Member
Posts: 3
|
Post by mdb on Nov 20, 2023 12:03:10 GMT -5
Many thanks for your quick respose Rod.
However, I am still unclear how I can fill a graphic box with a solid colour.
I tried using
print #main, "fill Red"
but it seems the fill command is not valid in this type of window.
Can you help with this?
Many thanks. Malcolm
|
|
|
Post by xxgeek on Nov 20, 2023 13:29:04 GMT -5
In Rod's code he uses a graphicsbox for the graphics, not a graphics window.
So you need to have your code address the graphicbox, and NOT the window when doing anything graphical, like fill'ing the window(which is fully covered by a graphicbox), and is a popup window that has NO graphic capabilities, other than the graphicbox placed in it.
Before you can "fill" the graphicbox with a color, you must first put the "pen" down on the 'canvas'(the graphicsbox)
eg: #main.g "down ; fill red" 'Notice the #main.g is the graphicsbox, and NOT the window
There is a section in the help file named "Graphic Commands" that has all the different commands you can use in graphics windows, and graphicsboxes.
Note: There is no longer a need to use Print since with LB v4.5.1 the new syntax is #main.g "down : fill red" Print is implied.
'alt + F4 closes the open window nomainwin WindowWidth = DisplayWidth WindowHeight = DisplayHeight UpperLeftX=int((DisplayWidth-WindowWidth)/2) UpperLeftY=int((DisplayHeight-WindowHeight)/2) graphicbox #main.g, 0, 0, WindowWidth, WindowHeight open "Dance" for window_popup as #main 'since we go full screen you need option to allow user to quit #main.g "down ; fill red" wait
|
|
mdb
New Member
Posts: 3
|
Post by mdb on Nov 21, 2023 5:57:49 GMT -5
Thanks to you both. Works perfectly.
Regards. Malcolm
|
|
|
Post by tenochtitlanuk on Nov 21, 2023 13:38:21 GMT -5
I just had a play- to exit from a window with no controls visible and/or with a faulty 'on keyboard..' or 'on mouse...' is difficult!!! My first version accidentally put my exit button it off-screen, hence I added, while testing, a timer routine to get me out in 20 seconds from such things! Code below creates an 'Exit' button. nomainwin
WindowWidth = DisplayWidth WindowHeight = DisplayHeight UpperLeftX = int( ( DisplayWidth -WindowWidth) /2) UpperLeftY = int( ( DisplayHeight -WindowHeight) /2)
graphicbox #main.g, 0, 0, WindowWidth, WindowHeight button #main.b1, "Exit", [q], LR, 40, WindowHeight -50 statictext #main.st1, "Some static text.", 30, 100, 100, 40
open "Demo. of a whole-screen window." for window_popup as #main
#main.g "down ; fill 180 180 80 ; flush"
#main.g "up ; goto 200 400 ; down ; color darkblue ; backcolor 180 180 80 ; font bold 32" #main.g "\Demo. of filled whole screen window."
timer 20000, [q] ' while testing, gives you a way to exit automatically after 20 seconds! ' eg if you code a mouse or kbd exit routine which fails you can be left with no exit! scan
wait
[q] timer 0 close #main end
|
|
|
Post by tsh73 on Nov 21, 2023 15:22:38 GMT -5
It just asks for making that button run from the mouse cursor (standard prank. Not so easy in LB, needs MouseMove on button) (You always could press Alt-F4, aren't you?) *really surprised I got window closed with AltF4 regardless of trapclose* ah well. If I indeed catch trapclose and put a WAIT in handler, Alt-F4 stops working. OK...
|
|
|
Post by Rod on Nov 22, 2023 3:06:13 GMT -5
I usually write a when characterinput event and trap Esc.
|
|
|
Post by Marco Kurvers on Dec 4, 2023 9:12:08 GMT -5
Yes, Rod. That's a possibility. But if I use a window or a window_popup, the graphicbox must always have a setfocus. If the window accidentally has the focus, an escape will not working.
|
|