Page 1 of 1

releasemouse

Posted: Thu Sep 04, 2003 11:07 am
by Skipsy
Folks,

I am getting green with that f@#& windows events.

In a windowed screen i am using ExamineMouse() etc... I don't find a
way to say to the system that if the screen has no longer the focus
(masked by another app window), mouse control is back to the system
(releasemouse(1).

here is a summary of the code :

Code: Select all

While QUITTE = 0
  
  EVT_WIND.l = WindowEvent()
  Delay (1)

  If EventWindowID() = 1                                ; My window
    
      ReleaseMouse(0)
      ExamineMouse()

    Select EVT_WIND
      Case #PB_Event_CloseWindow
        QUITTE = 1
      Case blabla
    EndSelect
    
  Else
    ReleaseMouse(1)
  EndIf

Wend
I have also did a test using IsScreenActive but if I understood it is only
for full screen (?)

Any idea ?????
thks

Re: releasemouse

Posted: Thu Sep 04, 2003 11:22 am
by PB
Try this:

Code: Select all

If GetForegroundWindow_() <> WindowID()
  ; Your app no longer has the focus...
Else
  ; Your app has the focus!
EndIf

Posted: Thu Sep 04, 2003 11:27 am
by Franky
Hi PB, perhaps get activewindow_() is better than get foregroundwindow_()

The DebuggerWindow for example is in the foreground even if it isn´t active

Posted: Thu Sep 04, 2003 12:37 pm
by Skipsy
Great !!!

Both work. I am turned back to my normal color :D

Many thks.

Posted: Thu Sep 04, 2003 12:43 pm
by Kale
Both work. I am turned back to my normal color
Are you sure? you still look a little green Image :D

Posted: Thu Sep 04, 2003 1:38 pm
by PB
> perhaps get activewindow_() is better than get foregroundwindow_()

GetForegroundWindow_() is the API of the window that has the focus.
You can test this by running this simple app:

Code: Select all

; 3-second delay at start so you can give the
; focus to another app, to test the result.
;
Sleep_(3000)
Debug "Focus is: "+Str(GetForegroundWindow_())
Debug "Active is: "+Str(GetActiveWindow_())