Jump to content

[SOLVED]Deadlock upon GUI and Input Subclass


PhoenixXL
 Share

Recommended Posts

Hello Everyone

This it the Code

#NoTrayIcon
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstants.au3>

$hGUI = GUICreate(@ScriptName,500,400)
Global $nInput = GUICtrlCreateInput('', 10, 50, 480, 30)
Global $hInput = GUICtrlGetHandle(-1)

Global $nList = GUICtrlCreateList('', 10, 80, 480, 70)
GUICtrlSetState(-1, BitOR($GUI_HIDE,$GUI_ONTOP))
GUICtrlSetData(-1, 'Hello|Hie|Height|How')
Global $hList = GUICtrlGetHandle(-1)


; Set Input Proc
Global $InputProc = DllCallbackRegister("_InputProc", "long_ptr", "hwnd;uint;wparam;lparam")
Global $IProc = _WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, DllCallbackGetPtr($InputProc))
; Set GUI Proc
Global $ListProc = DllCallbackRegister("_GUIProc", "long_ptr", "hwnd;uint;wparam;lparam")
Global $LProc = _WinAPI_SetWindowLong($hGUI, $GWL_WNDPROC, DllCallbackGetPtr($ListProc))

GUISetState()

Do
Sleep(10)
Until GUIGetMsg() = -3

_Exit()

Func _Exit()
_WinAPI_SetWindowLong($hInput, $GWL_WNDPROC, $IProc)
_WinAPI_SetWindowLong($hGUI , $GWL_WNDPROC, $LProc)
DllCallbackFree($InputProc)
DllCallbackFree($ListProc)
EndFunc

Func _InputProc($hWnd, $iMsg, $wParam, $lParam)
Switch $iMsg
Case $WM_CHAR
Switch $wParam
Case 72 ; H
GUICtrlSetState($nList, $GUI_SHOW)
EndSwitch
EndSwitch
Return _WinAPI_CallWindowProc($IProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc

Func _GUIProc($hWnd, $iMsg, $wParam, $lParam)
Return _WinAPI_CallWindowProc($LProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc

I Subclassed the GUI to receive ListBox Notifications through WM_COMMAND

and the input to receive WM_CHAR

Upon typing the H in the input the Listbox is dropped

and this is where the Deadlock occurs

Maybe something is getting Invoked continuously but Im not able to find so

Thanks for your time

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

After pressing "H" the List appears

Click the List

after that click the Input again to receive Focus

That causes some sort of deadlock and the GUI freezes

for me it worked normally!

:huh: Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

I did this procedure and no deadlock occurs and the GUI not freezes!

Environment(Language:0416  Keyboard:00010416  OS:WIN_7/Service Pack 1  CPU:X64 OS:X64)

Edit: If you use WM_KEYDOWN will be much better because it works with lowercase letters

JS

Edited by JScript

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Im Having Environment(Language:0409 Keyboard:00000409 OS:WIN_7/ CPU:X64 OS:X86)

Can anybody try it on x86 OS

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

JScript,

Thanks for the Help

But the problem is upon subclassing the GUI still freezes

It is required to subclass the GUI to receive WM_COMMAND

Code

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>

#include "_GUIRegisterMsgEx.au3"

Global $iInput, $iList
Global $pOld_WndProc, $GUIProc
_Example()

Func _Example()
Local $hForm

$hForm = GUICreate(@ScriptName, 455, 163)

$iInput = GUICtrlCreateInput("", 97, 64, 247, 21)
$iList = GUICtrlCreateList("", 97, 86, 247, 70)
GUICtrlSetState(-1, BitOR($GUI_HIDE, $GUI_ONTOP))
GUICtrlSetData(-1, 'Hello|Hie|Height|How|Jscript')

$GUIProc = DllCallbackRegister("_GUIProc", "long_ptr", "hwnd;uint;wparam;lparam")
$pOld_WndProc = _WinAPI_SetWindowLong($hForm, $GWL_WNDPROC, DllCallbackGetPtr($GUIProc))


GUISetState(@SW_SHOW)

_GUICtrlMsg_Register($iInput, $WM_KEYUP, "_WndProc")

While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
_WinAPI_SetWindowLong($hForm, $GWL_WNDPROC, $pOld_WndProc)
DllCallbackFree($GUIProc)
Exit
EndSwitch
WEnd
EndFunc ;==>_Example

Func _WndProc($hWnd, $iMsg, $wParam, $lParam)
Switch $wParam
Case 72, 74
Return GUICtrlSetState($iList, $GUI_SHOW)
Case Else
If GUICtrlRead($iInput) = "" Then
GUICtrlSetState($iList, $GUI_HIDE)
EndIf
EndSwitch

Return $GUI_RUNDEFMSG
EndFunc ;==>_WndProc

Func _GUIProc($hWnd, $iMsg, $wParam, $lParam)
Return _WinAPI_CallWindowProc($pOld_WndProc, $hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>_GUIProc

Its basically for an UDF

Hence I cannot use GUIRegisterMsg

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Hence I cannot use GUIRegisterMsg

_GUICtrlMsg_Register() not used GUIRegisterMsg

Take a look at UDF _GUIRegisterMsgEx.au3

The example in your post above works on my Win7 - x86

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Link to comment
Share on other sites

Thanks for the help JScript

maybe some problem in my computer or maybe 2GB RAM

I would try to find a workaround

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • 4 weeks later...
  • Moderators

Im Having Environment(Language:0409 Keyboard:00000409 OS:WIN_7/ CPU:X64 OS:X86)

Can anybody try it on x86 OS

For what it is worth, ran it in x86 environment and saw the same things as JScript.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

  • 2 weeks later...

_GUICtrlMsg_Register() not used GUIRegisterMsg

Your UDF is the same as subclassing, it didnt solve the problem

Already one month will do what you posted, you already managed to solve the problem?

Still the problem is UNRESOLVED,

The code was for AutoSuggestion UDF

I tried to find a workaround with using WM_COMMAND and with GUIRegisterMsg rather than hooks,

But it feels odd for using GUIRegisterMsg in a UDF, then the User cannot use WM_COMMAND. :(

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • Moderators

PhoenixXL.

But it feels odd for using GUIRegisterMsg in a UDF, the User cannot use WM_COMMAND

Take a look at my ChooseFileFolder UDF and you will see how I get around this problem of existing message handlers: :)

; From the list of functions:

; _CFF_RegMsg:            Registers WM_NOTIFY to action doubleclick and item expansion on TreeView
; _CFF_WM_NOTIFY_Handler: Windows message handler for WM_NOTIFY - reacts to doubleclick and item expansion on TreeView

; And then in the headers for the 2 functions:

; Remarks .......: If the script already has a WM_NOTIFY handler then call the _CFF_WM_NOTIFY_Handler function
;                  from within it

; Remarks .......: If a WM_NOTIFY handler is already registered, then call this function from within that handler

Many of my UDFs use the same "trick" to enable them to use GUIRegisterMsg - after all sometimes you just cannot do without it. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

GUIRegisterMsg - after all sometimes you just cannot do without it.

I believe it is possible to register a GUI WinProc Hook and receive the messages internally through it [until and unless its single], but it goes way too complex.

Your Tip looks promising.

Thanks for the advice :)

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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