Author Topic: How to remove title Bar from graphics screen?  (Read 8766 times)

0 Members and 1 Guest are viewing this topic.

Offline mpgcan

  • Newbie
  • Posts: 26
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #15 on: October 30, 2021, 03:30:19 am »
I had a delay problem similar to this, one of you guys provided a neat solution which seems to work on this. At the top of your script add the following line :
Code: QB64: [Select]
  1. Do: Loop Until _ScreenExists 'before using _WindowHandle or _title

Worked on this:
Code: QB64: [Select]
  1. Do: Loop Until _ScreenExists 'before using _WindowHandle or _title
  2.  
  3. Const HWND_TOPMOST%& = -1
  4. Const SWP_NOSIZE%& = &H1
  5. Const SWP_NOMOVE%& = &H2
  6. Const SWP_SHOWWINDOW%& = &H40
  7.  
  8.     Function GetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long)
  9.     Function SetWindowPos& (ByVal hWnd As Long, Byval hWndInsertAfter As _Offset, Byval X As Integer, Byval Y As Integer, Byval cx As Integer, Byval cy As Integer, Byval uFlags As _Offset)
  10.     Function SetWindowLongA& (ByVal hwnd As Long, Byval nIndex As Long, Byval dwNewLong As Long)
  11.     Function GetForegroundWindow&
  12.     Function SetLayeredWindowAttributes& (ByVal hwnd As Long, Byval crKey As Long, Byval bAlpha As _Unsigned _Byte, Byval dwFlags As Long)
  13. Screen _NewImage(600, 480, 32)
  14. GWL_STYLE = -16
  15. ws_border = &H800000
  16. WS_VISIBLE = &H10000000
  17. _Title "Borderless Window"
  18. Dim hwnd As Long
  19. Level = 175
  20. SetWindowOpacity hwnd, Level
  21.  
  22. winstyle2& = GetWindowLongA&(hwnd, GWL_STYLE)
  23. winstyle& = -12582913
  24. a& = SetWindowLongA&(hwnd, GWL_STYLE, winstyle& And WS_VISIBLE) ' AND NOT WS_VSCROLL) ' AND NOT ws_border)
  25. a& = SetWindowPos&(hwnd, 0, 0, 0, 0, 0, 39)
  26. msg$ = "Welcome to Translucent Windows Without Borders!"
  27. i = 16
  28. Color &HFFFFFFFF, &H0 ' white foreground, transparent background
  29.     _Limit 60
  30.     FGwin& = GetForegroundWindow&
  31.     If hwnd <> FGwin& Then ' QB64 no longer in focus.
  32.         While _MouseInput: Wend
  33.         a& = SetWindowPos&(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_SHOWWINDOW)
  34.         Do: _Limit 30: Loop Until hwnd = GetForegroundWindow&
  35.     End If
  36.     If InKey$ = Chr$(27) Then Exit Do
  37.     For y = 480 To 0 Step -1
  38.         For x = 640 To 0 Step -1
  39.             PSet (x, 480 - y), _RGB(y / 2 Mod 256, 100, 200) ' (x MOD 512 XOR y) MOD 256, y MOD 256)
  40.         Next
  41.     Next
  42.     _PrintString (92, 1), msg$
  43.     _PrintString (1, 464), "Press Esc to quit."
  44.     _PrintString (250, i), "Hi Chez-Pete!"
  45.     _Display
  46.     i = i + 1
  47.     If i > 464 Then i = 16
  48.  
  49. Sub SetWindowOpacity (hwnd As Long, Level)
  50.     Dim Msg As Long
  51.     Const G = -20
  52.     Const LWA_ALPHA = &H2
  53.     Const WS_EX_LAYERED = &H80000
  54.     Msg = GetWindowLongA&(hwnd, G)
  55.     Msg = Msg Or WS_EX_LAYERED
  56.     action = SetWindowLongA&(hwnd, G, Msg)
  57.     action = SetLayeredWindowAttributes(hwnd, 0, Level, LWA_ALPHA)
  58.  
All the best.
« Last Edit: October 30, 2021, 03:38:58 am by mpgcan »

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #16 on: October 30, 2021, 07:12:55 am »
That solution created a memory problem. In other words, I forgot that keyword existed! Oh well, by tomorrow I'll forget how $^$%# I got about forgetting about _SCREENEXISTS, so I've got that going for me.

