View previous topic :: View next topic |
Author |
Message |
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Thu Sep 18, 2003 7:30 pm Post subject: |
|
|
I'm still confused here. As far as I can see, @mousepos() does return the screen co-ordinates. It's only the DIALOG POPUP command that relativizes the co-ordinates to the window client area. Am I wrong here?
So the issue is about changing DIALOG POPUP not changing @mousepos(). I can't imagine many people even bother specifying the co-ordinates for the popup menu, as it's easier to let it pop up where the mouse is, which it does by default. _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Thu Sep 18, 2003 8:47 pm Post subject: |
|
|
I tried to find a good solution for Chris' script using some API calls, but it seems like the
cursor will still be strangely off by a few pixels:
Code: | #define command,AbsToRel
#define command,RelToAbs
option decimalsep,.
DIALOG CREATE,New Dialog,10,10,181,95,CLASS VDSTEST
DIALOG ADD,TEXT,TEXT1,8,8,,,TEXT1
DIALOG ADD,TEXT,TEXT2,26,7,,,TEXT2
DIALOG ADD,BUTTON,BUTTON1,51,3,170,24,"Supposed To Show Right"
DIALOG SHOW
:timer
dialog set,text1,X=@mousepos(X)
dialog set,text2,Y=@mousepos(Y)
:evloop
wait event,0.1
goto @event()
:button1button
%%top = @mousepos(Y)
%%left = @mousepos(X)
abstorel #VDSTEST
dialog Popup,Item1|Item2|Item3,%%top,%%left
goto evloop
:close
exit
:AbsToRel
rem abstorel <window handle number>
rem pre: %%top and %%left contain the absolute coordinates
rem post: %%top and %%left contain the coordinates relative to <window handle number>
rem effect: converts absolute screen coordinates to coordinates relative to
rem the specified window.
loadlib user32
%p = @binary(dword,%%left)@binary(dword,%%top)
%x = @lib(user32,ScreenToClient,bool:,@strdel(@winexists(%1),1),@addr("%p"))
if %x
%%left = @val(@substr(%p,1,4))
%%top = @val(@substr(%p,5,)
if @greater(%%left,2147483647)
rem value is negative
%%left = @fsub(%%left,4294967295)
end
if @greater(%%top,2147483647)
rem value is negative
%%top = @fsub(%%top,4294967295)
end
else
error -1
end
freelib user32
exit
:RelToAbs
rem reltoabs <window handle number>
rem pre: %%top and %%left contain the coordinates relative to <window handle number>
rem post: %%top and %%left contain the absolute coordinates
rem effect: converts coordinates relative to the specified window to absolute
rem screen coordinates.
loadlib user32
%p = @binary(dword,%%left)@binary(dword,%%top)
%x = @lib(user32,ClientToScreen,bool:,@strdel(@winexists(%1),1),@addr("%p"))
if %x
%%left = @val(@substr(%p,1,4))
%%top = @val(@substr(%p,5,)
if @greater(%%left,2147483647)
rem value is negative
%%left = @fsub(%%left,4294967295)
end
if @greater(%%top,2147483647)
rem value is negative
%%top = @fsub(%%top,4294967295)
end
else
error -1
end
freelib user32
exit |
PS: I'm not sure if the correction for negative numbers is really implemented well... |
|
Back to top |
|
|
PGWARE Web Host
Joined: 29 Dec 2001 Posts: 1562
|
Posted: Thu Sep 18, 2003 9:02 pm Post subject: |
|
|
Your right this only pertains to POPUP, I just noticed this. I think this is fine since use of popups are typically for within the applications form or for taskicon. |
|
Back to top |
|
|
jules Professional Member
Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Fri Sep 19, 2003 9:15 am Post subject: |
|
|
If you want to use it for a tray icon then it really needs to use screen co-ordinates, so in that case DIALOG POPUP needs changing... _________________ The Tech Pro
www.tech-pro.net |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|