AutoHotkey Community

It is currently May 26th, 2012, 3:04 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: January 24th, 2009, 11:43 pm 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
I want to create my own slider, to avoid background transparency problems.

I have 2 images, the slider bar and the slider 'thumb'.

I know I can detect when they are clicked using a g - subroutine, but how do you detect which way they are moving the mouse once they have clicked it? (And adjust the values accordingly.)

Can someone show an example please?

thanks


Last edited by mb777 on January 25th, 2009, 8:39 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2009, 3:06 am 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
what do u want to "Slide" The pictures? Or do you want the slider to adjust the Opacity? (invisbleness)

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2009, 8:39 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Sorry - I did not explain myself very clearly.

Basically I want to simulate a GUI slider.

I want to create my own style - (or skin i suppose) for an application. So instead of using the built in GUI Slider control, I want to make my own. I have a bar image. and a 'thumb' image (the bit that slides along the bar).

So, once the 'thumb' is clicked, how can I move the slider along with the mouse drag?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 25th, 2009, 2:20 pm 
Offline

Joined: June 9th, 2008, 2:32 am
Posts: 936
Location: Canada
I dont know. You might want to check this out tho http://www.autohotkey.com/forum/viewtopic.php?p=200822#200822

_________________
Image
I know i have 6 legs. It's cuz I'm special.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 7:28 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Thanks,
It did help. I'm getting there slowly. Clicking on the slider 'thumb' now lets u move it and the value changes...

But as soon as u click, it disappears!
also, i had to remove my adding of the updown, because for some reason, that caused the 'thumb' image to disappear too


NOTE: This is part of a large program , so it wont work on as it is...

Code:

arraycol--        ;TAKE 1 OFF - THIS IS NOW THE NUMBER OF COLS IN THE ARRAY 'CELL      '
; *********************             FUNCTION KEY TABS     **********************************
;                            WE WILL DISPLAY ON 3 TABS F1-4 F5-8 AND F9-12   
row:=0                 ;COLUMNS COUNTER - SET TO = COLNUM AFTER EACH TAB   
rowplus:=1
tabnum:=1                   ;TAB NUMBERS
fkeyspertab:=4
arrayrow:= 1
loop
{
   row:=0                     ;ROW COUNTER
   rowplus:=1
   if (arrayrow>11)
   {
;      msgbox too much too much
      break
   }
   gui,tab,%tabnum%             ;SELECT TAB - THIS LOOP IS REPEATED 4 TIMES - 1 ON EACH TAB
   loop
   {
      if ((row>fkeyspertab) or (arrayrow>11)) ;if we reach end of tabrows,start new tab
      ;                                        if we reach end of array, break out both loops
      {
         break
      }
      
      ;msgbox, row after : %row%
      col:=0
   
      
      ;COLUMN HEADERS (= 1ST ROW)
      if (row=0)             ;DO THE HEADER ROW?
      {
         gui,font,%titlefontstyle%
         firstcolheaders:=initcolgap+rowhead_width+slider_padding+slider_width+slider_padding+edit_width+slider_padding
          newfch:=firstcolheaders+10
         gui,add,picture,backgroundtrans center y80 x%newfch% ,%sliderheads%
         tslider_padding:=slider_padding
         gui,add,text, h%slider_height% backgroundtrans center y%initrowgap% x%initcolgap%  w%rowhead_width%,%colhead0%
         gui,add,text, h%slider_height% backgroundtrans center y+-20 x+%tslider_padding% w%slider_width%,%colhead1%
         tslider_padding:=(slider_padding*4)+(edit_width*2)
      }
      else
      {
         if (row=1)
         {
            trow_padding:=firstrow_padding
         }
         else
         {
            trow_padding:=row_padding
         }
         
         ;ROW HEADERS (=1ST COLUMN)
         tmprowhead:=rowhead%arrayrow%
         ;msgbox,rowhead%row%
         gui, font, %titlefontstyle%
         gui,add,text, y+%trow_padding% backgroundtrans h%slider_height% x%initcolgap% w%rowhead_width% left, %tmprowhead%
                  
         fire:=cell%arrayrow%_1
         editname:=% fire . "box"
         updownname:=% fire . "upd"
         barname:= % fire . "bar"
         weaponslot:=cell%arrayrow%_2
         lowg:=cell%arrayrow%_3
         slot2tog:=cell%arrayrow%_4
         strengthon:=cell%arrayrow%_5
         strengthval:=cell%arrayrow%_6
            xtest:=initcolgap+20
         gapafterslider:=250
 
         ;'EDITBOX' VARIABLES ARE SIMPLY SLIDER VARIABLES WITH 'BOX' APPENDED TO THE NAME
         ;'updown' VARIABLES ARE SIMPLY SLIDER VARIABLES WITH 'UPD' APPENDED TO THE NAME

         gui, font, %txtfontstyle%
         
         gui,add,picture,backgroundtrans v%barname% x+20 yp,%sliderbar%
         gui,add,picture,backgroundtrans v%fire% xp yp gslidervals2,%sliderthumb%
           msgbox ,,,%sliderthumb%,10
         
         ;gui,add,slider,v%fire% c%controlcolor% backgroundtrans gslidervals Buddy2%veditname% thick%slider_thumb% h%slider_height% x+%slider_padding% w%slider_width% line%slider_line% page%slider_page% range%minrange%-%maxrange% TickInterval%slider_Interval% ToolTipTop,%sliderstartval%
         gui,add,edit,v%editname% backgroundtrans c%txtcolor% gslidervals H%slider_height% x+%gapafterslider% w%edit_width% limit%edit_limit% number,%sliderstartval%
         msgbox ,,,%sliderthumb%,10
         ;gui,add,updown,v%updownname% xp yp h%slider_height% range%minrange%-%maxrange%,%sliderstartval%
         ;msgbox ,,,%sliderthumb%,10
         ddl_width:=edit_width-20
         gui,add,dropdownlist,v%weaponslot% x+%slider_padding% h%slider_height% w%ddl_width%,%weaponslotlist%
         ;msgbox ,,,%sliderthumb%,10
           addcheckbox(lowg,"green","yp","x+20")
         ;msgbox ,,,%sliderthumb%,10
         addcheckbox(slot2tog,"green","yp","x+20")
         ;msgbox ,,,%sliderthumb%,10
         addcheckbox(strengthon,"green","yp","x+20")         
         ;msgbox ,,,%sliderthumb%,10
         gui,add,dropdownlist,v%strengthval% x+%slider_padding% h%slider_height% w%ddl_width%,%weaponstrengthlist%
         ;msgbox ,,,%sliderthumb%,10
         ;msgbox,,,displaypng(pic%checkbox1no%,greencheckboxoniconum)::hWndPic%checkboxno1%::row:%row%::arow::%arrayrow%
         arrayrow++
      }
      row++
      rowplus++
      
   }
   tabnum++
}



Code:
slidervals2:
   tslidepos:=""
   gui, 1:submit,nohide
   coordmode,mouse,relative
   tcontrolname:=A_GuiControl                 ; Find out what control called this subroutine
   teditname:=tcontrolname . "box"
   tbarname:=tcontrolname . "bar"
   tupdname:=tcontrolname . "upd"
   tmaxval:=maxrange
   mousegetpos,mousefx,mousefy,tposnow
   guicontrol,,tcurrval,%teditname%
   guicontrolget,tbarpos,pos,%tbarname%
   maxright:=(tbarposx+tbarposw)
   loop
   {
      mousegetpos,mousex,mousey           ;get current mouse pos
      if checkkeydown("LButton")             ;check left button is still down
         break
      if (mousex>maxright)
         mousex:=maxright
      if (mousex<tbarposx)
         mousex:=tbarposx
      tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
      guicontrol,move,tcontrolname,mousex,mousefy
      guicontrol,,%teditname%,%tnewval%
      guicontrol,,%tupdname%,%tnewval%
      
   }
   
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 7:54 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Well Closer now...

made a stupid mistake with the guicontrol,move command. Sorted that, now the problem is that instead of moving the 'thumb', it moves the edit control that shows the value, along the slider.

The first time I click on the slider, A_guicontrol is shown as the thumb image, but it is immediately changed to the edit control if I move the mouse. The edit control steals focus.

I could make the edit control disabled, but I want the user to be able to enter a value in there.

Code:
slidervals2:
   tslidepos:=""
   gui, 1:submit,nohide
   coordmode,mouse,relative
   tcontrolname:=A_GuiControl                 ; Find out what control called this subroutine
   teditname:=tcontrolname . "box"
   tbarname:=tcontrolname . "bar"
   tupdname:=tcontrolname . "upd"
   tmaxval:=maxrange
   mousegetpos,mousefx,mousefy,tposnow      ;position of mouse when thumb is clicked
   guicontrol,,tcurrval,%teditname%
   guicontrolget,tbarpos,pos,%tbarname%
   maxright:=(tbarposx+tbarposw)
   loop
   {
      mousegetpos,mousex,mousey           ;get current mouse pos
  msgbox,,,%mousefx%x%mousefy%:::%mousex%x%mousey%`n`n %tcontrolname%,.6
      if checkkeydown("LButton")             ;check left button is still down
         break
      if (mousex>maxright)                  ;dont allow the value to go out of range
         mousex:=maxright
      if (mousex<tbarposx)
         mousex:=tbarposx
         
      tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
      guicontrol,move,%tcontrolname%, x%mousex% y%tbarposy%        ;move control with mouse - does not seem to work - thumb disappears!
      guicontrol,,%teditname%,%tnewval%                ;update values of the edit box
      ;guicontrol,,%tupdname%,%tnewval%
      
   }
   
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 8:26 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Now, when I update the edit control, it moves the edit control along the slider bar, and the 'thumb' image disappears.

But if I dont update the edit control, the thumb image stays and moves along the slider like it should.

Code:
slidervals2:
   tslidepos:=""
   gui, 1:submit,nohide
   coordmode,mouse,relative
   tcontrolname:=A_GuiControl                 ; Find out what control called this subroutine
   ttcontrolname:=tcontrolname
    msgbox,,,%tcontrolname%`n`n%ttcontrolname%,.6
   teditname:=tcontrolname . "box"
   tbarname:=tcontrolname . "bar"
   tupdname:=tcontrolname . "upd"
   tmaxval:=maxrange
   mousegetpos,mousefx,mousefy,tposnow      ;position of mouse when thumb is clicked
   guicontrol,,tcurrval,%teditname%
   guicontrolget,tbarpos,pos,%tbarname%
   maxright:=(tbarposx+tbarposw)
   loop
   {
      mousegetpos,mousex,mousey           ;get current mouse pos
  ;msgbox,,,%mousefx%x%mousefy%:::%mousex%x%mousey%`n`n %tcontrolname%,.6
      if checkkeydown("LButton")             ;check left button is still down
         break
      if (mousex>maxright)                  ;dont allow the value to go out of range
         mousex:=maxright
      if (mousex<tbarposx)
         mousex:=tbarposx
         
      tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
      guicontrol,1:move,%ttcontrolname%, x%mousex% y%tbarposy%        ;move control with mouse
      guicontrol,1:,%teditname%,%tnewval%                ;update values of the edit box
   ;guicontrol,1:,%tupdname%,%tnewval%
      
   }
   
return



Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 8:49 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Ughhhh! Found the problem

The edit control was calling an old subroutine, that caused the thumb image to disappear!

It works now. Just need to make it so that changing the edit or updown controls, will move the slider


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 10:25 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Well here it is - it is not perfect , but it works...

