Jump to content

StatusBar doubleclick - demo


Zedna
 Share

Recommended Posts

Here is demo example for catching/processing doubleclick NOTIFY message on StatusBar control

also with distinguishing on which part of statusbar was clicked

; http://msdn.microsoft.com/en-us/library/windows/desktop/bb760734%28v=VS.85%29.aspx
 
#include <GUIConstantsEX.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>
 
Global $hGUI = GUICreate("Statusbar doubleclick demo", 400, 300)
$sb_dblclk_id = GUICtrlCreateDummy() ; statusbar doubleclick ID
$label = GUICtrlCreateLabel('abc', 10,10,100)
 
Global $hStatus = _GUICtrlStatusBar_Create($hGUI)
Global $aParts[3] = [125, 250]
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "Text1", 0)
_GUICtrlStatusBar_SetText($hStatus, "Text2", 1)
_GUICtrlStatusBar_SetText($hStatus, "Text3", 2)
 
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
 
While 1
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $sb_dblclk_id
            OnStatusBarDoubleClick(GUICtrlRead($sb_dblclk_id))
    EndSwitch
WEnd
 
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
 
    If $hWndGUI = $hGUI Then
 
        $NMHDR = DllStructCreate($tagNMHDR , $lParam)
        $hWndFrom = DllStructGetData($NMHDR, 'hWndFrom')
        $event = DllStructGetData($NMHDR, 'Code')
 
        If $event = $NM_DBLCLK And $hWndFrom = $hStatus Then
            $NMMOUSE = DllStructCreate($tagNMMOUSE , $lParam)
            $part = DllStructGetData($NMMOUSE, 'ItemSpec')
;~           OnStatusBarDoubleClick($part)
         GUICtrlSendToDummy($sb_dblclk_id, $part)
        EndIf
    EndIf
 
    Return $GUI_RUNDEFMSG
EndFunc
 
Func OnStatusBarDoubleClick($sb_part)
    ConsoleWrite('statusbar doubleclick, part=' & $sb_part & ' text=' & _GUICtrlStatusBar_GetText($hStatus, $sb_part) & @CRLF)
EndFunc

Note that GUICtrlSendToDummy() is used only for non-blocking processing of WM_NOTIFY message, so in this way you can have in OnStatusBarDoubleClick() also long lasting or blocking code like messagebox without any harm on system.

EDIT: The same way as $NM_DBLCLK can be used also $NM_CLICK

Edited by Zedna
Link to comment
Share on other sites

  • 1 year later...

Just for the reference, here is modification of my example

using _SendMessage() with custom message instead of GUICtrlSendToDummy().

With GUICtrlSendToDummy() you can send only 1 parameter and it must be numeric.

With _SendMessage() you can send 2 parameters (wParam+lParam) and it can be diferent types.

This is ideal when catching messages in ListView where you can trap/send item/subitem or item/state parameters for example.

; <a href='http://msdn.microsoft.com/en-us/library/windows/desktop/bb760734%28v=VS.85%29.aspx' class='bbc_url' title='External link' rel='nofollow external'>http://msdn.microsoft.com/en-us/library/windows/desktop/bb760734%28v=VS.85%29.aspx</a>

#include <GUIConstantsEX.au3>
#include <WindowsConstants.au3>
#include <GuiStatusBar.au3>

Global Const $WM_SB_DBLCLK = $WM_USER + 1

Global $hGUI = GUICreate("Statusbar doubleclick demo", 400, 300)
$label = GUICtrlCreateLabel('abc', 10,10,100)

Global $hStatus = _GUICtrlStatusBar_Create($hGUI)
Global $aParts[3] = [125, 250]
_GUICtrlStatusBar_SetParts($hStatus, $aParts)
_GUICtrlStatusBar_SetText($hStatus, "Text1", 0)
_GUICtrlStatusBar_SetText($hStatus, "Text2", 1)
_GUICtrlStatusBar_SetText($hStatus, "Text3", 2)

GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
GUIRegisterMsg($WM_SB_DBLCLK, "WM_SB_DBLCLK")

While 1
    Switch GuiGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam

    If $hWndGUI = $hGUI Then

        $NMHDR = DllStructCreate($tagNMHDR , $lParam)
        $hWndFrom = DllStructGetData($NMHDR, 'hWndFrom')
        $event = DllStructGetData($NMHDR, 'Code')

        If $event = $NM_DBLCLK And $hWndFrom = $hStatus Then
            $NMMOUSE = DllStructCreate($tagNMMOUSE , $lParam)
            $part = DllStructGetData($NMMOUSE, 'ItemSpec')
            _SendMessage($hGUI, $WM_SB_DBLCLK, $part, 0)
        EndIf
    EndIf

    Return $GUI_RUNDEFMSG
EndFunc

Func WM_SB_DBLCLK($hWnd, $MsgID, $wParam, $lParam)
    ConsoleWrite('statusbar doubleclick, part=' & $wParam & ' text=' & _GUICtrlStatusBar_GetText($hStatus, $wParam) & @CRLF)
EndFunc
Link to comment
Share on other sites

Nice example of using WM_USER. Thanks.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Because it will cause the application to "lock up". Try it and see AZJIO.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

guinness

I tried many times and I didn't see a difference. Maybe it is necessary to open a new thread?

Yeah do that please.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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...