The MASM Forum

General => The Campus => Topic started by: dedndave on October 05, 2012, 12:12:22 AM

Title: Tooltips for Multiple Controls ?
Post by: dedndave on October 05, 2012, 12:12:22 AM
i have made some custom buttons...

(http://imageshack.us/a/img198/2563/custbuttons.png)

i would like to have tooltips for each button
i have very limited experience using tooltips   :P

my question is this...
do i create a seperate tooltip control for each button
or do i create a single tooltip control, and add multiple tips with TTM_ADDTOOL ?
Title: Re: Tooltips for Multiple Controls ?
Post by: jj2007 on October 05, 2012, 12:34:48 AM
Dave,

See line 5272ff in \Masm32\MasmBasic\MasmBasic.inc, plus e.g. line 182 in \masm32\RichMasm\Res\SkelWinLV.asc
I cannot promise that all that is self-explanatory, but you will recognise the API calls needed ;-)

hth
Jochen
Title: Re: Tooltips for Multiple Controls ?
Post by: dedndave on October 05, 2012, 01:25:22 AM
thanks Jochen

although, this text was a little confusing, at first   :biggrin:

Quote from: jj2007 on October 05, 2012, 12:34:48 AMSee line 5272ff...
my first thought was "it must be a big file"
Title: Re: Tooltips for Multiple Controls ?
Post by: mineiro on October 05, 2012, 05:42:28 AM
Hello Sir dedndave;
I remember playing with this some time ago, but I have forgotten all that I have learned. I have found the link:
http://www.masmforum.com/board/index.php?topic=16671.0
Not sure if this give you some path, because I remember of extract that code from other project.
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 05, 2012, 04:54:41 PM

Thinks to do are:
Know where is the mouse cursor is,with WM_MOUSEMOVE message.
Know where are the controls.
Made all coordinates in screen coordinate or windows coordinate.
The mouse is in a control ?
Show the tooltip.
Creating a tooltip:
Create the control (Nothing shown),when needed create the tooltip.

Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 05, 2012, 05:05:29 PM

It is good day,I have keep a sample posted in the old forum
Title: Re: Tooltips for Multiple Controls ?
Post by: jj2007 on October 05, 2012, 09:38:01 PM
Quote from: ToutEnMasm on October 05, 2012, 04:54:41 PM

Thinks to do are:
Know where is the mouse cursor is,with WM_MOUSEMOVE message.

Where is that documented? My tooltips work just fine without that message.
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 05, 2012, 10:07:51 PM
Quote
Where is that documented? My tooltips work just fine without that message
showing your code,as i do ,wil be better than ask for undocumented answer  :bgrin:
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 05, 2012, 10:22:46 PM

Sorry it is documented somewhere
Quote
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760250(v=vs.85).aspx
:eusa_dance:
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 05, 2012, 10:38:25 PM
and here the link (in the exe) who give the more answer on control.
The "common control" link give source code in C
Title: Re: Tooltips for Multiple Controls ?
Post by: jj2007 on October 05, 2012, 11:54:50 PM
Quote from: ToutEnMasm on October 05, 2012, 10:07:51 PM
Quote
Where is that documented? My tooltips work just fine without that message
showing your code,as i do ,wil be better than ask for undocumented answer  :bgrin:

See reply #1.

Quote from: ToutEnMasm on October 05, 2012, 10:22:46 PM

Sorry it is documented somewhere
Quote
http://msdn.microsoft.com/en-us/library/windows/desktop/bb760250(v=vs.85).aspx
:eusa_dance:

MSDN says "messages handled by the window procedure", i.e. no need for handling the message. And indeed my code works just fine without WM_MOUSEMOVE (indeed there is not a single WM_MOUSEMOVE in 15,000 lines of MB source code - Windows knows very well how to handle that message... :P).

Test it with any of the windows examples, e.g. \Masm32\examples\exampl04\car\car.asm - just four lines more:

include \masm32\MasmBasic\MasmBasic.inc   ; download (http://www.masm32.com/board/index.php?topic=94.0)
;      .486                      ; create 32 bit code
;      .model flat, stdcall      ; 32 bit memory model
;      option casemap :none      ; case sensitive

...

    .elseif uMsg == WM_CREATE
        invoke BitmapFromResource, hInstance, 2000
        mov hBmp, eax
        invoke PushButton,SADD("About"),hWin,210,180,100,25,50
        ToolTips TTS_BALLOON         ; optional: use a specific style
        ToolTips rv(GetDlgItem, hWin, 50), "Click About please"   ; immediate text for tooltip
        ToolTips end         ; not optional: close the tooltips definition
    .elseif uMsg == WM_SYSCOLORCHANGE

Or take \Masm32\examples\exampl01\bmbutton\bmbutton.asm - it's no rocket science, really:

    .elseif uMsg == WM_CREATE
        ...
        ToolTips
        ToolTips hBtn1, "The first button"
        ToolTips hBtn2, "The second button"
        ToolTips hBtn3, "The third button"
        ToolTips hBtn4, "The fourth button"
        ToolTips end
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 06, 2012, 01:56:12 AM
Quote
MSDN says "messages handled by the window procedure", i.e. no need for handling the message. And indeed my code works just fine without WM_MOUSEMOVE (indeed there is not a single WM_MOUSEMOVE in 15,000 lines of MB source code - Windows knows very well how to handle that message... ).
You are just BLIND
Follow this link  Tracking Tooltips
You find this page http://msdn.microsoft.com/en-us/library/windows/desktop/hh298405(v=vs.85).aspx (http://msdn.microsoft.com/en-us/library/windows/desktop/hh298405(v=vs.85).aspx)
With this code:
Quote
//g_hwndTrackingTT is a global HWND variable

case WM_INITDIALOG:

        InitCommonControls();
        g_hwndTrackingTT = CreateTrackingToolTip(IDC_BUTTON1, hDlg, L"");
        return TRUE;

case WM_MOUSELEAVE: // The mouse pointer has left our window. Deactivate the tooltip.
   
    SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)FALSE, (LPARAM)&g_toolItem);
    g_TrackingMouse = FALSE;
    return FALSE;

case WM_MOUSEMOVE:

    static int oldX, oldY;
    int newX, newY;

    if (!g_TrackingMouse)   // The mouse has just entered the window.
    {                       // Request notification when the mouse leaves.
   
        TRACKMOUSEEVENT tme = { sizeof(TRACKMOUSEEVENT) };
        tme.hwndTrack       = hDlg;
        tme.dwFlags         = TME_LEAVE;
       
        TrackMouseEvent(&tme);

        // Activate the tooltip.
        SendMessage(g_hwndTrackingTT, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM)&g_toolItem);
       
        g_TrackingMouse = TRUE;
    }

    newX = GET_X_LPARAM(lParam);
    newY = GET_Y_LPARAM(lParam);

    // Make sure the mouse has actually moved. The presence of the tooltip
    // causes Windows to send the message continuously.
   
    if ((newX != oldX) || (newY != oldY))
    {
        oldX = newX;
        oldY = newY;
           
        // Update the text.
        WCHAR coords[12];
        swprintf_s(coords, ARRAYSIZE(coords), L"%d, %d", newX, newY);
       
        g_toolItem.lpszText = coords;
        SendMessage(g_hwndTrackingTT, TTM_SETTOOLINFO, 0, (LPARAM)&g_toolItem);

        // Position the tooltip. The coordinates are adjusted so that the tooltip does not overlap the mouse pointer.
       
        POINT pt = { newX, newY };
        ClientToScreen(hDlg, &pt);
        SendMessage(g_hwndTrackingTT, TTM_TRACKPOSITION, 0, (LPARAM)MAKELONG(pt.x + 10, pt.y - 20));
    }
    return FALSE;

In the link i posted first you can also find WM_MOUSEMOVE

Really BLIND or don't want to see






Title: Re: Tooltips for Multiple Controls ?
Post by: jj2007 on October 06, 2012, 02:12:50 AM
Quote from: ToutEnMasm on October 06, 2012, 01:56:12 AM
You are just BLIND
Follow this link  Tracking Tooltips
...
Really BLIND or don't want to see

Monsieur, je vous en prie!!! Show me one professional app that uses those horrible tracking tooltips... even in your beautifully styled EditMasm, you use "normal" tooltips  :biggrin:
Title: Re: Tooltips for Multiple Controls ?
Post by: TouEnMasm on October 06, 2012, 03:04:01 AM

If you don't want want them who don't want to use them , it's your problem.
My only problem,was to find a sample of it.