Code:
movecustomslider:
  gui ,1:submit, nohide
  tcontrolname:=A_GuiControl                 ; Find out what control called this subroutine
   if (substr(tcontrolname,-2,3)="box" or substr(tcontrolname,-2,3)="upd") ; User clicked on edit or updown control
  {
      guicontrolget,tcontrolval,,%tcontrolname%  ; store value of control to a variable
      stringtrimright,tsetcontrolname,tcontrolname,3
      tsetslider:=tsetcontrolname
      ;msgbox,,,%tcontrolname%::%tsetslider%,8
      tbarname:=tsetcontrolname . "bar"
      tmaxval:=maxrange
      tnewsliderpos:=0
      if (substr(tcontrolname,-2,3)="box")
     {
         tsetcontrolname:=tcontrolname . "upd"
       }
     else
     { 
        tsetcontrolname:=tcontrolname . "box"
     } 
     tcontrolval:=tcontrolval="" ? 0 : tcontrolval
     tcontrolval:=tcontrolval>maxrange ? maxrange : tcontrolval
      guicontrol,1:,%tsetcontrolname%,%tcontrolval%  ; set valuse of corres control
     ;position custom made slider
      guicontrolget,tbarpos,pos,%tbarname%       ;get pos (x,y,width and height) of the 'bar' of the slider
     tnewsliderpos:=tbarposx+(tbarposw*(tcontrolval/tmaxval))
     guicontrol, 1:move,%tsetslider%, x%tnewsliderpos% y%tbarposy%
   }
   else
   {  ;User clicked on slider thumb
   
      tsetcontrolname:=tcontrolname . "upd"
      tslidepos:=0
      gui, 1:submit,nohide
      coordmode,mouse,relative
      ;msgbox,,,CALLED`n`n%tcontrolname%`n`n%ttcontrolname%,.6
      teditname:=tcontrolname . "box"
      tbarname:=tcontrolname . "bar"
      tupdname:=tcontrolname . "upd"
      tmaxval:=maxrange
      ;mousegetpos,mousefx,mousefy,tposnow      ;position of mouse when thumb is clicked
      guicontrolget,tbarpos,pos,%tbarname%
      maxright:=(tbarposx+tbarposw)   ;   ycoord of right edge of slider bar
      loop
      {
         mousegetpos,mousex,mousey           ;get current mouse pos
   ;msgbox,,,%mousefx%x%mousefy%:::%mousex%x%mousey%`n`n %tcontrolname%::%ttcontrolname%,.6
         if checkkeydown("LButton")             ;check left button is still down
            break
         if (mousex>maxright)                  ;dont allow the value to go out of range
            mousex:=maxright
         if (mousex<tbarposx)
            mousex:=tbarposx
         
         tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
         guicontrol,1:move,%tcontrolname%, x%mousex% y%tbarposy%        ;move control with mouse
         ttposx:=mousex-6
         ttposy:=tbarposy-5
         tooltip,%tnewval%,ttposx,ttposy
      }
      guicontrol,1:,%teditname%,%tnewval%                ;update values of the edit box   
         guicontrol,1:,%tupdname%,%tnewval%
   }
return
checkkeydown(key,checkdelay =2)
{
   
     Sleep, %checkdelay%
   GetKeyState, state, %key%, P
   if state = U  ; The key has been released, so break out of the loop.
       return true
   else
      return false
}




For this to work, you have to give your controls the following variable names:

Slider 'Thumb' Graphic (The bit that you move) : eg. myslider
Slider Bar Graphic : mysliderbar
editcontrol: mysliderbox
updowncontrol on editcontrol : mysliderupd

I put a tooltip in to show the current position while the user is moving it, because if I updated the edit control during moving the slider, the 'thumb' graphic disappeared, and the edit control moved along the slider.

This is because the edit control calls the subroutine when its value is changed.

I could not find a way round this, so I put the tooltip in, and updated the edit control after the move was complete.

If anyone can improve this, that would be great...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 27th, 2009, 10:48 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
Still have a problem, the tooltip appears behind the window, and also would like the edit control to change as you move the slider , if at all possible.

Code:
movecustomslider:
  gui ,1:submit, nohide
  tcontrolname:=A_GuiControl                 ; Find out what control called this subroutine
   if (substr(tcontrolname,-2,3)="box" or substr(tcontrolname,-2,3)="upd") ; User clicked on edit or updown control
  {   guicontrolget,tcontrolval,,%tcontrolname%  ; store value of control to a variable
      stringtrimright,tsetcontrolname,tcontrolname,3
      tsetslider:=tsetcontrolname
      ;msgbox,,,%tcontrolname%::%tsetslider%,8
      tbarname:=tsetcontrolname . "bar"
      tmaxval:=maxrange
      tnewsliderpos:=0
      if (substr(tcontrolname,-2,3)="box")
     {
         tsetcontrolname:=tcontrolname . "upd"
       }
     else
     { 
        tsetcontrolname:=tcontrolname . "box"
     } 
     tcontrolval:=tcontrolval="" ? 0 : tcontrolval
     tcontrolval:=tcontrolval>maxrange ? maxrange : tcontrolval
      guicontrol,1:,%tsetcontrolname%,%tcontrolval%  ; set valuse of corres control
     ;position custom made slider
      guicontrolget,tbarpos,pos,%tbarname%       ;get pos (x,y,width and height) of the 'bar' of the slider
     tnewsliderpos:=ceil(tbarposx+(tbarposw*(tcontrolval/tmaxval)))
     guicontrol, 1:move,%tsetslider%, x%tnewsliderpos% y%tbarposy%
   }
   else
   {  ;User clicked on slider thumb
   
      tsetcontrolname:=tcontrolname . "upd"
      tslidepos:=0
      gui, 1:submit,nohide
      coordmode,mouse,relative
      ;msgbox,,,CALLED`n`n%tcontrolname%`n`n%ttcontrolname%,.6
      teditname:=tcontrolname . "box"
      tbarname:=tcontrolname . "bar"
      tupdname:=tcontrolname . "upd"
      tmaxval:=maxrange
      ;mousegetpos,mousefx,mousefy,tposnow      ;position of mouse when thumb is clicked
      guicontrolget,tbarpos,pos,%tbarname%
      maxright:=(tbarposx+tbarposw)   ;   ycoord of right edge of slider bar
      loop
      {
         mousegetpos,mousex,mousey           ;get current mouse pos
   ;msgbox,,,%mousefx%x%mousefy%:::%mousex%x%mousey%`n`n %tcontrolname%::%ttcontrolname%,.6
         if checkkeydown("LButton")             ;check left button is still down
            break
         if (mousex>maxright)                  ;dont allow the value to go out of range
            mousex:=maxright
         if (mousex<tbarposx)
            mousex:=tbarposx
         
         tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
         guicontrol,1:move,%tcontrolname%, x%mousex% y%tbarposy%        ;move control with mouse
         ttposx:=mousex-6
         ttposy:=tbarposy-5
         tooltip,%tnewval%,ttposx,ttposy
      }
      tooltip
      guicontrol,1:,%teditname%,%tnewval%                ;update values of the edit box   
      guicontrol,1:,%tupdname%,%tnewval%
   }
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2009, 2:29 am 
Offline

Joined: January 8th, 2009, 11:36 pm
Posts: 42
So here it is: Creating a slider using your own graphics - 2 image files. One for the bar, and one for the thumb (the bit that moves)

You have the sliderbar and thumb, plus an edit box with an updown control. The thumb, editbox and updown controls all call the same sub-routine when they are changed.

The value of the editbox will change when you move the slider. The slider position will change when you use the up down arrows, or enter a value in the editbox. Also, you can click anywhere on the bar (just like a standard slider control)

You must make sure to name them as follows for this to work:

The thumb:- Any name - eg: Slider - This is the root from
The Bar :- eg: Sliderbar which the others are
The editbox eg: Sliderbox based.
The updown control eg Sliderupd

Also, there is a function that will automatically put a scale under the slider.

Code:
         addpng(sliderbariconum,"backgroundtrans gmovecustomslider v" . barname . " x" . sliderbarxpos . " yp",hModule)
         guicontrolget,tbarpos,pos,%barname%
         sliderstartpos:=sliderbarxpos+((sliderstartval//maxrange)*tbarposw)
         addpng(sliderthumbiconum,"backgroundtrans v" . fire . " x" . sliderstartpos . " yp gmovecustomslider",hModule)
         ;keywait,enter,T5 D
         gui,add,edit,v%editname% backgroundtrans  gmovecustomslider c%txtcolor% H%slider_height% yp-8 x%gapafterslider% w%edit_width% limit%edit_limit% number
         gui,add,updown,v%updownname%  gmovecustomslider range%minrange%-%maxrange%, %sliderstartval%
scale(%barname%,200,maxrange,0,tbarposw,sliderbarxpos,tbarposy+8)        ; This adds the scale


The addpng, is just a function that adds a .png file from a resource file.dll. But as just think of it as adding a picture normally.


Code:
movecustomslider:
  ;msgbox afj
  gui ,1:submit, nohide
               ; Find out what control called this subroutine
  temptxt:=substr(A_guicontrol,-2,3)
   if (temptxt = "box" or temptxt = "upd" or temptxt = "bar")
      stringtrimright,tcontrolname,a_guicontrol,3
   else
      tcontrolname:=a_guicontrol
   tbarname:=tcontrolname . "bar"
   teditname:=tcontrolname . "box"
   tupdname:=tcontrolname . "upd"
   tmaxval:=maxrange
   if (a_guicontrol=teditname or a_guicontrol=tupdname) ; User clicked on edit or updown control
  {   
      guicontrolget,tcontrolval,,%a_guicontrol%  ; store value of control to a variable
      tnewsliderpos:=0
      tsetcontrolname:=a_guicontrol=teditname ? tupdname : teditname
      tcontrolval:=tcontrolval="" ? 0 : tcontrolval
       tcontrolval:=tcontrolval>maxrange ? maxrange : tcontrolval
      guicontrol,1:,%tsetcontrolname%,%tcontrolval%  ; set valuse of corres control
     ;position custom made slider
      guicontrolget,tbarpos,pos,%tbarname%       ;get pos (x,y,width and height) of the 'bar' of the slider
     tnewsliderpos:=ceil(tbarposx+(tbarposw*(tcontrolval/tmaxval)))
     guicontrol, 1:move,%tcontrolname%, x%tnewsliderpos% y%tbarposy%
    }
   
   else
   {  ;User clicked on slider thumb or bar
      tslidepos:=0
      
      coordmode,mouse,relative
      guicontrolget,tbarpos,pos,%tbarname%
      maxright:=(tbarposx+tbarposw)   ;   ycoord of right edge of slider bar
      loop
      {
         mousegetpos,mousex,mousey           ;get current mouse pos
   
         if (mousex>maxright)                  ;dont allow the value to go out of range
            mousex:=maxright
         if (mousex<tbarposx)
            mousex:=tbarposx
         tnewval:=ceil(((mousex-tbarposx)/tbarposw) * tmaxval)     ;new value of slider
         ;msgbox ,,,tnewval:=ceil(((%mousex%-%tbarposx%)/%tbarposw%) * %tmaxval%)  `n`n          =%tnewval%`n`nguicontrol,1:move,%tcontrolname%, x%mousex% y%tbarposy%`n`n%A_GuiControl%
         guicontrol,1:move,%tcontrolname%, x%mousex% y%tbarposy%        ;move control with mouse
         ttposx:=mousex-6
         ttposy:=tbarposy-5
         tooltip,%tnewval%,ttposx,ttposy
         if (checkkeydown("LButton") or (a_guicontrol=tbarname)) ;check left button is still down
         {   
            break                                           ; or if user clicked on bar exit loop
            }
      }
      tooltip
      guicontrol,1:,%teditname%,%tnewval%                ;update values of the edit box   
      guicontrol,1:,%tupdname%,%tnewval%
      ;msgbox,,,guicontrol.1:.%tupdname%.%tnewval%::%A_GuiControl%
      
   }
return




....and here is the scale function....
Code:
scale(slidebar,bigsteps,max,min =0,w =999,x =999,yy =999,startpostatmin =false, smscale ="smscale.bmp")
{
   global
   static uid:=1
   xpox:=0
   varname:=""
   guicontrolget,scale,pos,%slidebar%   
   w:=w=999 ? scalew : w
   x:=x=999 ? scalex : x
   yy:=yy=999 ? scaley :yy
   smsteps:=50
   smintervals:=max/smsteps
   bigintervals:=max/bigsteps
   if startpostatmin
      bigstartpostlabel:=min
   else
      bigstartpostlabel:=mod(min,bigsteps)=0 ? min : ((min//bigsteps)+1)*bigsteps
   smposts:=smintervals+1
   bigposts:=bigintervals+1
   unitdist:=(w/(max-min))
   bigintervaldistance:=unitdist*bigsteps
   smintervaldistance:=unitdist*smsteps
   bigstartpost:=startpostatmin=true ? 0 : (mod(min,bigsteps))*unitdist
;   loop %smposts%
;   {
;      yy:=a_index=1 ? yy : "p"
;      xpox:=x+(smintervaldistance*(a_index-1))
;      gui,1:add,picture,y%yy% x%xpox% w.5 h7,%smscale%
;      ;msgbox,,,gui.1:add.picture.y%yy% x%xpox% w1 h3.%smscale%`n`n`nxpox:=%x%+(%smintervaldistance%*(%a_index%-1))::%xpox%,.5
;   }
   loop %bigposts%
   {
      yy:=a_index=1 ? yy : "p"
      xpox:=x+bigstartpost+(bigintervaldistance*(a_index-1))
      if startpostatmin
         bigpostlabel:=min+(bigsteps*(a_index-1))
      else
         bigpostlabel:=((bigstartpostlabel//bigsteps)+(a_index-1))*bigsteps
      varname=scale_%uid%_%a_index%
      gui, add, text, x%xpox% y%yy% backgroundtrans v%varname%,%bigpostlabel%
      guicontrolget,tempos,pos,%varname%
      guicontrol,1:move,%varname%, % "x" temposx-(temposw/2)
      ;msgbox,,,%tempww%`n`n%varname%,.5
   }
   uid++
return
}


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], G. Sperotto, patgenn123, Tilter_of_Windmills and 20 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