Page 2 of 2

Re: Class TransparentListBox

Posted: 16 May 2016, 08:15
by Verdlin
The update did not fix it. But, wow! After further research, I've discovered this is a "bug" with the native AHK ListBox and not your class :) I also noticed this behavior with non-AutoHotKey applications, so apparently it's a normal Windows thing.

Here's what happening: After launching an explorer.exe process (such as launching a folder) apparently explorer.exe sends the WM_Paint message. The Listbox (both AHK's and yours) repaints when this happens. I've provided a script below which should make this pretty clear.

So it's perfectly defensible for your script to keep doing what it is doing. For what it's worth, I would like a way to opt out of the redrawing procedure upon launching explorer.exe because I've never used a ListBox which is dependent upon anything that happens within explorer.exe. But I can easily do this on my own and then post the code in case you want to add it to the class.

Code: Select all

#NoEnv
Loop, %A_WinDir%\Web\Wallpaper\*.jpg, 0, 1
{
   PicFile := A_LoopFileLongPath
   Break
}
; PicFile := A_WinDir . "\Web\Wallpaper\Blaues Fenster.jpg"   ; German Win XP
; PicFile := A_WinDir . "\Web\Wallpaper\Landscapes\img7.jpg"  ; Win 7
; PicFile := A_WinDir . "\Web\Wallpaper\theme2\img10.jpg"     ; Win 8.1
Content := "One|Two|Three|Four|Five|Six|Seven|Eight|Nine|Ten|Eleven|Twelve|Thirteen|Fourteen|Fifteen|Sixteen"
; ----------------------------------------------------------------------------------------------------------------------
Global hMain
Gui, New, hwndhMain
Gui, Font, s12
Gui, Add, Picture, x0 y0 w600 h400 hwndhPic, %PicFile%
Gui, Add, ListBox, x50 y50 w200 r8 vLB1 gSel1 Choose1, %Content%
Gui, Add, ListBox, x+100 yp wp hp hwndhLB vLB Choose1 gSelection -VScroll -E0x0200, %Content%
TLB := New TransparentListBox(hLB, hPic, 0xFFFFFF, 0x000000, 0xFFFFFF, 128)
Gui, Show, w600 h400, Transparent ListBox
Return
; ----------------------------------------------------------------------------------------------------------------------
GuiClose:
ExitApp
; ----------------------------------------------------------------------------------------------------------------------
#If WinActive("ahk_id " . hMain)
!x::
   Random, R, 0, % TLB.ItemCount
   GuiControl, %hMain%:Choose, LB, %R%
Return
#If
; ----------------------------------------------------------------------------------------------------------------------
Selection:
   GuiControlGet, LB
   ToolTip, Selected: %LB%`nA_GuiEvent: %A_GuiEvent%`nA_EventInfo: %A_EventInfo%
   SetTimer, KillTT, -750
Return
Sel1:
   GuiControlGet, LB1
   ToolTip, Selected: %LB1%`nA_GuiEvent: %A_GuiEvent%`nA_EventInfo: %A_EventInfo%
   Msgbox Move your mouse off the listbox and then keep your eyes on the corners of the listbox
		Run, %A_WinDir%
   SetTimer, KillTT, -750
Return
KillTT:
   ToolTip
Return
; ----------------------------------------------------------------------------------------------------------------------
#Include Class_TransparentListBox.ahk

Re: Class TransparentListBox

Posted: 16 May 2016, 10:04
by just me
Thanks for testing.

Maybe it's due to my old eyes, but I cannot see any abnormal when running your test script.

Re: Class TransparentListBox

Posted: 17 May 2016, 06:50
by Verdlin
Interesting. I just noticed your signature says you run Win 10 Pro. I typically use Win 7 pro. I'm guessing that's the difference. I suppose it's not an issue in newer versions of windows.

Re: Class TransparentListBox

Posted: 30 Oct 2016, 12:15
by empardopo
Hello.

I'm using this class and I have two questions:
1.- Is it possible to center the text of each item in the listbox?
2.- I have three items (Notepad, Mala and HyperSpin) in my listbox. If I press la n key in my keyboard, Notepad item is selected or if I press the m key then Mala is selected. Is it possible to disable this option in the class?

Thanks very much for your class.

Greetings

Re: Class TransparentListBox

Posted: 06 Nov 2016, 03:50
by just me
  1. You might try to add the DT_CENTER (0x01) flag to the DrawText uFormat parameter:

    Code: Select all

                DllCall("User32.dll\DrawText", "Ptr", LBDC, "Ptr", &Txt, "Int", Len, "Ptr", &RECT, "UInt", 0x0841)
  2. You might try to add the following to SubClassProc:

    Code: Select all

          ; ----------------------------------------------------------------------------------------------------------------
          ; Keyboard
          ; ----------------------------------------------------------------------------------------------------------------
          ; WM_CHAR message
          If (uMsg = 0x0102)
             Return 0
I didn't test both.

Re: Class TransparentListBox

Posted: 06 Nov 2016, 15:01
by empardopo
I've just take a look changing the class and my first impression is that it works fine!!!! Thanks very much!