Focus Handle of Multiwin Output Window

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

Focus Handle of Multiwin Output Window

Post by MattC » Sun 19 May 2019, 18:58

Hi (again).

The program I'm writing uses multiple output windows using the MULTIWIN library. The function FN_createwin returns the handle of the created window. I am using a mouse to access items on the output screen but I need to know that the output window is selected. All the 'window focus' routines only return the main output window, returning @hwnd% . As much as this is, to some extent, useful, it would be good to have the current child window's handle, to guarantee the focus. Is there a routine available.

I tried using either:

Code: Select all

      SYS "GetForegroundWindow" TO hwnd%
and

Code: Select all

      DEF FN_getfocus(hwnd%)
      LOCAL H%, O%, W%
      SYS "GetWindowThreadProcessId", hwnd%, 0 TO W%
      SYS "GetCurrentThreadId" TO O%
      SYS "AttachThreadInput", O%, W%, TRUE
      SYS "GetFocus" TO H%
      SYS "AttachThreadInput", O%, W%, FALSE
      = H%
Neither of which gives me the current child output window's handle.

(Not sure where I got the second one from, but I've been using it on and off for ages.)

Thanks

Matt

KenDown
Posts: 58
Joined: Wed 04 Apr 2018, 06:36

Re: Focus Handle of Multiwin Output Window

Post by KenDown » Fri 14 Jun 2019, 12:30

Hmmm. I have multiple windows and although I don't need to ensure that one of them has the focus, I do need to know which one is being accessed by the program, which I guess comes down to the same thing.

SYS"GetForegroundWindow"TOhw%
IFhw%=hw1%ORhw%=hw2%ORhw%=hw3%ORhw%=hw5%ORhw%=hw6%ELSEENDPROC

hw1% hw2% etc are the handles of the windows that are created with FN_createwin. I can only suggest that perhaps it is the hwnd%, which is perhaps too similar to @hwnd%? You haven't used it more than once, have you?

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

Re: Focus Handle of Multiwin Output Window

Post by MattC » Fri 14 Jun 2019, 18:07

I tried so many variations of different things that I may have just overlooked 'GetForegroundWindow'. Thanks.

I would be surprised if BB4W got confused with hwnd% and @hwnd%. Particularly as @... is a system variable. But I will investigate what you have brought up.

Thanks.

Matt

Post Reply