Resizing of widows

Discussions related to mouse, keyboard, fonts and Graphical User Interface
Ric
Posts: 261
Joined: Tue 17 Apr 2018, 21:03

Resizing of widows

Post by Ric »

I am trying to write a package similar to MS paint, but slightly more specific to my needs, the program uses asm to render to a DIBsection and I am using imglib to render images too.
I am calling a resizing routine with

Code: Select all

ON MOVE PROCresize(@msg%,@lparam%) : RETURN
and PROCresize code is

Code: Select all

      DEF PROCresize(action%,pixels%)

      IF action% <> 5 THEN ENDPROC
      screen_width% = pixels% AND &FFFF
      screen_height% = pixels% >>> 16

      bmi.Header.Size% = DIM(BITMAPINFOHEADER{})
      bmi.Header.Width% = screen_width%
      bmi.Header.Height% = screen_height%
      bmi.Header.Planes.l& = 1
      bmi.Header.BitCount.l& = 32
      SYS "CreateDIBSection", @memhdc%, bmi{}, 0, ^bits%, 0, 0 TO hbitmap%
      IF hbitmap%=0 ERROR 100, "Couldn't create DIBSection"
      SYS "SelectObject", @memhdc%, hbitmap% TO oldhbm%
      SYS "DeleteObject", oldhbm%
      SYS "InvalidateRect", @hwnd%, 0, 0

      VDU 23,22,screen_width%;screen_height%;10,20,16,0
      VDU 26
       PROC_imgInit
       PROConResize : REM(reset any variables that need to and re-render screen with imglib
      *FX 15,1

      ENDPROC
My program regularly crashes with some random variable that has been altered and badsubcript error occurs when accessing some of the arrays
Can someone please help to code the resize correctly
Kind regards Ric
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 539
Joined: Tue 18 Jun 2024, 09:32

Re: Resizing of widows

Post by Richard Russell »

Ric wrote: Tue 02 Dec 2025, 18:56 Can someone please help to code the resize correctly
If your suspicion is that the instability results from the asynchronous nature of the ON MOVE interrupt, set a global flag in the interrupt and act on it in your main code:

Code: Select all

DIM Resize%(2)
ON MOVE Resize%() = TRUE, @msg%, @lparam% : RETURN
Somewhere regularly executed in your main code:

Code: Select all

IF Resize%(0) Resize%(0) = FALSE : PROCresize(Resize%(1), Resize%(2)) 
That will ensure the resizing happens synchronously. If that doesn't fix the problem you will need to continue with debugging.
Ric
Posts: 261
Joined: Tue 17 Apr 2018, 21:03

Re: Resizing of widows

Post by Ric »

Thank you Richard, there was a little playing around to iron out a few anomalies but it worked a treat. It just leaves one question, does ON MOVE trap maximise and minimise, if not how do i do that?
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 539
Joined: Tue 18 Jun 2024, 09:32

Re: Resizing of widows

Post by Richard Russell »

Ric wrote: Wed 03 Dec 2025, 19:57 does ON MOVE trap maximise and minimise?
Maximise: yes, assuming the size actually changes. Minimise: not necessarily (it depends on the platform and possibly other factors); if minimise does trigger an ON MOVE interrupt the window size is likely to be reported as zero and should usually be ignored.
if not how do i do that?
Why would you want to trap minimise?
Ric
Posts: 261
Joined: Tue 17 Apr 2018, 21:03

Re: Resizing of widows

Post by Ric »

Thank you for the quick reply, it is all sorted now and the window can be resized, maximised and minimised.
I wanted to trap minimise so that i could tell the DIBsection not to renew.
Kind Regards Ric.

6502 back in the day, BB4W 2017 onwards, BBCSDL from 2023
Richard Russell
Posts: 539
Joined: Tue 18 Jun 2024, 09:32

Re: Resizing of widows

Post by Richard Russell »

Ric wrote: Wed 03 Dec 2025, 22:36 I wanted to trap minimise so that i could tell the DIBsection not to renew.
You shouldn't need a notification in order not to do something! :lol: