SystemParametersInfoA

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
Post Reply
MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

SystemParametersInfoA

Post by MattC » Wed 29 May 2019, 20:02

Hi.

Could someone please explain what I'm doing wrong. I'm trying to get the dimensions of the screen without the taskbar. I thought this would work, but all I'm getting is zeros except for the result which seems to suggest it worked.

Code: Select all

      DIM rc{l%,t%,r%,b%}
      SYS "SystemParametersInfoA", 30, 0, rc{}, 0 TO result%
      PRINT rc.l%, rc.t%, rc.r%, rc.b%
      PRINT result%
I did try finding the information in the BBCBASIC help/forum/Wiki, but I couldn't. (On past experience, it's probably staring me in the face.)

Matt

Zaphod
Posts: 78
Joined: Sat 23 Jun 2018, 15:51

Re: SystemParametersInfoA

Post by Zaphod » Thu 30 May 2019, 05:25

Um, that 30 is hex! Try &30 and it should work.

Z

MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

Re: SystemParametersInfoA

Post by MattC » Thu 30 May 2019, 06:17

Ugh. How obvious was that - schoolboy error - :roll:. I must have been too tired last night.

Thanks Zaphod.

Matt

MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

Re: SystemParametersInfoA

Post by MattC » Thu 30 May 2019, 07:20

This change works fine. (Although I had to go back and reset the mouse double click Y value, as this was changed to zero with the 30 - i.e. &1E.)

However, I'm getting a slightly confusing effect when I try to run my program.

The edited bit is here:

Code: Select all

      DIM rc{l%,t%,r%,b%}
      SYS "GetSystemMetrics", 0 TO W%
      SYS "GetSystemMetrics", 1 TO H%
      SYS "SystemParametersInfoA", 48, 0, rc{}, 0
      rc.r% = 800
      SYS "MoveWindow", @hwnd%, (W% - rc.r%) / 2, 0, rc.r%, rc.b%, 1
      SYS "GetWindowLong", @hwnd%, -16 TO ws%
      SYS "SetWindowLong", @hwnd%, -16, ws% AND NOT &40000 AND NOT &10000
      VDU 26
The positioning and size are fine, but when the window is moved, black side bars appear. The client window is the same size but the overall window increases slightly. Any idea what's causing it? I've tried playing around with various settings, but to no avail. Is there a way of stopping the user actually moving the window at all?

Matt

svein
Posts: 26
Joined: Tue 03 Apr 2018, 19:34

Re: SystemParametersInfoA

Post by svein » Tue 04 Jun 2019, 09:54

Change the window size after you change the style, as hinted in the help page "Fixing the window size" :
" It is important to execute a MODE or VDU 23 statement after changing the window style. "

Is there a way of stopping the user actually moving the window at all?
Yes, but that's usually a bad idea.
One way can be found in the help page: "Removing the title bar"

Svein

Code: Select all

      DIM rc{l%,t%,r%,b%}
      SYS "GetSystemMetrics", 0 TO W%
      SYS "GetSystemMetrics", 1 TO H%
      SYS "SystemParametersInfoA", 48, 0, rc{}, 0
      rc.r% = 800
      SYS "GetWindowLong", @hwnd%, -16 TO ws%
      SYS "SetWindowLong", @hwnd%, -16, ws% AND NOT &40000 AND NOT &10000
      SYS "MoveWindow", @hwnd%, (W% - rc.r%) / 2, 0, rc.r%, rc.b%, 1
      VDU 26

MattC
Posts: 51
Joined: Mon 16 Apr 2018, 06:17

Re: SystemParametersInfoA

Post by MattC » Tue 04 Jun 2019, 19:49

Thanks Svein.

Implementing this change into my program does sort this problem out. However, it seems to introduce another one, which I will have to investigate further. Thanks again for your advice.

Matt

Post Reply