Verssuss

how un-registerMsg GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN"

10 posts in this topic

#1 ·  Posted

i added to my script 3 function what i needed for move and resize gui empty inside and it work perfect but it working for whole code

GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")            ; For cursor type change
GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")     ; For resize/drag
GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO")


i want to unregister it to make it working like before i call it

 

Func _SetCursor()
     Local $iCursorID
     Switch _Check_Border()
         Case 0
             $iCursorID = 2
         Case 1, 2
             $iCursorID = 13
         Case 3, 6
             $iCursorID = 11
         Case 5, 7
             $iCursorID = 10
         Case 4, 8
             $iCursorID = 12
     EndSwitch
     GUISetCursor($iCursorID, 1)
 EndFunc ;==>SetCursor

 ; Check cursor type and resize/drag window as required
 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
     Local $iCursorType = _Check_Border()
     If $iCursorType > 0 Then ; Cursor is set to resizing style so send appropriate resize message
         $iResizeType = 0xF000 + $iCursorType
         _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0)
     Else
         Local $aCurInfo = GUIGetCursorInfo($hGUI)
         If $aCurInfo[4] = 0 Then ; Mouse not over a control
             _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
         EndIf
     EndIf
 EndFunc ;==>WM_LBUTTONDOWN

 ; Determines if mouse cursor over a border
 Func _Check_Border()
     Local $aCurInfo = GUIGetCursorInfo($hGui)
     If @error Then Return -1
     Local $aWinPos = WinGetPos($hGUI)
     Local $iSide = 0
     Local $iTopBot = 0
     If $aCurInfo[0] < $iMargin Then $iSide = 1
     If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2
     If $aCurInfo[1] < $iMargin Then $iTopBot = 3
     If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6
     Return $iSide + $iTopBot
 EndFunc ;==>_Check_Border

  Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
     $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
     DllStructSetData($tMinMaxInfo,  7, $iGUIMinX)
     DllStructSetData($tMinMaxInfo,  8, $iGUIMinY)
     DllStructSetData($tMinMaxInfo,  9, $iGUIMaxX)
     DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY)
     Return 0
  EndFunc   ;==>_WM_GETMINMAXINFO

plz help 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use an empty string to replace the function names.

GUIRegisterMsg($WM_MOUSEMOVE, "")

 

Edited by czardas

Share this post


Link to post
Share on other sites

#3 ·  Posted

this was first what i did. not working well...

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Post a reproducer (code) that demonstrates the problem you are experiencing.

Edited by czardas

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

need Melba23’s GUIListViewEx UDF

here is code

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <SendMessage.au3>

HotKeySet("{ESC}", "_quit")

$GUI = GUICreate("Clicker", 500, 300,200,200)
$ListView = GUICtrlCreateListView("Name1|Name2|Name3|Name4|Name5|Name6", 10, 20, 400, 200, $LVS_SHOWSELALWAYS)
$button_set_box = GUICtrlCreateButton("Set Area", 430, 190, 60, 25)
$button_get_box = GUICtrlCreateButton("GET Area", 430, 220, 60, 25)
$button_exit = GUICtrlCreateButton("Exit", 330, 450, 33, 30)
GUISetState()

Global Const $iMargin = 4
Global Const $iGUIMinX = 20, $iGUIMinY = 20, $iGUIMaxX = @DesktopWidth, $iGUIMaxY = @DesktopHeight
Global Const $SC_DRAGMOVE = 0xF012

Global $iCount, $vData, $iEditMode = 0,$hGui,$box
Global $aLV_List[$iCount] ; Create array and fill Left listview
$aLV_List_Left = _GUIListViewEx_ReadToArray($ListView, 1) ; Note count element
; Initiate LVEx - use filling array - no count parameter - default insert mark colour (black) - drag image - sortable + not select all text + editable headers
$iLV_Index = _GUIListViewEx_Init($ListView, $aLV_List_Left, 0, 0, True, 1 + 2 + 8)
_GUIListViewEx_SetEditStatus($iLV_Index, "0;2;3;4;5") ; Column 0 & 2 editable - simple text not selected on open
_GUIListViewEx_MsgRegister() ; Register for sorting, dragging and editing
_GUIListViewEx_EventMonitor($iEditMode) ; Create editable listview

Global $vData[6] = ["1a",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)
Global $vData[6] = ["1b",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)
Global $vData[6] = ["1c",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)
Global $vData[6] = ["1d",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)
Global $vData[6] = ["1e",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)
Global $vData[6] = ["1f",  "2", "3", "4", "5", "6"]
_GUIListViewEx_Insert($vData)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $button_exit
            Exit
        Case $button_set_box
            _set_box()
        Case $button_get_box
            _get_box()
    EndSwitch
    $vRet = _GUIListViewEx_EventMonitor($iEditMode)
WEnd