Well thanks for that, and for the further discussion of race conditions by Steve. Now here's a couple more things for discussion...

1) Don't you guys think _SCREEEXISTS should just be an inherent part of all SCREEN commands? In otherwords the code doesn't precede until the SCREEN is rendered?

2) In my code that @mpgcan modified, I would have put _SCREENEXISTS after the screen call:

SCREEN _NEWIMAGE(600, 480, 32)

but he put it at the beginning of the program, and it still worked. To me, that indicates the race problem is not with making the graphics screen, but with making the start up, SCREEN 0 screen. @SMcNeill  Does that assumption seem correct?

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to remove title Bar from graphics screen?
« Reply #17 on: October 30, 2021, 07:55:25 am »
@Pete The problem, I found in the past, with ScreenExists is it's an internal one-time flag.  (Unless it's been modified to be different over time.)

This means ScreenExists starts as a 0 (False) value.  Then, once that initial SCREEN 0 screen is created, it gets a value of -1 (True).  From that point on, it stays true as you will always have a visible screen for your program.

The issue can arise as in the code above (or as simplified below):

DO: LOOP UNTIL _SCREENEXISTS 'This will pause your program until that initial SCREEN 0 is generated and registered properly.
SCREEN _NEWIMAGE(640, 480, 32)
PRINT _WINDOWHANDLE

That Print statement above may, or may not, work as intended.  You might get the handle for the initial SCREEN 0.  You might get the handle 0 where it was freed, but the new screen isn't registered back to us yet.  You might get what you expect.

The screen does indeed exist at this point, but we're swapping screens and as such Windows may not be reporting what the updated handle is back to us just yet.

As I mentioned above, I'd play it safe and *always* toss a _DELAY .2 in there after initializing that screen for the first time, just to be safe. 

The reason why you don't want an automatic delay in all SCREEN commands would be for something a little unusual like this:

ScreenOne = _NEWIMAGE(640, 480, 32)
ScreenTwo = _NEWIMAGE(640, 480, 32)

Do
    i= i + 1 MOD 2
    IF i THEN SCREEN ScreenOne ELSE ScreenTwo

We create the screens above, then flip between them alternating like we used to do with multiple pages in the old days...  You certainly  don't want to add in a .2 second delay in those instances, now do you?

Sometimes, it's best to leave some things up to the programmer to sort out themselves.  ;D
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #18 on: October 30, 2021, 11:28:40 am »
I remember Dav's Pipe program for which this:
Code: QB64: [Select]

did not work but a simple _Delay .25 did for _Screenmove _Middle

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #19 on: October 30, 2021, 12:36:45 pm »
@bplus Yes, I've had to use a small delay before using _SCREENMOVE as well. From our discussion so far, it appears likely  the delay is needed for the screen to be rendered, before it can be moved. In Dav's "Pipes" game, I did not experience the failure to move the screen, as you did. In other words I ran the code both with and without that .25 delay, and it centered the screen both times. My question would be if you moved his Do: Loop Until _ScreenExists statement to the top of the program and removed your delay, would it work?

@SMcNeill I agree a method that provides the freedom to choose outweighs a one size that doesn't always fit all method. I'm also in favor of improvements, and if it is possible to make a _SCREENEXISTS statement identify with each screen statement and reset itself to zero when the screen is rendered, that would be an improvement. That would require dynamic arrays and using preserve in QB64. I'm not familiar with a different method for C/C++.

These situations make me more appreciative of code that runs as expected. With this, and statements like SCREENPRINT and SCREENCLICK, the benchmark seems to be a .2 delay. The question is will .2 always be enough? As I mentioned, I could run Dav's program without the delay Mark needed. So if a faster, slower, or different systems with some different run-time priorities are involved, what good is a delay that falls a millisecond short? Again, the only ironclad system is a feedback one. That's a tall order, I know, as more than just screen rendering would need to be included.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #20 on: October 30, 2021, 02:43:00 pm »
Quote
My question would be if you moved his Do: Loop Until _ScreenExists statement to the top of the program and removed your delay, would it work?

No, it didn't. @Pete

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #21 on: October 30, 2021, 03:49:43 pm »
Hmm, now I see what the original poster is referring to, still seeing the title bar.  There seems to be a difference between QB64 versions and removing the title bar.  When I run Pete's code, using a very long delay, in v1.5 and lower I get this on my Win7 laptop - no title bar and no borders at all.

  [ You are not allowed to view this attachment ]  

But when I run it in QB64 v2 I get this, a black title bar and border, no matter how long a delay I add.

  [ You are not allowed to view this attachment ]  

That's just for Petes code.  I can remove the title bar and border using other API code, like this one here which does work as expected in QB64 v2..

- Dav

Code: QB64: [Select]
  1. '================
  2. 'WindowRegion.bas v1.1
  3. '================
  4. 'Uses Windows API to create a non-standard looking window.
  5. 'Using this you could use an image as the entire window instead.
  6. 'Coded by Dav, JULY/2020
  7.  
  8. 'I used API information found on this page....
  9. 'http://allapi.mentalis.org/apilist/apilist.php
  10.  
  11.  
  12. TYPE POINTAPI
  13.     x AS LONG
  14.     y AS LONG
  15. DIM apixy AS POINTAPI 'mouse x/y for the GetCursorPos function
  16.  
  17.     'sets a created window region
  18.     'http://allapi.mentalis.org/apilist/SetWindowRgn.shtml
  19.     FUNCTION SetWindowRgn& (BYVAL hwnd&, BYVAL hrgn&, BYVAL bredraw%)
  20.     'get current mouse x/y position
  21.     'http://allapi.mentalis.org/apilist/GetCursorPos.shtml
  22.     FUNCTION GetCursorPos% (lpPoint AS POINTAPI)
  23.  
  24.  
  25.     'creates a rectangular region
  26.     'http://allapi.mentalis.org/apilist/CreateRectRgn.shtml
  27.     FUNCTION CreateRectRgn& (BYVAL x1&, BYVAL y1&, BYVAL x2&, BYVAL y2&)
  28.     'creates an elliptical region
  29.     'http://allapi.mentalis.org/apilist/CreateEllipticRgn.shtml
  30.     FUNCTION CreateEllipticRgn& (BYVAL x1&, BYVAL y1&, BYVAL x2&, BYVAL y2&)
  31.     'creates a rectangular region with rounded corners
  32.     'http://allapi.mentalis.org/apilist/CreateRoundRectRgn.shtml
  33.     FUNCTION CreateRoundRectRgn& (BYVAL x1&, BYVAL y1&, BYVAL x2&, BYVAL y2&, BYVAL x3&, BYVAL y3&)
  34.  
  35. controls& = BASIMAGE1& 'Make Minimize & Exit controls image
  36. _ICON controls& 'might as well make it the program icon too...
  37.  
  38. hwnd& = _WINDOWHANDLE 'need the windows handle to play with it
  39.  
  40. 'Create a rounded rectangular region...
  41. rgn& = CreateRoundRectRgn(30, 30, 650, 650, 240, 240)
  42.  
  43. 'you can try these also...
  44. 'rgn& = CreateEllipticRgn(30, 30, 650, 650)
  45. 'rgn& = CreateRectRgn(30, 30, 650, 650)
  46.  
  47. 'Set the created region...
  48. try& = SetWindowRgn(hwnd&, rgn&, 0)
  49. 'Returns zero if failed...
  50. IF try& = 0 THEN
  51.     PRINT "Failed...": END
  52.  
  53. 'Setup screen....
  54. SCREEN _NEWIMAGE(680, 680, 32)
  55. FOR y = 1 TO 680
  56.     LINE (0, y)-(680, y), _RGB(c, c, 64), BF
  57.     c = c + 1: IF c > 32 THEN c = 0
  58.  
  59. 'Draw a top highlighted bar
  60. LINE (0, 0)-(680, 80), _RGB(64, 64, 196), BF
  61. 'draw minimize and exit image
  62. _PUTIMAGE (500, 30), controls&
  63.  
  64.  
  65.     p = _MOUSEINPUT
  66.     mx = _MOUSEX: my = _MOUSEY
  67.  
  68.     'LOCATE 12, 12: PRINT mx, my; _MOUSEBUTTON(1); 'testing info
  69.  
  70.     IF _MOUSEBUTTON(1) AND mx < 500 AND mx > 0 AND my < 80 AND mx > 0 THEN
  71.  
  72.         'get orig mouse x/y using api
  73.         tmp = GetCursorPos(apixy)
  74.         origx = apixy.x: origy = apixy.y
  75.  
  76.         DO
  77.             p = _MOUSEINPUT: IF _MOUSEBUTTON(1) = 0 THEN EXIT DO
  78.  
  79.             'poll mouse x/y
  80.             tmp = GetCursorPos(apixy)
  81.             mx = apixy.x: my = apixy.y
  82.  
  83.             _SCREENMOVE _SCREENX - (origx - mx), _SCREENY + (my - origy)
  84.  
  85.             origx = mx: origy = my
  86.  
  87.         LOOP
  88.  
  89.  
  90.     END IF
  91.  
  92.     'see if user clicked minimized area
  93.     IF _MOUSEBUTTON(1) AND mx > 500 AND mx < 540 AND my > 29 AND my < 66 THEN
  94.         'wait until button up to continue
  95.         DO: p = _MOUSEINPUT
  96.             IF _MOUSEBUTTON(1) = 0 THEN EXIT DO
  97.         LOOP
  98.         'minimize program
  99.         _SCREENICON
  100.     END IF
  101.  
  102.     'see if user clicked exit area
  103.     IF _MOUSEBUTTON(1) AND mx > 540 AND mx < 580 AND my > 29 AND my < 66 THEN
  104.         IF _MOUSEBUTTON(1) = -1 THEN
  105.             SYSTEM
  106.         END IF
  107.     END IF
  108.  
  109.  
  110.  
  111. 'This function creates the control image.
  112. 'It was made with my BASIMAGE.BAS program .
  113. FUNCTION BASIMAGE1& 'controls.png
  114.     v& = _NEWIMAGE(80, 40, 32)
  115.     DIM m AS _MEM: m = _MEMIMAGE(v&)
  116.     A$ = ""
  117.     A$ = A$ + "haIkH_oCCM5007_l#P28JF6a`HbL3iIKY?hEO#aOHKJ04W^9ciLDX::aXbn1"
  118.     A$ = A$ + "U]iFfD7?4#4T7jLZK4#A5:<L;Z0^T]Q#L6aU\HbRVmO04PO081n]c>WcUc]g"
  119.     A$ = A$ + "KkmNJ[m2SOhfT?inXWk]GnN_]gFZ\b:1E:c_=a4C\ZbZaS9Q>6UkWde_7jhF"
  120.     A$ = A$ + ";K6]_KcJ\nkQW7=P3<Jm[S^nC#Gmn_[J8g?Y_OS?hmHmdQ^_X6Oh11oUGjY?"
  121.     A$ = A$ + "H8_6]nM^cokP6Jk5B\WcZ^Fn7<W[k5PVJML#c]lTUlH\jKL4<Qjg8>jU1lJT"
  122.     A$ = A$ + "7fW3`HoDo2Jd1hk9go^^Qki2JhNNQFoZj\o6XV6O^?[ZU9bmCjkg#Mn3l<LG"
  123.     A$ = A$ + "o8[1i0]l#G_3NN#gM2ne^_QXnSNkaYnjU5nlEo>`W_Xe__lD33nZ_mI2:_]F"
  124.     A$ = A$ + "6VVg<FgPFo9[jI<>mOc>?]aCfVR?d8RB^OBOoLdJCHmeFcH3LYFMjb]cj>Oo"
  125.     A$ = A$ + "5an5>^37olE^T7=P0Xe_SDAoPSNRa54i_MQNPFoF\F<6J\TiY=N4J]C\nMmj"
  126.     A$ = A$ + "ZQA3e2^Ame2^McWSE?GXAFT>c5Yi8>Jo2\j71fOG9di3Jm[db^9hPOjS5T5C"
  127.     A$ = A$ + "k5cC=Q<6JSS\_Tkg:Oo^fIn6\>Zn<HMMfZahfET^K\>\KeD32B\^;DkkUC_Y"
  128.     A$ = A$ + "e?Kf_9h07kADIfh79JK8mQfcI4^mNZKbmKi_OT6BjWKM4Rd#aJY_d#YZOLK8"
  129.     A$ = A$ + "]FiJg#<UUgg>ajGKOfaIenWO2`E?mGcS[GOBdI]EaX^Za`m^nJhQL];g[O9M"
  130.     A$ = A$ + "WdI?e_R?lX2ZTb7SW\Q]01eU5GLAAQ_V;cmPi;]C^O;?mcVY\LbRA#9iH2cF"
  131.     A$ = A$ + ">VaC;eZI6iV3`N^F0fgREFUo^_=?79_]QMhlg6XR]W??7]`l17K75h6Jm;^="
  132.     A$ = A$ + "o5PgBK7n4=Yad`iWONgPOO;liO3eGSQV[jLNXXC]5ZTkWdg_DEX0C=B0:0J2"
  133.     A$ = A$ + ":0FY5LPlXM=1aCJQ4<;MQ52;m:35H8l`0Y7QB<3[=LNB?Z805THlPMZ:IZmC"
  134.     A$ = A$ + "QRg3X8ZFm9a]Yg7gYiVK>gPFOLKJG`aeRh2Z1A9DoD_DkD1UbBCE]D;E50cD"
  135.     A$ = A$ + "Nc783JmEcBhfG^=6eGmAbdEjm[#PR`Jf[4C\5RQJd\c>[X#?ojOUg1SF[Tkg"
  136.     A$ = A$ + ":Co8_oUd=bba7IX2noZ`OT`jS4c0\QXgOSJXDd?Bg#VIVIl8bHme6:g?Y_OZ"
  137.     A$ = A$ + "hd>ETkS0i]OGNOi1ihf0WkahakOXllDAJgdC?]PldcQfNNkCoXOYjBoFHQ5T"
  138.     A$ = A$ + "DTnY3nIQYkEmKWRNOBdmAA#k_YVJ:g#N]8SQfh8k;5AdTLoFQk7K_LU7^?f;"
  139.     A$ = A$ + "3bO7I0kFFA6>8ce6Q7jg^015Mc2R\_VLb9M3ncJCX8<dHS?aR`X=NT0OEin]"
  140.     A$ = A$ + "Bg?]`FaU^PHT#D:UlkoJ=ihafj6S1\KE91n#=Y#]O[K3E0D^aV4DBYl1H2mj"
  141.     A$ = A$ + "PF?kHS]AWKCbkFha3G?BX`aj[m;k`F3F61706IIS:3Q_823c4lkLPH6nMOck"
  142.     A$ = A$ + "eSQWRP=1I?`^`e7[C=HOje`cWT^F#aIXSJoN]=OL#\jn>ob6Dg6?AcMN?lkM"
  143.     A$ = A$ + "mVOo[Lol_nI?3mHFP=97XmVJB<DW2HO#fdZ6[HMJhaVnd0UH#;;K`FDBVja8"
  144.     A$ = A$ + "kcBcb0?fc>MFU2]OCIB]OYJhTPD\NIOFRFJGdeWXi;b:NS]`KI?A^OBOo>XU"
  145.     A$ = A$ + "\UL70f5GGGIXYiH4k#8F=1:?GcDkGfF?5HkkoNnU2]OGNcSD`;9QjgZ9[6?V"
  146.     A$ = A$ + "4jHD^OBCoT9ko3o7Ml:S%%%0"
  147.     btemp$ = ""
  148.     FOR i& = 1 TO LEN(A$) STEP 4: B$ = MID$(A$, i&, 4)
  149.         IF INSTR(1, B$, "%") THEN
  150.             FOR C% = 1 TO LEN(B$): F$ = MID$(B$, C%, 1)
  151.                 IF F$ <> "%" THEN C$ = C$ + F$
  152.             NEXT: B$ = C$: END IF: FOR j = 1 TO LEN(B$)
  153.             IF MID$(B$, j, 1) = "#" THEN
  154.         MID$(B$, j) = "@": END IF: NEXT
  155.         FOR t% = LEN(B$) TO 1 STEP -1
  156.             B& = B& * 64 + ASC(MID$(B$, t%)) - 48
  157.             NEXT: X$ = "": FOR t% = 1 TO LEN(B$) - 1
  158.             X$ = X$ + CHR$(B& AND 255): B& = B& \ 256
  159.     NEXT: btemp$ = btemp$ + X$: NEXT
  160.     btemp$ = _INFLATE$(btemp$)
  161.     _MEMPUT m, m.OFFSET, btemp$: _MEMFREE m
  162.     BASIMAGE1& = _COPYIMAGE(v&): _FREEIMAGE v&
  163.  
  164.  



Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #22 on: October 30, 2021, 09:05:44 pm »
@Dav

