AutoHotkey Community

It is currently May 27th, 2012, 11:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: September 5th, 2010, 11:57 pm 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
I've got a list box that a user can choose from, when they select I'd like to pop a second gui up at the listbox line selected ?
ie how do I get xpos and ypos in the example below ?

[click on a,b,c,d and get the new window to appear to the right of the cursor with the first line of the new window aligned with the selected line from the main listbox]

1) Use of Coordmode, mouse
2) margin must come before listbox is added


Code:
delay=5000  ;delay for gui 2 close
coordmode, mouse

;popup gui
[;margin must come before listbox is added
gui, 2: margin, 1,1
gui, 2: add ,listbox, vnamchoice, gnumberselected
Gui, 2:-Caption

;main gui
Gui, Add, Edit, x6 y10 w240 h20 vsearchedString   -WantReturn
Gui, Add, listbox,  r6 x6 y30  w240 r10 -wrap  Border vscroll -gnamelistclick t200 vchoice, |a|b|c|d|
Gui, Show,  h169 w250, Names
GroupAdd, keycatch, Names      

Return


#IfWinActive ahk_group keycatch

Down::
GuiControlGet, FocusedControl, Focus
If FocusedControl = edit1
 {
 guicontrol, focus, listbox1
 guicontrol, choose, listbox1, 1
 }
 else
 send {Down}
Return



namelistclick:
GuiControl, 2:, namchoice , %regtext%
Gui, 2:Margin , 0, 0     ;needs to be fixed, should be no margin.
gui, 2:show, x%xpos%, y%ypos%
settimer, closechoice, %delay%
return



Closechoice:
settimer, closechoice, off
gui 2: destroy
return


Last edited by cdjones on September 6th, 2010, 4:37 am, edited 6 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 2:16 am 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
ok, so got mousegetpos to work, thanks to <tidbit>

now, how do I get rid of the gray border aorund gui2 ? Already got -caption -border

Code:
delay=3000  ;delay for gui 2 close
CoordMode, MOUSE

;popup gui
gui, 2: add, listbox, vnamchoice, gnumberselected
Gui, 2:-Caption

;main gui
Gui, Add, Edit, x6 y10 w240 h20 vsearchedString   -WantReturn
Gui, Add, listbox,  r6 x6 y30  w240 r10 -wrap  Border vscroll -gnamelistclick t200 vchoice, |a|b|c|d|e|f|g|h|
Gui, Show,  h169 w250, Names
GroupAdd, keycatch, Names      

Return


#IfWinActive ahk_group keycatch

Down::
GuiControlGet, FocusedControl, Focus
If FocusedControl = edit1
 {
 guicontrol, focus, listbox1
 guicontrol, choose, listbox1, 1
 }
 else
 send {Down}
Return



namelistclick:

mousegetpos, xx, yy
xx:=xx+5
yy:=yy+5
GuiControl, 2:, namchoice, hello world

Gui, 2: -border -caption      ;needs to be fixed, should be no margin.
gui, 2:show,  x%xx% y%yy%
    ;needs to be fixed, should be no margin.
settimer, closechoice, %delay%
return



Closechoice:
settimer, closechoice, off
gui 2: hide
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 2:29 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Try
Code:
Gui, Margin, 0, 0

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 2:35 am 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
Gui, 2: margin, 0 ,0

gets rid of the bottom and right margins only - not what is says it the documentation


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 6th, 2010, 5:52 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
cdjones wrote:
Gui, 2: margin, 0 ,0

gets rid of the bottom and right margins only - not what is says it the documentation


You are mistaken.
The command's effect is dependant on its position within the script.
If the command is issued before any components are added, it will affect all margins.
Try this script and see that the later (in the script) the margin, the later the margin 'takes' effect between controls.
Code:
#singleinstance force
#Persistent

Gui, 2:-Caption

;gui,2: margin, 0, 0

gui, 2:add, button, w100 h50

;gui,2: margin, 0, 0

gui, 2:add, button, w100 h50
gui, 2:add, button, w100 h50
gui, 2:add, button, w100 h50

;gui,2: margin, 0, 0

gui, 2:add, button, w100 h50
gui, 2:add, button, w100 h50
gui, 2:add, button, w100 h50

gui, 2:add, button, w100 h50
gui, 2:add, button, w100 h50

gui,2: margin, 0, 0

gui, 2:show


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 6th, 2010, 6:10 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
cdjones wrote:
I've got a list box that a user can choose from, when they select I'd like to pop a second gui up at the listbox line selected ?
ie how do I get xpos and ypos in the example below ?


In your original script, if you <<insert>> the following code just after the label "namelistclick"
it will a give you a good approximation of where you described.
Actually it only works for xpos, there is something strange about ypos.

Code:
SendMessage, 0x188, 0, 0, listbox1, Names  ; find current index in listbox
ChoicePos = %ErrorLevel%

ControlGet, LBhwnd, Hwnd,, listbox1, Names
WinGetPos, X, Y, Width, Height, ahk_id %LBhwnd%

rowheight:=Height/10
xpos:= x+width
ypos:=y+(ChoicePos)*rowheight

Edit: the above code has been corrected, and I missed there were (2) 'r' parameters
"Gui, Add, listbox, r6 x6 y30 w240 r10-wrap Border vscroll -gnamelistclick t200 vchoice, t|a|b|c|d| "


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2010, 3:01 pm 
Offline

Joined: September 15th, 2009, 7:16 pm
Posts: 67
Location: Ga, USA
leef_me: thanks

rowheight:=Height/10

does this mean font size = 10 ?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 10th, 2010, 5:14 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6074
Location: San Diego, California
No.

It means I retrieved the resulting measurements of the listbox and divide the height by 10 because you specified "r10" when you added the listbox.

btw, just to make it perfectly clear, using r6 and r10 in the same statement makes no sense.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], BrandonHotkey, MSN [Bot] and 16 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group