kcvinu Posted January 29, 2016 Posted January 29, 2016 Hi all, I am playing with this script. It only responds to WM_PAINT message. And it is not quitting when i click the close button. Please look at the script. expandcollapse popup#include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global $g_hProcOld, $g_hNewProc Local $hForm1, $g_bExit = False Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $hForm1 = GUICreate("Hello Program", 550, 306, 277, 153) Local $hLabel1 = GUICtrlCreateLabel("Hello from AutoIt", 200, 120, 136, 17) GUICtrlSetOnEvent(-1, "Label1Click") Local $hBtn = GUICtrlCreateButton("Click", 100, 100, 86, 57) GUICtrlSetOnEvent(-1, "BtClick") $g_hNewProc = DllCallbackRegister('_WndProc', 'LRESULT', 'hwnd;uint;wparam;lparam') $g_hProcOld = _WinAPI_SetWindowLong($hForm1, $GWL_WNDPROC,DllCallbackGetPtr($g_hNewProc)) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(10) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd #Region ctrl funcs Func Label1Click() EndFunc Func BtClick() EndFunc #EndRegion ctrl funcs DllCallbackFree($g_hNewProc) Func _WndProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_CLOSE _WinAPI_DestroyWindow($hForm1) Case $WM_CREATE ConsoleWrite("Just Created" & @CRLF) Case $WM_PAINT ConsoleWrite("Wondow Painted" & @CRLF) Case $WM_KEYDOWN ConsoleWrite("key pressed" & @CRLF) EndSwitch Return _WinAPI_CallWindowProc($g_hProcOld,$hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WndProc Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
AutoBert Posted January 29, 2016 Posted January 29, 2016 (edited) 1 hour ago, kcvinu said: ... And it is not quitting when i click the close button. I can't believe you are wondering about and can't find it. Using Opt("GUIOnEventMode", 1) and trying GuiGetMsg to listen which events are fired not works. Just use GUISetOnEvent. Edited January 29, 2016 by AutoBert
kcvinu Posted January 29, 2016 Author Posted January 29, 2016 @AutoBert , Thanks , My mistake. It now quits when i click the x button. But what about the WM_CREATE and WM_KEYDOWN messages. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
AutoBert Posted January 29, 2016 Posted January 29, 2016 (edited) 40 minutes ago, kcvinu said: @AutoBert , Thanks , My mistake. It now quits when i click the x button. But what about the WM_CREATE and WM_KEYDOWN messages. I never worked with _WinAPI_SetWindowLong or DllCallbackRegister, but i don't believe WM_CREATE can be catched for a GUI which already created. Edited January 29, 2016 by AutoBert
kcvinu Posted January 29, 2016 Author Posted January 29, 2016 The WM_KEYDOWN is working only when i use _WinAPI_DefWindowProc instead of _WinAPI_CallWindowProc in _WndProc function. But then the script resists to stop. Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer --- A tool to visit the links of some most important UDFs Includer_2 ----- A tool to type the #include statement automatically Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing. Alert ------ An alternative for MsgBox MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF -------- An UDF for working with access database files. (.*accdb only)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now