AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

tooltip.ahk version 2
Goto page Previous  1, 2
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
rexx



Joined: 28 Feb 2006
Posts: 72

PostPosted: Mon Apr 20, 2009 5:59 am    Post subject: Reply with quote

Thanks for your easy to use tooltip, but I have some problem with it.
Sometimes I click on a listview item, and then my gui becomes no response, until the gui window lost its focus. (the LV has no tooltip, but another edit control has one.)
And I tried to remove the "Critical" in the WM_MOUSEMOVE() function, then this won't happen again.
Is the critical necessary here?
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Mon Apr 20, 2009 8:14 am    Post subject: Reply with quote

You are saying that when you remove "Critical" the script works? If so, do you happen to have a variable called "counter" or "looper" in your code? (All global vars are prefaced with "tipGui_" to avoid conlicts - these two slipped through. This is fixed now.) That might cause the issue you report. I can't think of any other reason that the "WM_MouseMove" routine would hang. There is a loop that might never end if either of those two vars are changed unexpectedly. (On second thought, that might not matter because if the control classnn changes, the func should Return.)

To answer your question, though, I don't think it matters anymore if "Critical" is there. If another thread interrupts the previous and the control ID is the same, it skips the tip code and the new thread returns. If the control ID is diff, the old thread returns and the new one takes over.

BTW, what OS are you running? How fast is your computer? V2 or V2a? Can you post the problematic code? I'm curious why this could happen. Thanks.
_________________
Back to top
View user's profile Send private message
rexx



Joined: 28 Feb 2006
Posts: 72

PostPosted: Mon Apr 20, 2009 10:43 am    Post subject: Reply with quote

Micahs wrote:
You are saying that when you remove "Critical" the script works? If so, do you happen to have a variable called "counter" or "looper" in your code? (All global vars are prefaced with "tipGui_" to avoid conlicts - these two slipped through. This is fixed now.) That might cause the issue you report. I can't think of any other reason that the "WM_MouseMove" routine would hang. There is a loop that might never end if either of those two vars are changed unexpectedly. (On second thought, that might not matter because if the control classnn changes, the func should Return.)

The tooltips works without the "Critical".
I make the looper and counter local var because they have no "tipGui_", I thought it was a local var, and it works fine.
The problem ony happens when there's "Critical", no matter if looper and counter are global or not.

Micahs wrote:

BTW, what OS are you running? How fast is your computer? V2 or V2a? Can you post the problematic code? I'm curious why this could happen. Thanks.

Windows 7 beta / Intel Dual-Core 1.86G / V2
And the code is here http://www.autohotkey.net/~rexx/FolderMenu/files/FM.zip
Run FolderMenu.ahk and rightclick the tray icon, open options, and go to icons tab, click on an item in LV, and then it hangs.
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Tue Apr 21, 2009 10:34 am    Post subject: Reply with quote

I'm not sure what to tell you. It works for me in XPsp3. Maybe 7 has some issues. It is beta, after all.

As long as you can make it work, I guess that is the important thing!

I have removed "Critical" from the posted version because it is not really needed. I've made other changes, mainly to reduce overhead on non-tooltiped controls and guis.
_________________
Back to top
View user's profile Send private message
hughman



Joined: 11 Feb 2007
Posts: 166

PostPosted: Wed Apr 29, 2009 6:21 am    Post subject: Reply with quote

It's not neccessay to take advantage of MouseGetPos to retrieve the info of the gui and control under mouse.
You can use A_Gui and A_GuiControl to retrieve current target.
And MSDN wrote:
Quote:

;~ wParam
;~ Indicates whether various virtual keys are down,
;~ lParam
;~ The low-order word specifies the x-coordinate of the cursor
;~ The high-order word specifies the y-coordinate of the cursor

And you'd better return the monitor function according to A_Gui, because I have suffered from a conflict for a multiple gui script with your function and token a long time to find out the reason (the conflict is the same as rexx, but in xp sp2, the listview becomes no response or very slow, but the function has already deprived of Critical, and I am sure that there're no variable with the same name as yours )