Func _set_box(); HOTKEY W
    GUIRegisterMsg($WM_MOUSEMOVE, "_SetCursor")             ;////////////////////////// i put it here
    GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN")      ;////////////////////////// and it work
    GUIRegisterMsg($WM_GETMINMAXINFO, "_WM_GETMINMAXINFO")  ;//////////////////////////
    $box = $box + 1
    If $box = 1 Then

        $hGUI = GUICreate("Y", 120, 120, -1, -1, $WS_POPUP, BitOr($WS_EX_LAYERED, $WS_EX_COMPOSITED, $WS_EX_TOPMOST),$GUI)
        GUISetBkColor(0x00FF00)
        GuiCtrlCreateLabel("", 10, 10, 100, 100)
        GUICtrlSetBkColor(-1, 0xABCDEF)
        GUICtrlSetResizing(-1, $GUI_DOCKBORDERS)
        GUISetState()
        _WinAPI_SetLayeredWindowAttributes($hGui, 0xABCDEF)
    EndIf

EndFunc

Func _get_box() ; HOTKEY ESC
    $box = 0
    GUIDelete($hGui)
EndFunc ; Cancel BOX

Func _SetCursor()
     Local $iCursorID
     Switch _Check_Border()
         Case 0
             $iCursorID = 2
         Case 1, 2
             $iCursorID = 13
         Case 3, 6
             $iCursorID = 11
         Case 5, 7
             $iCursorID = 10
         Case 4, 8
             $iCursorID = 12
     EndSwitch
     GUISetCursor($iCursorID, 1)
 EndFunc ;==>SetCursor

 ; Check cursor type and resize/drag window as required
 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam)
     Local $iCursorType = _Check_Border()
     If $iCursorType > 0 Then ; Cursor is set to resizing style so send appropriate resize message
         $iResizeType = 0xF000 + $iCursorType
         _SendMessage($hGUI, $WM_SYSCOMMAND, $iResizeType, 0)
     Else
         Local $aCurInfo = GUIGetCursorInfo($hGUI)
         If $aCurInfo[4] = 0 Then ; Mouse not over a control
             _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
         EndIf
     EndIf
 EndFunc ;==>WM_LBUTTONDOWN

 ; Determines if mouse cursor over a border
 Func _Check_Border()
     Local $aCurInfo = GUIGetCursorInfo($hGui)
     If @error Then Return -1
     Local $aWinPos = WinGetPos($hGUI)
     Local $iSide = 0
     Local $iTopBot = 0
     If $aCurInfo[0] < $iMargin Then $iSide = 1
     If $aCurInfo[0] > $aWinPos[2] - $iMargin Then $iSide = 2
     If $aCurInfo[1] < $iMargin Then $iTopBot = 3
     If $aCurInfo[1] > $aWinPos[3] - $iMargin Then $iTopBot = 6
     Return $iSide + $iTopBot
 EndFunc ;==>_Check_Border

  Func _WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam)
     $tMinMaxInfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam)
     DllStructSetData($tMinMaxInfo,  7, $iGUIMinX)
     DllStructSetData($tMinMaxInfo,  8, $iGUIMinY)
     DllStructSetData($tMinMaxInfo,  9, $iGUIMaxX)
     DllStructSetData($tMinMaxInfo, 10, $iGUIMaxY)
     Return 0
  EndFunc   ;==>_WM_GETMINMAXINFO

Func _quit()
    GUIRegisterMsg($WM_MOUSEMOVE, "")            ; For cursor type change
    GUIRegisterMsg($WM_LBUTTONDOWN, "")     ; For resize/drag
    GUIRegisterMsg($WM_GETMINMAXINFO, "")

;~  Exit
EndFunc   ;==>_quit

i have list with multi moveable items

after u use box move items work wrong

at bottom of script its (unregister) dont work...

Edited by Verssuss

Share this post


Link to post
Share on other sites

#6 ·  Posted

I can't test it right now sorry. I imagine someone will take a look soon. Thanks for posting the code.

Share this post


Link to post
Share on other sites

#7 ·  Posted

Verssuss,

I recognise a lot of that code!

Looking at the code you posted, I am pretty sure that your problem comes because you can only register a single function to a Windows message. When you register $WM_MOUSEMOVE as you enter the _set_box function, you therefore replace the GUIListViewEx handler with your own - and as you never reset it, the UDF fails to work from then on.

I suggest that you add another _GUIListViewEx_MsgRegister call as you leave the _get_box function - that way the UDF handlers are re-registered and the UDF can use them to function correctly. When I test it the ListView is still editable after having created and deleted the popup.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#8 ·  Posted

well problem fixed by change _quit() function

THX M23 for suggestion

Func _quit()
_GUIListViewEx_MsgRegister() ; Register for sorting, dragging and editing
EndFunc   ;==>_quit

Share this post


Link to post
Share on other sites

#9 ·  Posted

      0 Verssuss,

I said to add that line in the  _get_box function, not _quit.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#10 ·  Posted

thx i did that. this was just to show it wokrs fine

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