AutoHotkey Community

It is currently May 26th, 2012, 10:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: moveable tool bar?
PostPosted: May 4th, 2005, 5:13 am 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
can ahk have a moveable toolbar that doesnt use a second window? Yes. Have a look. This may not be of use to more than 10% of ahk users but I am sure this will spark an idea with a few of them
Code:
;TB = ToolBar
;TBC = ToolBar Control
#InstallMouseHook

;#### SubMenus ####

;-------------File Menu------------------
Menu, File_Menu_Gui, Add, New Session, NewSession
Menu, File_Menu_Gui, Add, Open Session, OpenExistingSession

Menu, File_Menu_Gui, Add, Import File, ImportDataFile
Menu, File_Menu_Gui, Add, Exit , ExitAppSub

;------------Tools Menu-------------------
Menu, Tools_Menu_Gui, Add, Add New Object, AddNewObject
Menu, Tools_Menu_Gui, Add, Monitor Engine, MonitorEngine

;------------Settings Menu-----------------
Menu, Settings_Menu_Gui, Add, User Preferences, UserPreferences
Menu, Settings_Menu_Gui, Add, Engine Settings, EngineSettings

;----------Edit---------------------------
Menu, Edit_Menu_Gui, Add, Edit Object, EditObject

;#### Menus seen on the Main Gui ####
Menu, MyMenuBar, Add, File, :File_Menu_Gui
Menu, MyMenuBar, Add, Edit, :Edit_Menu_Gui
Menu, MyMenuBar, Add, Tools, :Tools_Menu_Gui
Menu, MyMenuBar, Add, Settings, :Settings_Menu_Gui



;#### Main Gui Interface ####
Gui, Menu, MyMenuBar


Gui, Add, Button, vTBC1 gHideToolBar x186 y5 w15 h15, _
Gui, Add, Button, vTBC2 gMoveToolBar x200 y5 w15 h15, +
Gui, Add, Button, vTBC3 x186 y20 w15 h15, ?
Gui, Add, Button, vTBC4 x200 y20 w15 h15, #


Gui, Add, Button, vTBC5 x6 y5 w80 h30, Edit Object
Gui, Add, Button, vTBC6 x96 y5 w80 h30, Create New Object
Gui, Add, Button, vTBC7 x6 y45 w60 h30, Objects
Gui, Add, Button, vTBC8 x76 y45 w70 h30, Barriers
Gui, Add, Button, vTBC9 x156 y45 w60 h30, Sounds
Gui, Add, Button, vTBC10 x6 y85 w30 h30, <
Gui, Add, Button, vTBC11 x186 y85 w30 h30, >
;Gui, Add, Text, vCONText tl x46 y85 w130 h30, CurrentObjectNumber
;Gui, Add, Text, vHardnessText x6 y125 w170 h20, Hardness
;Gui, Add, Text, vResText x6 y155 w170 h20, Resistance
;Gui, Add, Text, vWidthText x6 y185 w170 h20, Width
;Gui, Add, Text, vLengthText x6 y215 w170 h20, Length
;Gui, Add, Text, vHeightText x6 y245 w170 h20, Height
;Gui, Add, Text, vTextureText x6 y275 w170 h20, Texture
;Gui, Add, Text, vWeightText x6 y305 w170 h20, Weight
;Gui, Add, Text, vDirectText x6 y335 w170 h20, Direction
;Gui, Add, Text, vShapeText x6 y365 w170 h20, Shape
;Gui, Add, Text, vSpeedText x6 y395 w170 h20, Speed
;Gui, Add, Edit, vHardnessEdit x186 y125 w30 h20, HardnessLevel
;Gui, Add, Edit, x186 y155 w30 h20, 1
;Gui, Add, Edit, x186 y185 w30 h20, 2
;Gui, Add, Edit, x186 y215 w30 h20, 3
;Gui, Add, Edit, x186 y245 w30 h20, 4
;Gui, Add, Edit, x186 y275 w30 h20, 5
;Gui, Add, Edit, x186 y305 w30 h20, 6
;Gui, Add, Edit, x186 y335 w30 h20, 7
;Gui, Add, Edit, x186 y365 w30 h20, 8
;Gui, Add, Edit, x186 y395 w30 h20, 9
Gui, Show, x-4 y-4 h461 w640,
Return

;########## SubRoutines ########
;-------------File Menu------------------
NewSession:
OpenExistingSession:
ImportDataFile:
ExitAppSub:
MonitorEngine:
AddNewObject:
UserPreferences:
EngineSettings:
EditObject:
Return
;---------------Gui Functions------------
HideToolBar:

Return

MoveToolBar:
GuiControlGet, TB_Pos_Index, Pos, TBC2
TB_PosX = %TB_Pos_IndexX%
TB_PosY = %TB_Pos_IndexY%
GoSub, GetToolBarControlsPos
GoSub, HideToolBarControls
GuiControl, Hide, TBC1
GuiControl, Hide, TBC3
GuiControl, Hide, TBC4
Loop
{
   
   MouseGetPos, MPosX, MPosY
   MposX -= 3
   MposY -= 40
   GuiControl, Move, TBC2, x%MPosX% y%MPosY%
   GetKeyState, LButtonState, LButton, P
   If LButtonState = D
      Break
}
GuiControlGet, TB_Pos_Index, Pos, TBC2
TB_XDiff := (TB_Pos_IndexX - TB_PosX)
TB_YDiff := (TB_Pos_IndexY - TB_PosY)
GoSub, MoveToolBarControls
GoSub, ShowToolBarControls
GuiControl, Show, TBC1
GuiControl, Show, TBC3
GuiControl, Show, TBC4
Return