So I wrote a function by myself. This is my version, I think it's more concise and efficient.
Code:

OnMessage(0x200, "OnMouseMove") ;WM_MOUSEMOVE

AddButton(guiIndex, btnIndex, w, h, opt, tip="", VarName="", text="")
{
   global
   If Not _Var := VarName
      _Var = Button_%guiIndex%_%btnIndex%
   Tooltip_%_Var% := tip
   Gui, %guiIndex%:Add, Button, w%w% h%h% hwnd%_hBtn% v%_Var% %opt%, %text%
   }
}


OnMouseMove(wParam, lParam)
{
   global
   static _LastGUI
   If (A_Gui = _LastGUI) And (A_Gui != 2) ; only apply to Gui2
      Return
   _LastGUI := A_Gui
   If (A_Gui != 2) {
      ToolTip
      Return
   }
;~    _xPos := lParam & 0xFFFF
;~     _yPos := lParam >> 16
   ToolTip, % Tooltip_%A_GuiControl%
}


But I have a puzzle:
The button's glable event can't be excuted until the tooltip disappears. the OnMessage and glable runs as the same thread?
Who knows how to solve it?
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Thu Apr 30, 2009 9:09 am    Post subject: Reply with quote

Your code has some drawbacks:
  • Users might want to add tooltips to controls other than buttons.
  • Your tooltips do not time out like standard tooltips.
  • Your tooltips follow the cursor instead of staying in place.
  • You have hardcoded to use only gui 2. This is not flexible.


Quote:
The button's glable event can't be excuted until the tooltip disappears.
I've not experienced this.


As far as the conflict you have suffered, if you could provide more details and some code, maybe we could figure out why this happens.
_________________
Back to top
View user's profile Send private message
hughman



Joined: 11 Feb 2007
Posts: 166

PostPosted: Sun May 03, 2009 3:30 pm    Post subject: Reply with quote

Yes, I confess. But it's only a little part of my project and I have no need to wrapper a common function. One can change it a bit for common use. This is my improved version:
Code:

AddControl(guiIndex, btnIndex, w, h, opt, tip="", VarName="", text="", control="Button")
{
   global
   If Not _Var := VarName
      _Var = %control%_%guiIndex%_%btnIndex%
   Tooltip_%_Var% := tip
   Gui, %guiIndex%:Add, %control%, w%w% h%h% hwnd%_Var%_hwnd v%_Var% %opt%, %text%
   }

OnMouseMove(wParam, lParam)
{
   global
   static _LastControl, _StartTick, _xPos, _yPos
   If (A_GuiControl = _LastControl) and (A_TickCount - _StartTick > 3000) ; time out after 3 second.
   {
      ToolTip
      Return
   }
   If (A_GuiControl != _LastControl)
   {
      _LastControl := A_GuiControl
      _StartTick := A_TickCount
      _xPos := lParam & 0xFFFF
      _yPos := lParam >> 16
   }
   ToolTip, % Tooltip_%A_GuiControl%, %_xPos%, %_yPos%
}
Back to top
View user's profile Send private message
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Sun May 03, 2009 11:17 pm    Post subject: Reply with quote

That's the good thing about this forum. Users can pick which version they prefer.

I still prefer mine because the user can create the controls any way they wish and then provide any bit of info to set the tooltip. (hwnd, text, var, classnn)


Keep in mind that your latest script still does not time out if the mouse doesn't move.
_________________
Back to top
View user's profile Send private message
Drugwash



Joined: 07 Sep 2008
Posts: 921
Location: Ploiesti, RO

PostPosted: Mon May 04, 2009 12:14 am    Post subject: Reply with quote

Dreaming... Cpp Tooltip Rolling Eyes
Works in 9x too, you know. Wink
Back to top
View user's profile Send private message Visit poster's website Yahoo Messenger
Micahs



Joined: 01 Dec 2006
Posts: 460

PostPosted: Mon May 04, 2009 1:44 am    Post subject: Reply with quote

Ha, keep dreaming! Laughing
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group