Using your code from reply just above - I tried to have a window 640 x 320 without Title Bar or borders/sliders but it did not work for me.

I essentially removed any code referring to MOUSE or CONTROL Buttons to have a plain 640 x 320 graphics box with a diagonal line between screen corners.



Code: QB64: [Select]
  1. 'WindowRegion.bas v1.1      ' ### MODIFIED program written by Dav
  2.  
  3.     FUNCTION SetWindowRgn& (BYVAL hwnd&, BYVAL hrgn&, BYVAL bredraw%)
  4.     FUNCTION CreateRectRgn& (BYVAL x1&, BYVAL y1&, BYVAL x2&, BYVAL y2&)
  5. hwnd& = _WINDOWHANDLE 'need the windows handle to play with it
  6. rgn& = CreateRectRgn( 0, 0, 640, 320)'Create a rectangular region...
  7. try& = SetWindowRgn(hwnd&, rgn&, 0)  'Set the created region...
  8. IF try& = 0 THEN PRINT "Failed...": system 'Returns zero if failed...
  9.  
  10. SCREEN _NEWIMAGE(640, 320, 32)  'Setup screen.... 640x320 BLACK background
  11. line(0,0)-(639,319),&Hff00ff00~&& 'TESTING display GREEN LINE (0,0)-(bottom RH corner)
  12.  
  13. _delay 30:system    ' ### TERMINATE program after 30 seconds
  14.  


  [ You are not allowed to view this attachment ]  




