Jump to content
Sign in to follow this  

ToolTip replacement

Recommended Posts

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()

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;
   if($stube = -1) Then
      $stube = GUICtrlCreateEdit("",$lx,$ly,0,0);
      _WinAPI_ShowWindow(GUICtrlGetHandle($stube), @SW_HIDE);
   _GUICtrlEdit_ShowBalloonTip(GUICtrlGetHandle($stube), $title,$message,$icon);
   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);


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

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


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

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

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

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

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.

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

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

IUIAutomation - Topic with framework and examples


Share this post

Link to post
Share on other sites

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

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...