Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,227 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mino, squik, AemStones, LucasJoshua, Baklazhan
19061 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Position Cursor DLL [Re: adoado] #170780
01/29/08 15:25
01/29/08 15:25
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline
Serious User
ulf  Offline
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
that would be a nice ressource to learn from for a lot of people

Re: Position Cursor DLL [Re: ulf] #170781
01/30/08 16:53
01/30/08 16:53
Joined: Aug 2005
Posts: 1,012
germany, dresden
ulf Offline
Serious User
ulf  Offline
Serious User

Joined: Aug 2005
Posts: 1,012
germany, dresden
so far i got the following code, wich is already working pretty good. my only problem right now are to get the border values around the engine window. this can be different from system to system. so one user might have a real big border around every window - so this border will be around the gamestudio engine window too.

right now i try to get the correct values with

caption_size = sys_metrics(4)+sys_metrics(7); //SM_CYCAPTION
border_size = sys_metrics(7);

because i assume the title + border size forms the top window, then i just add +1 to make shure its really inside.

this seems to work for me but i'm not shure if this is correct. you have to constantly run mouse_checkTrap() in a loop to handle alt+tab losing focus of the engine window and you have to use mouse_setTrap() everytime you switch the resolution and mouse_freeTrap() once you exit the engine to make shure the mouse is set free again.

did i forgot something? is this the correct way of getting the borders?


Code:

//-----------------
// traps the mouse inside engine window
//-----------------

void mouse_setTrap()
{
RECT rc_clip;
short caption_size;
short border_size;

caption_size = sys_metrics(4)+sys_metrics(7); //SM_CYCAPTION
border_size = sys_metrics(7);

// lets set a rectangle with the correct size depending on what the user desktop settings are
// so the mouse gets trapped in the engine window even if he has some fancy windows theme
rc_clip.top = window_pos.y+caption_size+1;
rc_clip.left = window_pos.x+border_size+1;
rc_clip.right = window_pos.x+screen_size.x+border_size;
rc_clip.bottom = window_pos.y+screen_size.y+caption_size;

ClipCursor(&rc_clip);
}

//-----------------
// set me free
//-----------------

void mouse_freeTrap()
{
ClipCursor(NULL);
}


//-----------------
// watch mouse trap in a loop somewhere to release the trap if engine lost focus
//-----------------

void mouse_checkTrap()
{

if(!window_focus)
{
if(mouse_isTrapped)
{
mouse_isTrapped=FALSE;
mouse_freeTrap();
}
}
else
{
if(!mouse_isTrapped)
{
mouse_isTrapped=TRUE;
mouse_setTrap();
}
}



Re: Position Cursor DLL [Re: ulf] #237125
11/18/08 12:42
11/18/08 12:42
Joined: Feb 2007
Posts: 353
A
amy Offline
Senior Member
amy  Offline
Senior Member
A

Joined: Feb 2007
Posts: 353
Thanks Ulf!

So is this 100% fool proof with the borders and everything or does anyone have a better solution?

Re: Position Cursor DLL [Re: amy] #262873
04/26/09 19:14
04/26/09 19:14
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Publishing problem...

Adoado, your dll is working perfectly, but isn't included when I publish. I have it in the Acknex_plugins folder and at the top of the main script.

What do I need to do to include it with the published version. There is almost no info about using dllfunctions in the manual.

Re: Position Cursor DLL [Re: JazzDude] #262875
04/26/09 19:32
04/26/09 19:32
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
@JazzDude
if you are using lite-c you can directly use SetCursorPos(x,y); //dont forget to include windows.h

if you are using c-skript
just copy dll manually to publish folder?

Last edited by Quadraxas; 04/26/09 19:33.

3333333333
Re: Position Cursor DLL [Re: Quad] #262883
04/26/09 20:02
04/26/09 20:02
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline
User
JazzDude  Offline
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
It occurred to me to try the "bind" command and that did it, also.

I always try the most complicated methods first, then I whine in the forum when they don't work. I learned that routine in the Klutz Koder Skool, from which I failed to graduate.

Page 2 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1