BBC BASIC for Windows
Programming >> User Interface >> Multiple windows run from a BBC BASIC program
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1283868810

Multiple windows run from a BBC BASIC program
Post by simong42 on Sep 7th, 2010, 2:13pm

Hi, is it possible to control multiple windows from a single BBC Basic program? I'm running on Windows XP. (I did this on the old Archi, using the WIMP polling mechanism, but don't expect to be able to repeat that on Windows.)

I'm reviving some games I wrote, and would like
1. a graphics window, showing the current user's location - mouse clicks on this can affect the game state.
2. a text entry area (single command line) where text commands can be entered, e.g. "drink cider".
3. a log display, where text messages can be displayed, as a result of mouse clicks or text commands, e.g. "you go to sleep for a while".
4. a second text display to display whatever objects you have with you.

I had a look at the MDI demo that came with my copy of BBC Basic, but would prefer not to have an overall wrapping window.

(All a bit retro, I know.)
Re: Multiple windows run from a BBC BASIC program
Post by DDRM on Sep 7th, 2010, 3:21pm

Hi Simon (?),

Have you tried the MULTIWIN library? That should be able to get you close.

As an alternative, you could use multiple dialogue boxes, each containing one of your elements.

Best wishes,

D
Re: Multiple windows run from a BBC BASIC program
Post by admin on Sep 7th, 2010, 5:22pm

on Sep 7th, 2010, 2:13pm, simong42 wrote:
1. a graphics window, showing the current user's location - mouse clicks on this can affect the game state.
Most easily the main output window (or a graphics viewport on that window).

Quote:
2. a text entry area (single command line) where text commands can be entered, e.g. "drink cider".
Most easily a text viewport on the main output window. If that's not acceptable, a dialogue box containing a single-line edit control.

Quote:
3. a log display, where text messages can be displayed, as a result of mouse clicks or text commands, e.g. "you go to sleep for a while".
I would suggest a dialogue box containing a multi-line edit control set to 'read only'.

Quote:
4. a second text display to display whatever objects you have with you.
Again, yet another dialogue box containing maybe a list control.

Quote:
would prefer not to have an overall wrapping window.
Dialogue boxes can, by default, be moved anywhere on the desktop.

Richard.

Re: Multiple windows run from a BBC BASIC program
Post by simong42 on Sep 9th, 2010, 12:25pm

Thanks, will try playing with dialogue boxes for a start.

My current implementation has a single window with a graphics viewport and three text viewports, one for input, the other two for text display. The two text display viewport have a scrolling capability ... if a viewport is 6 lines deep, and I have 15 lines of text to display, then lines 1-6 are displayed with a down-arrow user-defined character in the bottom right. Click on that with the mouse, and lines 4-10 are displayed, with up and down arrows displayed. All a bit clunky. Dialogue boxes sound a lot cleaner.
Re: Multiple windows run from a BBC BASIC program
Post by simong42 on May 19th, 2011, 08:40am

I got sidetracked from this, and have only just got back to it, so forgive the time lapse.

Just to repeat the requirement : I need to have a master window, which can be used for text input and graphics display, and a couple of child windows, which should be scrollable, and which will be used solely for text output.

I'm not sure about dialogue boxes ... isn't it the case that you click on OK or some such, and the box disappears? I'd like the child windows to be on display as long as the program is running.

I started experimenting with MULTIWIN instead, and with scrolling instead, but i'm not sure if the scrolling can be set up with the child windows.
Re: Multiple windows run from a BBC BASIC program
Post by admin on May 19th, 2011, 11:08am

on May 19th, 2011, 08:40am, simong42 wrote:
I need to have a master window, which can be used for text input and graphics display, and a couple of child windows, which should be scrollable, and which will be used solely for text output.

Sounds like a couple of scrollable Edit Boxes would be ideal. If you don't want the user to be able to modify their contents set them to Read Only. If you want to populate the edit boxes 'one line at a time' rather than all at once that's easily arranged.

Quote:
I'm not sure about dialogue boxes

There's no need to use dialogue boxes at all. Simply create two ordinary multi-line Edit Boxes (FN_editbox in WINLIB5) and you're done. If you want things like coloured text then use Rich Edit Controls instead, but that's slightly more complicated.

Quote:
I started experimenting with MULTIWIN

I don't think MULTIWIN is well-suited to your application.

Richard.
Re: Multiple windows run from a BBC BASIC program
Post by simong42 on May 23rd, 2011, 07:30am

Thanks for that. I've got multiple edit windows working, but still need to get the scrolling bit done. I presume this is driven by the 'style' parameter - how can I achieve this?
Re: Multiple windows run from a BBC BASIC program
Post by admin on May 23rd, 2011, 08:19am

on May 23rd, 2011, 07:30am, simong42 wrote:
Thanks for that. I've got multiple edit windows working, but still need to get the scrolling bit done. I presume this is driven by the 'style' parameter - how can I achieve this?

To enable scroll bars add WS_HSCROLL and WS_VSCROLL to the style (the Add Windows Constants utility will give you their values).
Re: Multiple windows run from a BBC BASIC program
Post by simong42 on Jan 16th, 2012, 09:15am

In the event, I plumped for a couple of child windows using MULTIWIN. I can position the child windows on creation - is there any way I can set the position of the parent window?
Re: Multiple windows run from a BBC BASIC program
Post by admin on Jan 16th, 2012, 1:08pm

on Jan 16th, 2012, 09:15am, simong42 wrote:
is there any way I can set the position of the parent window?

You can move any window using either SYS "MoveWindow" or SYS "SetWindowPos":

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633534.aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545.aspx

Bear in mind that the coordinates of a child window are with respect to its parent's client area, whereas the position of a top-level window is set in screen coordinates.

Richard.