MoveToolBarControls:
Ctrl1PosX += %TB_XDiff%
Ctrl2PosX += %TB_XDiff%
Ctrl3PosX += %TB_XDiff%
Ctrl4PosX += %TB_XDiff%
Ctrl5PosX += %TB_XDiff%
Ctrl6PosX += %TB_XDiff%
Ctrl7PosX += %TB_XDiff%
Ctrl8PosX += %TB_XDiff%
Ctrl9PosX += %TB_XDiff%
Ctrl10PosX += %TB_XDiff%
Ctrl11PosX += %TB_XDiff%

Ctrl1PosY += %TB_YDiff%
Ctrl2PosY += %TB_YDiff%
Ctrl3PosY += %TB_YDiff%
Ctrl4PosY += %TB_YDiff%
Ctrl5PosY += %TB_YDiff%
Ctrl6PosY += %TB_YDiff%
Ctrl7PosY += %TB_YDiff%
Ctrl8PosY += %TB_YDiff%
Ctrl9PosY += %TB_YDiff%
Ctrl10PosY += %TB_YDiff%
Ctrl11PosY += %TB_YDiff%

GuiControl, Move, TBC1, x%Ctrl1PosX% y%Ctrl1PosY%
GuiControl, Move, TBC2, x%Ctrl2PosX% y%Ctrl2PosY%
GuiControl, Move, TBC3, x%Ctrl3PosX% y%Ctrl3PosY%
GuiControl, Move, TBC4, x%Ctrl4PosX% y%Ctrl4PosY%
GuiControl, Move, TBC5, x%Ctrl5PosX% y%Ctrl5PosY%
GuiControl, Move, TBC6, x%Ctrl6PosX% y%Ctrl6PosY%
GuiControl, Move, TBC7, x%Ctrl7PosX% y%Ctrl7PosY%
GuiControl, Move, TBC8, x%Ctrl8PosX% y%Ctrl8PosY%
GuiControl, Move, TBC9, x%Ctrl9PosX% y%Ctrl9PosY%
GuiControl, Move, TBC10, x%Ctrl10PosX% y%Ctrl10PosY%
GuiControl, Move, TBC11, x%Ctrl11PosX% y%Ctrl11PosY%
Return

GetToolBarControlsPos:
GuiControlGet, Ctrl1Pos, Pos, TBC1
GuiControlGet, Ctrl2Pos, Pos, TBC2
GuiControlGet, Ctrl3Pos, Pos, TBC3
GuiControlGet, Ctrl4Pos, Pos, TBC4
GuiControlGet, Ctrl5Pos, Pos, TBC5
GuiControlGet, Ctrl6Pos, Pos, TBC6
GuiControlGet, Ctrl7Pos, Pos, TBC7
GuiControlGet, Ctrl8Pos, Pos, TBC8
GuiControlGet, Ctrl9Pos, Pos, TBC9
GuiControlGet, Ctrl10Pos, Pos, TBC10
GuiControlGet, Ctrl11Pos, Pos, TBC11
Return

HideToolBarControls:
;GuiControl, Hide, TBC1
;GuiControl, Hide, TBC2
;GuiControl, Hide, TBC3
;GuiControl, Hide, TBC4 
GuiControl, Hide, TBC5
GuiControl, Hide, TBC6
GuiControl, Hide, TBC7
GuiControl, Hide, TBC8
GuiControl, Hide, TBC9
GuiControl, Hide, TBC10
GuiControl, Hide, TBC11
Return

ShowToolBarControls:
;GuiControl, Show, TBC1
;GuiControl, Show, TBC2
;GuiControl, Show, TBC3
;GuiControl, Show, TBC4
GuiControl, Show, TBC5
GuiControl, Show, TBC6
GuiControl, Show, TBC7
GuiControl, Show, TBC8
GuiControl, Show, TBC9
GuiControl, Show, TBC10
GuiControl, Show, TBC11
Return

;#######################################
;########## HOT KEYS ###################
;#######################################

;#### Reload ####
F9::Reload
GuiClose:
ExitApp

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2005, 4:54 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
Very nice!

Could you also show the controls as they are moved, or at least an outline? Sometimes part of them get outside of the GUI window.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2005, 5:37 pm 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
yeah, I was thinking about making a group box as an out line, and I dont show the controls when moving becuase I would loop that function or set a timer and I know the effect that I would get, the button most controls would lag a little bit, so I found it best to just hide them.

_________________
my lame sig :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2005, 5:39 pm 
Offline

Joined: February 14th, 2005, 10:54 am
Posts: 447
Location: Texas, Usa
yeah, I was thinking about making a group box as an out line, and I dont show the controls when moving becuase I would loop that function or set a timer and I know the effect that I would get, the button most controls would lag a little bit, so I found it best to just hide them. Also, I do know that the button can be covered by the menu if you click and drag up there. Or the the very bottom or right of the window. It needs some tweak but I thought it was a nice start. And one thing that Peed me off was that I could find no way to start the event on the buttons down event otherwise it would be a drag and drop style but, I do what I can

_________________
my lame sig :)


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: sks and 14 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