Using Windows 10 x64 Pro Build 21H1 (oct updated)  with  QB64 v2.1 dev c48bf67







Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #23 on: October 30, 2021, 11:04:51 pm »
@Dav

Using your code from reply just above - I tried to have a window 640 x 320 without Title Bar or borders/sliders but it did not work for me.

I essentially removed any code referring to MOUSE or CONTROL Buttons to have a plain 640 x 320 graphics box with a diagonal line between screen corners.

Okay, it didn't remove the title bar for me, either. Also, I had to add the delay indicated in the code below, between the two declare library statements, or the handle for SetWindowRgn would fail to register.

Code: QB64: [Select]
  1. 'WindowRegion.bas v1.1      ' ### MODIFIED program written by Dav
  2.  
  3.     FUNCTION SetWindowRgn& (BYVAL hwnd&, BYVAL hrgn&, BYVAL bredraw%)
  4. _DELAY .2 ' <---------------On my system, this delay is needed or it will fail.
  5.     FUNCTION CreateRectRgn& (BYVAL x1&, BYVAL y1&, BYVAL x2&, BYVAL y2&)
  6. hwnd& = _WINDOWHANDLE 'need the windows handle to play with it
  7. rgn& = CreateRectRgn(0, 0, 640, 320) 'Create a rectangular region...
  8. try& = SetWindowRgn(hwnd&, rgn&, 0) 'Set the created region...
  9. IF try& = 0 THEN PRINT "Failed...": SLEEP: SYSTEM 'Returns zero if failed...
  10.  
  11. SCREEN _NEWIMAGE(640, 320, 32) 'Setup screen.... 640x320 BLACK background
  12. LINE (0, 0)-(639, 319), &HFF00FF00~&& 'TESTING display GREEN LINE (0,0)-(bottom RH corner)
  13.  
  14. _DELAY 30: SYSTEM ' ### TERMINATE program after 30 seconds
  15.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline Dav

  • Forum Resident
  • Posts: 792
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #24 on: October 31, 2021, 09:25:14 am »
@Richard. That's because of the CreateRectRgn(0, 0, 640, 320) settings.  In your code the x1 and y1 is set to 0 which puts it inside the title bar area, so the title bar is drawn now. I really don't know well how it works, but I noticed I had to increase those numbers to keep title bar from popping back up, which is why in my code I had it set higher.  If you change your code to CreateRectRgn(10, 30, 640, 320) it should stay gone, but of course this puts x/y out of wack when drawing stuff because part of the screen is hidden.  I need to learn more about using these API's.  Maybe @SpriggsySpriggs can shed more light on this for us.   @Pete, the _DELAY was needed in it again because the _ICON call was removed.  With _ICON in play the _DELAY doesn't seem to be needed. 

