Jump to content

Draggable input control


Recommended Posts

  • Replies 72
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

ok i've solved the problem with creating multiple icons from multiple base images but I am still having trouble adding functionality for new items I add to the context menu.

Can someone please help me. This is what I have done in an attempt to add functionality for the additional menu items I added but whenever I create more than one icon and try to right click and delete it, it gives me an error saying "array variable has incorrect number of subscripts or subscript dimension range exceeded." and says that while pointing to the ElseIf $msg[0] = $ahInput[$i][4] Then line. please offer a better way of adding functionality as mine obviously sucks

For $i = 1 To $ahInput[0][0]
        If $msg[0] = $ahInput[$i][3] Then
            msgbox(0, "", "")
            ExitLoop
        ElseIf $msg[0] = $ahInput[$i][4] Then
            MsgBox(0, "", "lion")
        ElseIf $msg[0] = $ahInput[$i][6] Then
            If $CheckRegister = False Then
                If $lastdragIP < 5 Then
                    $lastdragIP += 1
                    createNextdragIP($lastdragIP)
                EndIf
            Else
                If $lastdragIP < 5 Then
                    $lastdragIP += 1
                    createNextdragIP($lastdragIP)
                EndIf
            EndIf
        ElseIf $msg[0] = $ahInput[$i][7] Then
            function()
        EndIf
Next
...
Edited by IWantIt
Link to comment
Share on other sites

  • 2 weeks later...

@IWantIt

About the hiding of first (or any other) icon - just use the first element of the array:

GUISetState(@SW_HIDE, $ahInput[1][0])

About “adding functionality”... i am not sure if i understand you correctly, can you be more specific?

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Well what I mean is adding functionality for the menus that I have when I right click. For example, in a previous post by martin on page 3 there is a delete item that appears on the context menu when you right click on the item, and it has functionality for it to delete it.

But when I try to add more menu items I don't know how to add functionality for them to "do something" like the delete item.

Link to comment
Share on other sites

Ok, i understand now what you want to do...

Well, you will have to add an items but also increase the elements in the second dimention, for example if you want to add an item to delete all the icons, then you do it like this (follow the commented lines, i wrote all the changes):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $ahInput[2][5] ;Cganged 4 to 5

$GUI = GUICreate("Dragable Controls", 300, 300)

$Create_DIP_Button = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 32, 58, 26, 26)

GUISetState()

While 1
    $nMsg = GUIGetMsg(1)
    
    Switch $nMsg[0]
        Case $GUI_Event_Close
            Exit
        Case $Create_DIP_Button
            CreateDragIP()
        Case $ahInput[1][1] To $ahInput[$ahInput[0][0]][1] ;$GUI_EVENT_PRIMARYDOWN
            If $nMsg[0] = 0 Then ContinueLoop
            
            Local $aMouse_Pos = MouseGetPos()
            Local $aCursorInfo = GUIGetCursorInfo($nMsg[1]), $aCurrent_Mouse_Pos, $aInputGUI_Pos
            
            $aInputGUI_Pos = WinGetPos($nMsg[1])
            If Not IsArray($aInputGUI_Pos) Then ContinueLoop
            
            While IsArray($aCursorInfo) And $aCursorInfo[2] = 1
                $aCursorInfo = GUIGetCursorInfo($nMsg[1])
                $aCurrent_Mouse_Pos = MouseGetPos()
                
                WinMove($nMsg[1], "", _
                    $aInputGUI_Pos[0] - $aMouse_Pos[0] + $aCurrent_Mouse_Pos[0], _
                    $aInputGUI_Pos[1] - $aMouse_Pos[1] + $aCurrent_Mouse_Pos[1])
                
                Sleep(10)
            WEnd
    EndSwitch
    
    ;Changed the all loop (to work more effective with more than one message)
    For $i = 1 To $ahInput[0][0]
        Switch $nMsg[0]
            Case $ahInput[$i][3] ;This is the "Delete" item message
                DeleteDragIP($nMsg[0])
                ExitLoop
            Case $ahInput[$i][4] ;This is the "Delete All" item message
                DeleteAllDragIP()
                ExitLoop
        EndSwitch
    Next
WEnd

Func CreateDragIP()
    Local $aMainGUI_Pos = WinGetPos($GUI)
    
    $ahInput[0][0] += 1
    ReDim $ahInput[$ahInput[0][0]+1][5] ;4 changed to 5
    
    $ahInput[$ahInput[0][0]][0] = GUICreate("", 26, 26, $aMainGUI_Pos[0] + 65, $aMainGUI_Pos[1] + 60 + 25, _
        $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED))
    
    $ahInput[$ahInput[0][0]][1] = GUICtrlCreatePic(@SystemDir & "\oobe\images\merlin.gif", 0, 0, 26, 26, -1)
    
    $ahInput[$ahInput[0][0]][2] = GUICtrlCreateContextMenu($ahInput[$ahInput[0][0]][1])
    $ahInput[$ahInput[0][0]][3] = GUICtrlCreateMenuItem("&Delete", $ahInput[$ahInput[0][0]][2])
    $ahInput[$ahInput[0][0]][4] = GUICtrlCreateMenuItem("&Delete All", $ahInput[$ahInput[0][0]][2]) ;Added
    
    GUISetState(@SW_SHOW, $ahInput[$ahInput[0][0]][0])
    
    WinSetOnTop($ahInput[$ahInput[0][0]][0], "", 1)
EndFunc

Func DeleteDragIP($iCtrlID)
    Local $aTmpArr[2][5] ;Changed 4 to 5
    
    For $i = 1 To $ahInput[0][0]
        If $ahInput[$i][3] = $iCtrlID Then
            GUIDelete($ahInput[$i][0])
        Else
            $aTmpArr[0][0] += 1
            ReDim $aTmpArr[$aTmpArr[0][0]+1][5] ;Changed 4 to 5
            
            $aTmpArr[$aTmpArr[0][0]][0] = $ahInput[$i][0]
            $aTmpArr[$aTmpArr[0][0]][1] = $ahInput[$i][1]
            $aTmpArr[$aTmpArr[0][0]][2] = $ahInput[$i][2]
            $aTmpArr[$aTmpArr[0][0]][3] = $ahInput[$i][3]
            $aTmpArr[$aTmpArr[0][0]][4] = $ahInput[$i][4] ;This line was added
        EndIf
    Next
    
    $ahInput = $aTmpArr
EndFunc

;Added new function
Func DeleteAllDragIP()
    For $i = 1 To $ahInput[0][0]
        GUIDelete($ahInput[$i][0])
    Next
    
    $ahInput = 0
    Dim $ahInput[2][5]
EndFunc

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...