Mat Posted July 7, 2011 Share Posted July 7, 2011 My old implementation of a finder control like the one in Au3Info.exe has been pretty popular, so I was having a look to see if it needed any updating... And I want to offer my sincerest apologies to anyone who has used it. The code is so bad I think someone must have hijacked it as surely I can't have been THAT bad. So anyway. Here's how to do it properly.Reasons why this one is better: * Found out how to draw the inverted frame like Au3Info does (thanks Jon ) * You can now have as many of them as you want. And they can all have different icons. * No temporary files for resources, they are loaded straight from the binary. * There is some code to make sure that you never have frames left behind or not showing. It solves 99% of issues. * No globals. * Functions are now properly named. * My last one returned a dummy which you couldn't use for anything other than events. This one returns a handle * Doesn't use GUIRegisterMsg, so you can use it with this no problem * ...The only slight downfall is that, like other UDF controls, GUIGetMsg ignores it. Instead it sends notifications by WM_COMMAND messages (We all know WM_NOTIFY is a bit more work huh?). Right now there are 4, though I can add more easily enough. My favourite example is this:#include<GUIFinder.au3> $hGUI = GUICreate("_GUICtrlFinder_GetLastWnd Example", 300, 40) $hFinder = _GUICtrlFinder_Create($hGUI, 130, 4) GUISetState() GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While True $iMsg = GUIGetMsg() Switch $iMsg Case -3 ExitLoop EndSwitch WEnd Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) Switch _WinAPI_HiWord($wParam) Case $FN_WNDCHANGED WinSetTitle($hWnd, "", "Handle: " & _GUICtrlFinder_GetLastWnd($lParam)) Case $FN_STARTUSE WinSetTrans($hWnd, "", 150) Case $FN_ENDUSE WinSetTrans($hWnd, "", 255) WinSetTitle($hWnd, "", "_GUICtrlFinder_Create Example") EndSwitch EndFunc ;==>WM_COMMANDAs you can see, it behaves like a custom control should.DownloadIncludes examples + UDF.For those interested in implementation: It's a custom control, so I register my own window class, which stores information like icons and the last selected window using the "extra" window space, and the GetWindowLongPtr function. Most stuff is handled in the window proc, so GUIRegisterMsg is free for you to use for your own purposes.Mat AZJIO and madmasles 2 AutoIt Project Listing Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now