- Dav

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to remove title Bar from graphics screen?
« Reply #25 on: October 31, 2021, 09:49:11 am »
Part of the issue may be command depreciation.  Windows documentation now tells us that GetWindowLong and SetWindowLong has now been depreciated, and GetWindowLongPtr and SetWindowLongPtr should now be used instead.  (Particularly on 64-bit systems.)

You guys might try swapping to those calls and see what it changes.  (You might need to check to make certain SetWindowPos hasn't changed as well.  I'm not at home atm, so didn't bother to keep digging since I can't actually test anything at the moment anyway.)


May also want to try the SetWindowPos with the last value being 38 rather than 39.

SWP_DRAWFRAME -- 0x0020 -- Draws a frame (defined in the window's class description) around the window.
SWP_NOMOVE -- 0x0002 -- Retains the current position (ignores the x and y members).
SWP_NOSIZE -- 0x0001 -- Retains the current size (ignores the cx and cy members).
SWP_NOZORDER  -- 0x0004 -- Retains the current Z order (ignores the hwndInsertAfter member).

That 39 is basically made up of all the flags above, but it seems to me that the NOSIZE right be an issue if windows counts the title bar height as being inclusive to the overall window size.  It wouldn't hurt to test it once without it.  :P
« Last Edit: October 31, 2021, 10:04:33 am by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #26 on: October 31, 2021, 09:51:33 am »
@Dav I'll speculate it's the process of getting the icon, the time it takes, provides the necessary delay for the race condition to catch up, but how would I know, as I graduated top of my class of zero. You ask, "how can you have a class of zero?" Simple, I was the only one in the class, and I never showed up.

Your "trick" of hiding the title bar reminded me of my trick of making the screen size the desktop size plus the height of the title bar and using _SCREENMOVE with a negative second parameter to move the screen up just far enough to hide the title bar.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline mpgcan

  • Newbie
  • Posts: 26
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #27 on: November 01, 2021, 04:50:13 am »
I have looked at removing borders and I offer my solution on this problem the following works on Windows 8.1

Code: QB64: [Select]
  1. Do: Loop Until _ScreenExists 'run before using _WindowHandle or _title
  2. '####################################################
  3. '# Name:     no_border_no_caption.bas
  4. '# Author:   MPG
  5. '# Purpose:  Remove border and caption. Remaing area
  6. '#           is all client.
  7. '#           Items commented out may be required.
  8. '#           Do: Loop Until _ScreenExists required
  9. '#           on Windows 8.1
  10. '# Revision: November 1 2021 - initial version
  11. '####################################################
  12.  
  13.     Function FindWindow& (ByVal ClassName As _Offset, WindowName$)
  14.  
  15.     Function GetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long)
  16.     Function SetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long, Byval dwNewLong As Long)
  17.     Function SetWindowPos& (ByVal hWnd As _Offset, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As Long, Byval cy As Long, Byval wFlags As Long)
  18.     '    Function ShowScrollBar& (ByVal hWnd As _Offset, Byval wBar As Long, Byval bShow As Long)
  19.  
  20. Const GWL_STYLE = -16
  21. Const WS_BORDER = &H800000
  22. Const WS_CAPTION = &H00C00000
  23. Const WS_THICKFRAME = &H00040000
  24. Const WS_MINIMIZEBOX = &H00020000
  25. Const WS_MAXIMIZEBOX = &H00010000
  26. Const WS_SYSMENU = &H00080000
  27. 'Const SB_BOTH = 3
  28.  
  29. Dim As Long winstyle, Style, a
  30.  
  31. winstyle = GetWindowLongA(hwnd, GWL_STYLE)
  32. Style = (WS_CAPTION Or WS_THICKFRAME Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX Or WS_SYSMENU)
  33. a = SetWindowLongA&(hwnd, GWL_STYLE, winstyle And Not Style)
  34. 'a = ShowScrollBar(hwnd, SB_BOTH, false)
  35.  
  36.  
  37. Screen _NewImage(640, 320, 32)
  38. 'Cls
  39. Line (0, 0)-(639, 319), &HFF00FF00~&&
  40. Line (300, 0)-(300, 320), &HFF00FF00~&&
  41. Line (0, 150)-(640, 150), &HFF00FF00~&&
  42.  
  43. Line (639, 0)-(639, 100), &HFF00FF00~&&
  44. Line (0, 0)-(0, 100), &HFF00FF00~&&
  45.  
  46. Line (400, 0)-(500, 0), &HFF00FF00~&&
  47. Line (400, 319)-(500, 319), &HFF00FF00~&&
  48.  
  49.  
  50. _PrintString (100, 100), "Press any key to end...": Sleep
  51. Print "The end Note:Location"
  52.  

With the do-loop enabled. Shows borders and caption removed .
  [ You are not allowed to view this attachment ]  

All the best.



Offline Richard

  • Seasoned Forum Regular
  • Posts: 364
    • View Profile
Re: How to remove title Bar from graphics screen?
« Reply #28 on: November 01, 2021, 05:18:28 am »
@mpgcan 

Thanks




  [ You are not allowed to view this attachment ]  





Windows 10 x64 Pro  21H1 (OCT updated)   with v2.1 dev build c48bf67






Many thanks again






Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: How to remove title Bar from graphics screen?
« Reply #29 on: November 01, 2021, 08:19:31 am »
Good catch with the WS_SYSMENU flag.   To completely remove the window, you need to remove both it and the WS_CAPTION flag from the options.

Code: QB64: [Select]
  1. Do: Loop Until _ScreenExists 'run before using _WindowHandle or _title
  2. '####################################################
  3. '# Name:     no_border_no_caption.bas
  4. '# Author:   MPG
  5. '# Purpose:  Remove border and caption. Remaing area
  6. '#           is all client.
  7. '#           Items commented out may be required.
  8. '#           Do: Loop Until _ScreenExists required
  9. '#           on Windows 8.1
  10. '# Revision: November 1 2021 - initial version
  11. '####################################################
  12.  
  13.     Function FindWindow& (ByVal ClassName As _Offset, WindowName$)
  14.  
  15.     Function GetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long)
  16.     Function SetWindowLongA& (ByVal hWnd As _Offset, Byval nIndex As Long, Byval dwNewLong As Long)
  17.     Function SetWindowPos& (ByVal hWnd As _Offset, Byval hWndInsertAfter As Long, Byval x As Long, Byval y As Long, Byval cx As Long, Byval cy As Long, Byval wFlags As Long)
  18.     '    Function ShowScrollBar& (ByVal hWnd As _Offset, Byval wBar As Long, Byval bShow As Long)
  19.  
  20. Const GWL_STYLE = -16
  21. Const WS_BORDER = &H800000
  22. Const WS_CAPTION = &H00C00000
  23. Const WS_THICKFRAME = &H00040000
  24. Const WS_MINIMIZEBOX = &H00020000
  25. Const WS_MAXIMIZEBOX = &H00010000
  26. Const WS_SYSMENU = &H00080000
  27. 'Const SB_BOTH = 3
  28.  
  29. Dim As Long winstyle, Style, a
  30.  
  31. winstyle = GetWindowLongA(hwnd, GWL_STYLE)
  32. Style = (WS_CAPTION Or WS_SYSMENU)
  33. a = SetWindowLongA&(hwnd, GWL_STYLE, winstyle And Not Style)
  34. 'a = ShowScrollBar(hwnd, SB_BOTH, false)
  35.  
  36.  
  37. Screen _NewImage(640, 320, 32)
  38. 'Cls
  39. Line (0, 0)-(639, 319), &HFF00FF00~&&
  40. Line (300, 0)-(300, 320), &HFF00FF00~&&
  41. Line (0, 150)-(640, 150), &HFF00FF00~&&
  42.  
  43. Line (639, 0)-(639, 100), &HFF00FF00~&&
  44. Line (0, 0)-(0, 100), &HFF00FF00~&&
  45.  
  46. Line (400, 0)-(500, 0), &HFF00FF00~&&
  47. Line (400, 319)-(500, 319), &HFF00FF00~&&
  48.  
  49.  
  50. _PrintString (100, 100), "Press any key to end...": Sleep
  51. Print "The end Note:Location"
  52.  
  53.  

Style = (WS_CAPTION Or WS_SYSMENU)

What the wiki has is the simple WS_CAPTION being removed, but that doesn't also remove the WS_SYSMENU, which is what's reserving that blank space up top for the titlebar that we're no longer making use of.  Getting rid of both fixes the issue for good.  ;)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!