Sign in to follow this  
Followers 0
icuurd12b42

ToolTip replacement

5 posts in this topic

#1 ·  Posted (edited)

I had a ton of problems with ToolTip. Mainly it showed tips on top of everything. when my application was behind or minimised the tips would show tip on the desktop over another app, confusing people.

This alternative uses a stub edit box's tool tip to replace ToolTip, It will stick to the main window, not go on top of everything and not display if the window is minimized or invisible.

I also added message importance, along with a control variable so you can tone down how many messges you generate for informing the user.

the required control variables

global $control_MaxMsgLevel = 3; what level of messages allowed to show
global $control_ShowTrayMsg = 1; display in tray if minimised
global $control_TimeOutFac = 1; a time multiplication factor so message stick longer or shorter
global $control_LogMsg = 0; for logging, logging code not included
global $hMainWnd; set to your GUI

the function

global $stube = -1;
func OnHideTip()
_GUICtrlEdit_HideBalloonTip(GUICtrlGetHandle($stube));
AdlibUnRegister("OnHideTip");
EndFunc

Func Tip($x,$y,$title,$message,$icon,$level,$ctrl = 0,$timeoutS = 1,$delay = 0)
   if($level>$control_MaxMsgLevel) then return 0;
   local $lx = $x;
   local $ly = $y;
   if($ctrl) Then
      local $pos = _WinAPI_GetWindowPlacement($hMainWnd);
      local $wx = DllStructGetData($pos, "rcNormalPosition",1)
      local $wy = DllStructGetData($pos, "rcNormalPosition",2)
      local $tRect = _WinAPI_GetWindowRect(GUICtrlGetHandle($ctrl));
      $lx += (DllStructGetData($tRect, "Left") + DllStructGetData($tRect, "Right"))/2 -$wx;
      $ly += (DllStructGetData($tRect, "Top") + DllStructGetData($tRect, "Bottom"))/2 -$wy-28;
   EndIf
   if($stube = -1) Then
      $stube = GUICtrlCreateEdit("",$lx,$ly,0,0);
      _WinAPI_ShowWindow(GUICtrlGetHandle($stube), @SW_HIDE);
   EndIf
   GUICtrlSetPos($stube,$lx,$ly);
   _GUICtrlEdit_ShowBalloonTip(GUICtrlGetHandle($stube), $title,$message,$icon);
   AdlibUnRegister("OnHideTip");
   AdlibRegister("OnHideTip",$timeoutS*$control_TimeOutFac * 1000);
   if($control_ShowTrayMsg and IsMinimized()) then TrayTip($title,$message,$timeoutS*$control_TimeOutFac,$icon);
   if($control_LogMsg) then LogMessage($title, $message)
   if($delay) sleep($timeoutS*$control_TimeOutFac * 1000);

EndFunc

func IsMinimized()
   return ((WinActive("[ACTIVE]") = 16) or (_WinAPI_IsWindowVisible($hMainWnd) = 0));
EndFunc

to call

Level 0, message always show if control_MaxMsgLevel is 0 or higher

Tip(0,0,"Error","There was a problem",$TTI_ERROR,0,$ctrl_UserDD)

Level 2 will only show if the options are set to display message of that high verbose level control_MaxMsgLevel = 2 or higher

Tip(0,0,"Tip","Did you know you can lower the tip level so this does not show anymore",$TTI_INFO,2,$ctrl_UserDD)
Edited by icuurd12b42

Share this post


Link to post
Share on other sites



Hey, just, good job. :P


Spoiler

Paster - Main function is to paste text, but has more functions.

OpenW - Open With... alternative, Open any file with any application, set it's icon, set application as default.

Renamer - Rename files and folders, remove portions of text from the filename etc.

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Firefox Profile Backup - Backup/restore previously saved profile.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks. I just reformatted the code in the main post. the format was ruined when I edited it last time

Edited by icuurd12b42

Share this post


Link to post
Share on other sites

Nice work!

_GUICtrlEdit_ShowBallonTip does not work with buttons, your function work!

God job!


Visit my repository

Share this post


Link to post
Share on other sites

Thanks

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0