Jump to content

open paint if paint is dubble-clicked on a listview


ashley
 Share

Recommended Posts

All you had to do was search.

#include <GuiConstants.au3>

Global Const $WM_NOTIFY = 0x004E
Global $DoubleClicked   = False

GUICreate("Double Click Demo", 400, 300)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")


$ListViewID = GuiCtrlCreateListView("List Column", 10, 20, 380, 250)

For $i = 1 To 10
    GuiCtrlCreateListViewItem("Item " & $i, $ListViewID)
Next

GUISetState()

While GUIGetMsg() <> -3
    Sleep(10)
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK", "Double Clicked: " & GUICtrlRead(GUICtrlRead($ListViewID)))
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $ListViewID And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

http://www.autoitscript.com/forum/index.ph...iew+doubleclick

Link to comment
Share on other sites

All you had to do was search.

#include <GuiConstants.au3>

Global Const $WM_NOTIFY = 0x004E
Global $DoubleClicked   = False

GUICreate("Double Click Demo", 400, 300)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$ListViewID = GuiCtrlCreateListView("List Column", 10, 20, 380, 250)

For $i = 1 To 10
    GuiCtrlCreateListViewItem("Item " & $i, $ListViewID)
Next

GUISetState()

While GUIGetMsg() <> -3
    Sleep(10)
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd

Func DoubleClickFunc()
    MsgBox(64, "OK", "Double Clicked: " & GUICtrlRead(GUICtrlRead($ListViewID)))
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $ListViewID And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

http://www.autoitscript.com/forum/index.ph...iew+doubleclick

that dont work with the shell im making
Link to comment
Share on other sites

#include <GUIConstants.au3>
Global $List1, $Close, $Open, $Start, $Form1, $startmenu
Global $DoubleClicked   = False
Global Const $WM_NOTIFY = 0x004E
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OS shell", 633, 430, 193, 115)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetBkColor(0x808080)
$Start = GUICtrlCreateButton("Start", 3, 409, 75, 17, 0)
$Open = GUICtrlCreateButton("Open", 3, 409, 75, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$startmenu = GUICtrlCreateListView("Applications   ", 8, 305, 85, 97,$LVS_NOSORTHEADER)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateListViewItem("Notepad",$startmenu )
GUICtrlCreateListViewItem("Paint",$startmenu )

$Close = GUICtrlCreateButton("X", 83, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$date = GUICtrlCreateMonthCal("2007/10/14", 432, 246, 191, 161)
GUICtrlSetState(-1, $GUI_HIDE)
$Closedate = GUICtrlCreateButton("X", 504, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Time = GUICtrlCreateButton(@Hour & ":" & @Min, 544, 409, 75, 17, 0)

GUISetState()
#EndRegion ### END Koda GUI section ###

AdlibEnable("refresh_time",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            Startmenu()
        Case $Close
            CloseStartmenu()
        Case $Open
        Case $Time
            GUICtrlSetState($date, $GUI_SHOW)
            GUICtrlSetState($Closedate, $GUI_SHOW)
        Case $Closedate
            GUICtrlSetState($date, $GUI_HIDE)
            GUICtrlSetState($Closedate, $GUI_HIDE)
        EndSwitch
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd
Func Startmenu()
GUIctrlSetState($Start,$GUI_HIDE)
GUICtrlSetState($Open, $GUI_SHOW)
GUICtrlSetState($Startmenu, $GUI_SHOW)
GUICtrlSetState($Close, $GUI_SHOW)
EndFunc
Func CloseStartmenu()
GUICtrlSetState($Open, $GUI_HIDE)
GUICtrlSetState($Startmenu, $GUI_HIDE)
GUICtrlSetState($Close, $GUI_HIDE)
GUIctrlSetState($Start,$GUI_SHOW)
EndFunc

Func refresh_time()
    GUICtrlSetData($Time,@Hour & ":" & @Min)
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $startmenu And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

Func DoubleClickFunc()
   $App=GUICtrlRead(GUICtrlRead($Startmenu))
   Switch $App
       Case "Notepad"
           Run("notepad")
       Case "Paint"
            Run("mspaint")
    EndSwitch
EndFunc

Link to comment
Share on other sites

#include <GUIConstants.au3>
Global $List1, $Close, $Open, $Start, $Form1, $startmenu
Global $DoubleClicked   = False
Global Const $WM_NOTIFY = 0x004E
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OS shell", 633, 430, 193, 115)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetBkColor(0x808080)
$Start = GUICtrlCreateButton("Start", 3, 409, 75, 17, 0)
$Open = GUICtrlCreateButton("Open", 3, 409, 75, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$startmenu = GUICtrlCreateListView("Applications   ", 8, 305, 85, 97,$LVS_NOSORTHEADER)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateListViewItem("Notepad",$startmenu )
GUICtrlCreateListViewItem("Paint",$startmenu )

$Close = GUICtrlCreateButton("X", 83, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$date = GUICtrlCreateMonthCal("2007/10/14", 432, 246, 191, 161)
GUICtrlSetState(-1, $GUI_HIDE)
$Closedate = GUICtrlCreateButton("X", 504, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Time = GUICtrlCreateButton(@Hour & ":" & @Min, 544, 409, 75, 17, 0)

GUISetState()
#EndRegion ### END Koda GUI section ###

AdlibEnable("refresh_time",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            Startmenu()
        Case $Close
            CloseStartmenu()
        Case $Open
        Case $Time
            GUICtrlSetState($date, $GUI_SHOW)
            GUICtrlSetState($Closedate, $GUI_SHOW)
        Case $Closedate
            GUICtrlSetState($date, $GUI_HIDE)
            GUICtrlSetState($Closedate, $GUI_HIDE)
        EndSwitch
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd
Func Startmenu()
GUIctrlSetState($Start,$GUI_HIDE)
GUICtrlSetState($Open, $GUI_SHOW)
GUICtrlSetState($Startmenu, $GUI_SHOW)
GUICtrlSetState($Close, $GUI_SHOW)
EndFunc
Func CloseStartmenu()
GUICtrlSetState($Open, $GUI_HIDE)
GUICtrlSetState($Startmenu, $GUI_HIDE)
GUICtrlSetState($Close, $GUI_HIDE)
GUIctrlSetState($Start,$GUI_SHOW)
EndFunc

Func refresh_time()
    GUICtrlSetData($Time,@Hour & ":" & @Min)
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $startmenu And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

Func DoubleClickFunc()
   $App=GUICtrlRead(GUICtrlRead($Startmenu))
   Switch $App
       Case "Notepad"
           Run("notepad")
       Case "Paint"
            Run("mspaint")
    EndSwitch
EndFunc
tyvm but i found a way around it
Link to comment
Share on other sites

how could i ahve icon in the list view and how could i have icon buttons not in listview(somewere in the gui)

What for? So when I give you a solution you go "tyvm but i found a way around it"

#include <GUIConstants.au3>
Global $List1, $Close, $Open, $Start, $Form1, $startmenu
Global $DoubleClicked   = False
Global Const $WM_NOTIFY = 0x004E
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OS shell", 633, 430, 193, 115)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetBkColor(0x808080)
$Start = GUICtrlCreateButton("Start", 3, 380, 50,50, $BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",-16)
$Open = GUICtrlCreateButton("Open", 3, 409, 75, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$startmenu = GUICtrlCreateListView("Applications   ", 8, 305, 85, 97,$LVS_NOSORTHEADER)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateListViewItem("Notepad",$startmenu )
GUICtrlSetImage (-1, "shell32.dll",-56)
GUICtrlCreateListViewItem("Paint",$startmenu )
GUICtrlSetImage (-1, "shell32.dll",-42)
$Close = GUICtrlCreateButton("X", 83, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$date = GUICtrlCreateMonthCal("2007/10/14", 432, 246, 191, 161)
GUICtrlSetState(-1, $GUI_HIDE)
$Closedate = GUICtrlCreateButton("X", 504, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Time = GUICtrlCreateButton(@Hour & ":" & @Min, 544, 409, 75, 17, 0)

GUISetState()
#EndRegion ### END Koda GUI section ###

AdlibEnable("refresh_time",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            Startmenu()
        Case $Close
            CloseStartmenu()
        Case $Open
        Case $Time
            GUICtrlSetState($date, $GUI_SHOW)
            GUICtrlSetState($Closedate, $GUI_SHOW)
        Case $Closedate
            GUICtrlSetState($date, $GUI_HIDE)
            GUICtrlSetState($Closedate, $GUI_HIDE)
        EndSwitch
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd
Func Startmenu()
GUIctrlSetState($Start,$GUI_HIDE)
GUICtrlSetState($Open, $GUI_SHOW)
GUICtrlSetState($Startmenu, $GUI_SHOW)
GUICtrlSetState($Close, $GUI_SHOW)
EndFunc
Func CloseStartmenu()
GUICtrlSetState($Open, $GUI_HIDE)
GUICtrlSetState($Startmenu, $GUI_HIDE)
GUICtrlSetState($Close, $GUI_HIDE)
GUIctrlSetState($Start,$GUI_SHOW)
EndFunc

Func refresh_time()
    GUICtrlSetData($Time,@Hour & ":" & @Min)
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $startmenu And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

Func DoubleClickFunc()
   $App=GUICtrlRead(GUICtrlRead($Startmenu))
   Switch $App
       Case "Notepad"
           Run("notepad")
       Case "Paint"
            Run("mspaint")
    EndSwitch
EndFunc
Link to comment
Share on other sites

What for? So when I give you a solution you go "tyvm but i found a way around it"

#include <GUIConstants.au3>
Global $List1, $Close, $Open, $Start, $Form1, $startmenu
Global $DoubleClicked   = False
Global Const $WM_NOTIFY = 0x004E
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("OS shell", 633, 430, 193, 115)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetBkColor(0x808080)
$Start = GUICtrlCreateButton("Start", 3, 380, 50,50, $BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",-16)
$Open = GUICtrlCreateButton("Open", 3, 409, 75, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$startmenu = GUICtrlCreateListView("Applications   ", 8, 305, 85, 97,$LVS_NOSORTHEADER)
GUICtrlSetState(-1, $GUI_HIDE)
GUICtrlCreateListViewItem("Notepad",$startmenu )
GUICtrlSetImage (-1, "shell32.dll",-56)
GUICtrlCreateListViewItem("Paint",$startmenu )
GUICtrlSetImage (-1, "shell32.dll",-42)
$Close = GUICtrlCreateButton("X", 83, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$date = GUICtrlCreateMonthCal("2007/10/14", 432, 246, 191, 161)
GUICtrlSetState(-1, $GUI_HIDE)
$Closedate = GUICtrlCreateButton("X", 504, 409, 35, 17, 0)
GUICtrlSetState(-1, $GUI_HIDE)
$Time = GUICtrlCreateButton(@Hour & ":" & @Min, 544, 409, 75, 17, 0)

GUISetState()
#EndRegion ### END Koda GUI section ###

AdlibEnable("refresh_time",2000)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Start
            Startmenu()
        Case $Close
            CloseStartmenu()
        Case $Open
        Case $Time
            GUICtrlSetState($date, $GUI_SHOW)
            GUICtrlSetState($Closedate, $GUI_SHOW)
        Case $Closedate
            GUICtrlSetState($date, $GUI_HIDE)
            GUICtrlSetState($Closedate, $GUI_HIDE)
        EndSwitch
    If $DoubleClicked Then
        DoubleClickFunc()
        $DoubleClicked = False
    EndIf
WEnd
Func Startmenu()
GUIctrlSetState($Start,$GUI_HIDE)
GUICtrlSetState($Open, $GUI_SHOW)
GUICtrlSetState($Startmenu, $GUI_SHOW)
GUICtrlSetState($Close, $GUI_SHOW)
EndFunc
Func CloseStartmenu()
GUICtrlSetState($Open, $GUI_HIDE)
GUICtrlSetState($Startmenu, $GUI_HIDE)
GUICtrlSetState($Close, $GUI_HIDE)
GUIctrlSetState($Start,$GUI_SHOW)
EndFunc

Func refresh_time()
    GUICtrlSetData($Time,@Hour & ":" & @Min)
EndFunc

Func WM_NOTIFY($hWnd, $MsgID, $wParam, $lParam)
    Local $tagNMHDR, $event, $hwndFrom, $code
    $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return 0
    $code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $startmenu And $code = -3 Then $DoubleClicked = True
    Return $GUI_RUNDEFMSG
EndFunc

Func DoubleClickFunc()
   $App=GUICtrlRead(GUICtrlRead($Startmenu))
   Switch $App
       Case "Notepad"
           Run("notepad")
       Case "Paint"
            Run("mspaint")
    EndSwitch
EndFunc
TYVM just what i needed
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...