Page 1 of 1

HideMouse()

Posted: Sat Apr 10, 2004 9:05 pm
by GPI
For OpenWindowedScreen() it would be nice to hide the mouse.

Posted: Sat Apr 10, 2004 9:22 pm
by Derlidio
May be I'm misunderstanding your question, but i think PB already does what you want. It hides the mouse pointer when you call InitMouse() after opening a Windowed Screen. Well, at least it works this way in the app I'm working on...

Posted: Sat Apr 10, 2004 11:30 pm
by GPI
?!
The mouse-cursor is never hide.

Can you write a example?

(openwindowedscreen(), not openscreen())

Posted: Sun Apr 11, 2004 12:23 am
by Derlidio
Yeepy...

Indeed, PB does hide Mouse Pointer, but not exactly the way I told you before. The mouse will be hidden not after InitMouse() but after the first call to ExamineMouse(). After that, mouse pointer will be trapped into the Windowed Screen. You'll see this behavior when you run the following code (press <ESC> to exit the loop):

Code: Select all

InitSprite()

OpenWindow(0,0,0,640,480,#PB_Window_SystemMenu, "Mouse Pointer Test")
OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)

CreateSprite(1,16,16,#PB_Sprite_Memory)
If StartDrawing(#SpriteOutput(1))
   Box(0,0,16,16,RGB(255,255,255))
   StopDrawing()
EndIf

InitMouse()
InitKeyboard()

Repeat
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape)
    Break
    Else
    ExamineMouse()
    DisplaySprite(1,MouseX(),MouseY())
    FlipBuffers()
  EndIf
ForEver
Hope it helps :wink:

Posted: Sun Apr 11, 2004 10:10 am
by GPI
Funny....

On my code it doesn't work so... (maybe because i create the main-window-loop in a diffrent thread)

....

Yes, because of the thread...

Code: Select all

Global MainWindow
Global Quit
Procedure MainWindow(flag)
  a=OpenWindow(0,0,0,640,480,#PB_Window_SystemMenu, "Mouse Pointer Test") 
  MainWindow=a
  Repeat
  Until WaitWindowEvent()=#PB_Event_CloseWindow
  Quit=#True
EndProcedure


CreateThread(@MainWindow(),flag)
While MainWindow=0:Wend

InitSprite() 
OpenWindowedScreen(MainWindow,0,0,640,480,0,0,0) 

CreateSprite(1,16,16,#PB_Sprite_Memory) 
If StartDrawing(SpriteOutput(1)) 
  Box(0,0,16,16,RGB(255,255,255)) 
  StopDrawing() 
EndIf 

InitMouse() 
InitKeyboard() 

Repeat 
  ExamineKeyboard() 
  If KeyboardPushed(#PB_Key_Escape) 
    Break 
  Else 
    ExamineMouse() 
    DisplaySprite(1,MouseX(),MouseY()) 
    FlipBuffers() 
  EndIf 
Until Quit
But the thread is the only method, to use menus, without stopping drawing the window...

i found a methode:
Create a empty Cursor.cur

before

Code: Select all

;nocursor=load a cursor
GetCursorPos_(OldPos.POINT)
  OldClassCursor=SetClassLong_(MainWindow,#GCL_HCURSOR,NoCursor)
  OldCursor=SetCursor_(NoCursor)
  ShowCursor_(#False) 
  
  ReleaseMouse(#False) 
...

after

Code: Select all

ReleaseMouse(#True)
  ShowCursor_(#True)
  SetCursor_(OldCursor)
  SetClassLong_(MainWindow,#GCL_HCURSOR,OldClassCursor)
  SetCursorPos_(OldPos\x,OldPos\y)

Posted: Sun Apr 11, 2004 11:42 am
by freak
I'm not sure if this is a good idea.

The windowed screen is a childwindow your Window, and it needs to have
access to the message queue.
By moving the window into a different thread, you also have it's message queue
attached to a different thread.
That's the reason for the mouse-thing.

And it might also have other impacts in the WindowedScreen, but i don't really
know, because i never tried it.

To be on the save side, i would try to keep both in the same thread.

Timo

Posted: Tue Apr 13, 2004 9:28 pm
by GPI
freak wrote:I'm not sure if this is a good idea.
But i really need this. It is a really necassary, when you work with openwindowedscreen, because the only reason for the windowedscreen is, that i want to use the Menus, requesters, and so on.

But how do this, when all is in the same thread? Then the animations in the screen stop, when the menu popup or when i open a requester (and when you move the requester, it destroy the screen and turn it to grey).

And it is also not a good idea to use directX in a other thread...

So how should i solve the Problem. How can i get the Window-Messages without threads (and without thousends API-Commands).

Is it possible to create a thread, so that windows don't make any diffrent in the messagesystem.

(in German: Ist es irgendwie möglich, einen Thread so zu erstellen, daß Windows hinsichtlich der Nachrichtenverwaltung keinerlei Unterschiede macht? Wie gesagt: Irgendwie ist es einfach bei WindowedScreen pflicht, das *gleichzeitig* sowohl die Windows-Nachrichten und auch das Neuzeichnen der Fenster abläuft und das eine nicht das andere binhindern darf)