AutoHotkey Community

It is currently May 26th, 2012, 7:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: April 20th, 2009, 6:59 am 
Offline

Joined: February 28th, 2006, 4:38 pm
Posts: 73
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2009, 9:14 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2009, 11:43 am 
Offline

Joined: February 28th, 2006, 4:38 pm
Posts: 73
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 21st, 2009, 11:34 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 29th, 2009, 7:21 am 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2009, 10:09 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 3rd, 2009, 4:30 pm 
Offline

Joined: February 11th, 2007, 4:10 pm
Posts: 185
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%
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2009, 12:17 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
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.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2009, 1:14 am 
Offline
User avatar

Joined: September 8th, 2008, 12:26 am
Posts: 1048
Location: Ploieşti, RO
Dreaming... Cpp Tooltip :roll:
Works in 9x too, you know. ;)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2009, 2:44 am 
Offline

Joined: December 1st, 2006, 9:27 am
Posts: 460
Ha, keep dreaming! :lol:

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: jrav and 18 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group