Sign in to follow this  
Followers 0
AZJIO

Than blocking in a main loop differs from blocking in WM_NOTIFY

13 posts in this topic

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

Opt("GUIOnEventMode", 1)
Global $iListView, $hListView

$hGUI = GUICreate('', 450, 360)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
$iListView = GUICtrlCreateListView('Col 1', 5, 5, 440, 330, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_REPORT, $LVS_SHOWSELALWAYS))
$hListView = GUICtrlGetHandle(-1)

For $i = 100 To 111
    GUICtrlCreateListViewItem($i, $iListView)
Next

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

While 1
    Sleep(100000)
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    MsgBox(0, 'Blocking', _GUICtrlListView_GetItemText($hListView, DllStructGetData($tInfo, "Index"), DllStructGetData($tInfo, "SubItem")), 0, $hGUI)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _Exit()
    Exit
EndFunc   ;==>_Exit
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>

Global $hGUI, $iListView, $hListView, $iDummy

$hGUI = GUICreate('', 450, 360)
$iDummy = GUICtrlCreateDummy()
$iListView = GUICtrlCreateListView('Col 1', 5, 5, 440, 330, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_REPORT, $LVS_SHOWSELALWAYS))
$hListView = GUICtrlGetHandle(-1)

For $i = 100 To 111
    GUICtrlCreateListViewItem($i, $iListView)
Next

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


While 1
    Switch GUIGetMsg()
        Case $iDummy
            MsgBox(0, 'Blocking', GUICtrlRead(GUICtrlRead($iListView)), 0, $hGUI)
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    GUICtrlSendToDummy($iDummy)
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

Why blocking of WM_NOTIFY is worse than blocking in a main loop?

Share this post


Link to post
Share on other sites



Try with _ArrayDisplay. Create a temporary array in that message function and then you will see what happens.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I will have to look for the problem _ArrayDisplay

The function "_ArrayDisplay" creates a window. I in the example don't create a window. Therefore the problem of the _ArrayDisplay function is an exception, which in my case not a hindrance.

Edited by AZJIO

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Any blocking WM should lead the window to stop responding if you try to manipulate it.

Edit: It's kind of like callback functions.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Normally when the Devs say "we don't recommend this" it's normally best to listen and take note.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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: 04/09/2015

Share this post


Link to post
Share on other sites

FireFox

When a time-consuming operation is performed in a loop, the window is locked and does not respond

Share this post


Link to post
Share on other sites

That's the same thing for your example, except that the "loop" is the WM function.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Why do I need to do a mediator who will redirect actions to a main loop?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I had problems when catching/using several messages in WM_NOTIFY with blocking code.

There were some visual problems or even crashes.

Another type of problems was with timing in my functions invoked from WM_NOTIFY (directly),

when I tried to get some GUI properties it had bad value because internal code from WM_NOTIFY wasn't finished.

These type of problems is related on length (time consuming) of your blocking code

so it's dangerous to ignore recommendations a do it by risky way.

Edited by Zedna

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Why do I need to do a mediator who will redirect actions to a main loop?

Yes, I tested an example with it but there is a bug I can't explain. There is nothing related to it in the bugtracker nor in the forum or in the helpfile.

As you will see, the data of the structure is not the same in WM_NOTIFY and _MyFunc1 functions.

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

Opt("GUIOnEventMode", 1)

Global $iListView, $hListView

Global $_tInfo = 0, $blCallFunc1 = False

$hGUI = GUICreate('', 450, 360)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit')
$iListView = GUICtrlCreateListView('Col 1', 5, 5, 440, 330, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_REPORT, $LVS_SHOWSELALWAYS))
$hListView = GUICtrlGetHandle(-1)

For $i = 100 To 111
    GUICtrlCreateListViewItem($i, $iListView)
Next

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

While 1
    Sleep(10)
    If $blCallFunc1 Then
        $blCallFunc1 = False
        _MyFunc1()
    EndIf
WEnd

Func _MyFunc1()
    ConsoleWrite("_MyFunc1 Index: " & DllStructGetData($_tInfo, "Index") & @crlf)
    MsgBox(0, 'Blocking', _GUICtrlListView_GetItemText($hListView, DllStructGetData($_tInfo, "Index"), DllStructGetData($_tInfo, "SubItem")), 0, $hGUI)
EndFunc   ;==>_MyFunc1

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView
            Switch $iCode
                Case $NM_CLICK
                    $_tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    ConsoleWrite("WM_NOTIFY Index: " & DllStructGetData($_tInfo, "Index") & @crlf)
                    $blCallFunc1 = True
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Func _Exit()
    Exit
EndFunc   ;==>_Exit
Edit: Added indents.

Note: I never used DllStructGetData (as far as I can remember) in different functions so I don't know if I'm using it badly or whatever.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

@FireFox

Do it this way:

Func _MyFunc1()
;~     ConsoleWrite("_MyFunc1 Index: " & DllStructGetData($_tInfo, "Index") & @crlf)
    ConsoleWrite("_MyFunc1 Index: " & _GUICtrlListView_GetNextItem($hListView)  & @crlf)
;    MsgBox(0, 'Blocking', _GUICtrlListView_GetItemText($hListView, DllStructGetData($_tInfo, "Index"), DllStructGetData($_tInfo, "SubItem")), 0, $hGUI)
EndFunc   ;==>_MyFunc1

Or make $index/$subitem as global variables

or use SendMessage() with $index/$subitem parameters as described in my original topic here

'?do=embed' frameborder='0' data-embedContent>>

Edited by Zedna

Share this post


Link to post
Share on other sites

@Zedna

I know, that's not the point. I was referring to the struct's bug.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

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