top,left should be y,x

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

top,left should be y,x

Post by PepsiHog » Sat May 28, 2011 5:07 pm

v12.1.4 Windows XP sp3

Hello Everyone,

I'm messing around with trying to make a right-click menu.
The rclick menu is initially not visible. When you rclick it becomes visible
only after the Top,Left coordinates is set to the cursor pos.

But it never appears near the cursor. It just jumps around. Top pos would be y. Because it's a vertical set. Left would be x, because it's accross.

Yet it no want to work. Me getting very upset! Maybe you can tell me why this is not working. Please.

JRL - Here's another "Why won't this work?"

Code: Select all

let>x=0
let>y=0

Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 104
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 216
  ClientWidth = 439
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSListBox1: tMSListBox
    Left = 280
    Top = 27
    Width = 65
    Height = 62
    Style = lbOwnerDrawFixed
    BevelEdges = []
    BorderStyle = bsNone
    ItemHeight = 13
    TabOrder = 0
    Visible = False
    SelectedIndex = -1
  end
  object MSButton1: tMSButton
    Left = 90
    Top = 86
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

OnEvent>Key_Down,VK2,0,RghtClick
AddDialogHandler>Dialog1,,OnClose,Finish


Show>Dialog1


Label>Start
GetDialogAction>Dialog1,KeyStroke
Goto>Start


srt>RghtClick
GetCursorPos>x,y

sub>x,%x%
//sub>y,1
SetDialogProperty>Dialog1,MSListBox1,Left,%y%
SetDialogProperty>Dialog1,MSListBox1,Top,%x%
SetDialogProperty>Dialog1,MSListBox1,Visible,True
GetDialogProperty>Dialog1,MSListBox1,Left,Lft
GetDialogProperty>Dialog1,MSListBox1,Top,tp
//mdl>%x% %Lft%  %tp%



END>RghtClick

srt>Finish
  exit
END>Finish

I did change the style of MSListBox1 (rclick menu). I thought maybe that might be the issue. But, nop.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Sun May 29, 2011 3:24 am

JRL - Here's another "Why won't this work?"
I see two things. First you have reversed your x and y. You set left to y and top to x. The other thing is that cursor position is a screen position and left and top are dialog positions. So you need to get the position of the dialog and subtract that from the cursor positions. You will also find that you need to subtract the title bar size and the border size to be really precise.

Code: Select all

Dialog>TitleBarSizeCalculation
Top=0
Left=0
Button=1,0,0,75,25,0
EndDialog>TitleBarSizeCalculation
Let>WIN_USEHANDLE=1
GetWindowPos>TitleBarSizeCalculation.msButton1.handle,OffSetX,OffSetY
Let>WIN_USEHANDLE=0


Dialog>Dialog1
object Dialog1: TForm
  Left = 251
  Top = 104
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 216
  ClientWidth = 439
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object MSListBox1: tMSListBox
    Left = 280
    Top = 27
    Width = 65
    Height = 62
    Style = lbOwnerDrawFixed
    BevelEdges = []
    BorderStyle = bsNone
    ItemHeight = 13
    TabOrder = 0
    Visible = False
    SelectedIndex = -1
  end
  object MSButton1: tMSButton
    Left = 90
    Top = 86
    Width = 75
    Height = 25
    Caption = 'MSButton1'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 1
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

OnEvent>Key_Down,VK2,0,RghtClick
AddDialogHandler>Dialog1,,OnClose,Finish


Show>Dialog1


Label>Start
GetDialogAction>Dialog1,KeyStroke
Goto>Start


srt>RghtClick
GetCursorPos>curx,cury
GetWindowPos>CustomDialog,winx,winy
Sub>Curx,%winx%
Sub>Cury,%winy%
Sub>Curx,%offsetx%
Sub>Cury,%offsety%

//sub>x,%x%
//sub>y,1
SetDialogProperty>Dialog1,MSListBox1,Left,%Curx%
SetDialogProperty>Dialog1,MSListBox1,Top,%Cury%
SetDialogProperty>Dialog1,MSListBox1,Visible,True
//GetDialogProperty>Dialog1,MSListBox1,Left,Lft
//GetDialogProperty>Dialog1,MSListBox1,Top,tp
//mdl>%x% %Lft%  %tp%



END>RghtClick

srt>Finish
  exit
END>Finish

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

blah

Post by PepsiHog » Sun May 29, 2011 6:55 am

Ok. Thanks.

I went back and fourth with the x,y. I had it right (that's what I started out thinking, what you said) but then the problems.

I was confused. But I did not think about getcursorpos being the full screen. That got by me. Oh well.

Thanks for the assist.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts