Sign in to follow this  
Followers 0
goldenix

[Solved]_GUIRegisterMsg V.S. GUISetOnEvent

5 posts in this topic

#1 ·  Posted (edited)

The gui is one Big Listview(height=100%,width=100%). Look at the fitrst lines, after the GUI is created

My goal is to be able to drag the gui & if I click on a an item winactivate it. The functions work separately only, if I use both I cant Drag the GUI anymore.

Run the code first & try to drag it. as you see its not happening. Now comment out & try again:

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")     ; Listview events

It works. but i cant use Listview functions now. Is there a way to use those both at the same time?

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

Opt("GUIOnEventMode",1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 161, 260, 193, 125,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;~ --------------------
;~ Create listview 
    $hListView = _GUICtrlListView_Create ($Form1, "", 0, 0, 160, 357) ; LEFT],[TOP],WIDTH],[HEIGHT]
                 _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_AUTOARRANGE,$LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER))
                 _GUICtrlListView_InsertColumn($hListView, 0, "Winlist:", 160)
;~ --------------------
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; events
;~ --------------------
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")             ; Listview events
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")     ; Exitfunc
GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "_Drag" )    ;Drag GUI func
;~ --------------------

;~ ========================================================
;~ To be able to drag GUI
;~ ========================================================
Func _Drag()
    dllcall("user32.dll","int","SendMessage","hWnd", $Form1,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

;~ ========================================================
;~ This thing is responcible for click events
;~ ========================================================
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode       
                
;~              GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" )     ;Drag GUI func                      
                
                Case $NM_CLICK  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                   Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
;~                 ConsoleWrite('Index: ' & DllStructGetData($tInfo, "Index") & ' Subitem: ' & DllStructGetData($tInfo, "SubItem") & @CRLF) 
                   $Index = DllStructGetData($tInfo, "Index")
                   
                        $mail = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index),'|')
                        $mail = $mail[1]
                    
                    WinActivate($mail)
                    
;~                  ConsoleWrite($mail & @CRLF)
                    
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


;~ ========================================================
;~ Exit
;~ ========================================================
Func CLOSEClicked()
  Exit
EndFunc

;~ Get Winlist & fill listview
;~ --------------------
$var = WinList()
For $i = 1 to $var[0][0]
    $text = WinGetClassList($var[$i][0], "")
    If StringInStr($text,'ToolbarWindow32') And StringInStr($text,'SHELLDLL_DefView') Then 
        _GUICtrlListView_AddItem ($hListView, $var[$i][0])    ; Add Empty Roe
    EndIf
Next
;~ --------------------

While 1
    Sleep(100)
WEnd
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites



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

;~ Opt("GUIOnEventMode",1)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 161, 260, 193, 125,BitOR($WS_POPUP,$WS_BORDER),BitOr($WS_EX_TOPMOST,$WS_EX_TOOLWINDOW))
;~ --------------------
;~ Create listview 
    $hListView = _GUICtrlListView_Create ($Form1, "", 0, 0, 160, 357) ; LEFT],[TOP],WIDTH],[HEIGHT]
                 _GUICtrlListView_SetExtendedListViewStyle ($hListView, BitOR($LVS_AUTOARRANGE,$LVS_EX_FULLROWSELECT,$LVS_EX_DOUBLEBUFFER))
                 _GUICtrlListView_InsertColumn($hListView, 0, "Winlist:", 160)
;~ --------------------
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; events
;~ --------------------
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")    ; Listview events
;~ GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")  ; Exitfunc
;~ GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "_Drag" )    ;Drag GUI func
;~ --------------------

;~ ========================================================
;~ To be able to drag GUI
;~ ========================================================
Func _Drag()
    dllcall("user32.dll","int","SendMessage","hWnd", $Form1,"int",$WM_NCLBUTTONDOWN,"int", $HTCAPTION,"int", 0)
EndFunc

;~ ========================================================
;~ This thing is responcible for click events
;~ ========================================================
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    
    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode      
                
;~     GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, "Drag" )    ;Drag GUI func                        
                
                Case $NM_CLICK  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                   Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
;~        ConsoleWrite('Index: ' & DllStructGetData($tInfo, "Index") & ' Subitem: ' & DllStructGetData($tInfo, "SubItem") & @CRLF)  
                   $Index = DllStructGetData($tInfo, "Index")
                   
                        $mail = StringSplit(_GUICtrlListView_GetItemTextString($hListView, $Index),'|')
                        $mail = $mail[1]
                    
                    WinActivate($mail)
                    
;~      ConsoleWrite($mail & @CRLF)
                    
                _Drag()

            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


;~ ========================================================
;~ Exit
;~ ========================================================
Func CLOSEClicked()
  Exit
EndFunc

;~ Get Winlist & fill listview
;~ --------------------
$var = WinList()
For $i = 1 to $var[0][0]
    $text = WinGetClassList($var[$i][0], "")
    If StringInStr($text,'ToolbarWindow32') And StringInStr($text,'SHELLDLL_DefView') Then 
        _GUICtrlListView_AddItem ($hListView, $var[$i][0])    ; Add Empty Roe
    EndIf
Next
;~ --------------------

;~ While 1
;~     Sleep(100)
;~ WEnd
While 1
 $msg = GuiGetMsg()
 Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
 EndSelect
WEnd

Share this post


Link to post
Share on other sites
...oÝ÷ Ûú®¢×+"²z ¢b¶V °±ìiz¸¦z{b¦¥Æ¦zêpØm+,yæÞ,y鬶ÞÂäx'ǥɫ­¢+Ø
ÍÀÌØí95}
1%
,ìM¹Ðä±¥Íе٥ܽ¹Ñɽ°Ý¡¸Ñ¡ÕÍȽձµ±¥­Ì¸¥Ñ´Ý¥Ñ Ñ¡±Ðµ½ÕÍÕÑѽ¸($%1½°ÀÌØíÑ%¹¼ô±±MÑÉÕÑ
ÉÑ ÀÌØíÑ95%Q5
Q%YQ°ÀÌØí¥±AÉ´¤($$ÀÌØí%¹àô±±MÑÉÕÑÑÑ ÀÌØíÑ%¹¼°ÅÕ½Ðí%¹àÅÕ½Ðì¤($$(íø$$%ݱ¥¬Í½µÝ¡É̥ͥѴ¼Ñ¡10±°($$%ÀÌØí%¹à±ÐìÐì´ÄQ¡¸$$$$($$$$ÀÌØíµ¥°ôMÑÉ¥¹MÁ±¥Ð¡}U%
Ñɱ1¥ÍÑY¥Ý}Ñ%ѵQáÑMÑÉ¥¹ ÀÌØí¡1¥ÍÑY¥Ü°ÀÌØí%¹à¤°ÌäíðÌäì¤($$$$ÀÌØíµ¥°ôÀÌØíµ¥±lÅt$$$$$$($$$%]¥¹Ñ¥ÙÑ ÀÌØíµ¥°¤$$$$($$%±Í($$$%±±±° ÅÕ½ÐíÕÍÈÌȹ±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½ÐíM¹5ÍÍÅÕ½Ðì°ÅÕ½Ðí¡]¹ÅÕ½Ðì°ÀÌØí½É´Ä°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí]5}9
1   UQQ=9=]8°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÀÌØí!Q
AQ%=8°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°À¤($$%¹%

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

working great, thanks! :)


Sorry 4 Bad English, I'm Indonesian...I'm really need 'Translator' for helping me posting in this forum (http://deeriee.wordpress.com)

Share this post


Link to post
Share on other sites

goldenix

My solution:

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

Opt("GUIOnEventMode", 1)

Global $hDLL = DllOpen("User32.dll")

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 161, 260, 193, 125, BitOR($WS_POPUP, $WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
;~ --------------------
;~ Create listview
$hListView = _GUICtrlListView_Create($Form1, "", 0, 0, 160, 357) ; LEFT],[TOP],WIDTH],[HEIGHT]
_GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_AUTOARRANGE, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER))
_GUICtrlListView_InsertColumn($hListView, 0, "Winlist:", 160)
;~ --------------------
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

; events
;~ --------------------
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")    ; Listview events
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") ; Exitfunc
;~ --------------------

;~ ========================================================
;~ To be able to drag GUI
;~ ========================================================
Func _Drag()
    DllCall("user32.dll", "int", "SendMessage", "hWnd", $Form1, "int", $WM_NCLBUTTONDOWN, "int", $HTCAPTION, "int", 0)
EndFunc   ;==>_Drag

;~ ========================================================
;~ This thing is responcible for click events
;~ ========================================================
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $hListView
    If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
    
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_HOTTRACK
                    If _IsPressed("01", $hDLL) Then _Drag()
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


;~ ========================================================
;~ Exit
;~ ========================================================
Func CLOSEClicked()
    DllClose($hDLL)
    Exit
EndFunc   ;==>CLOSEClicked

;~ Get Winlist & fill listview
;~ --------------------
$var = WinList()
For $i = 1 To $var[0][0]
    $text = WinGetClassList($var[$i][0], "")
    If StringInStr($text, 'ToolbarWindow32') And StringInStr($text, 'SHELLDLL_DefView') Then
        _GUICtrlListView_AddItem($hListView, $var[$i][0]) ; Add Empty Roe
    EndIf
Next
;~ --------------------

While 1
    Sleep(100)
WEnd

:)

Share this post


Link to post
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
Sign in to follow this  
Followers 0