Results 1 to 3 of 3

Thread: [RESOLVED] Don't want to show tooltip when over Vscrollbar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Resolved [RESOLVED] Don't want to show tooltip when over Vscrollbar

    I have successfully created a tooltip using TOOLINFO structure, and changed its time on, changed the title, changed the text, using SendMessage and the proper TTMs. However I do not want the tooltip to popup when over the control's Vscrollbar. I played around with TOOLINFO.rc values, but when I do, the tooltip won't pop up at all. What am I doing wrong?

    .rc.right = listbox.width
    .rc.left = listbox.left
    .rc.top = listbox.top
    .rc.bottom = listbox.height

    .uflags = TTF_SUBCLASS



    TTM_GETTEXTA = Wm_User + 11
    Public Type
    cbsize as long
    uFlags as Long
    hwnd as long
    uID as long
    rc as RECT
    hInstance as Long
    lpszText as String
    lParam as long
    End Type

    Dim parentHwnd as long 'handle of the control I want the tooltip to trigger over
    Dim tipHwnd as Long 'returned from CreateWindow(tooltip setup styles)

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Don't want to show tooltip when over Vscrollbar

    For .RC: The bounding rectangle coordinates of the tool. The coordinates are relative to the upper-left corner of the client area of the window identified by hWnd. In pixels not twips.

    So, if hWnd is the listbox's hWnd, you will want to call GetClientRect API on that hWnd. But that probably includes the scrollbar too. So you will have to subtract the scrollbar's width if it has a scrollbar. GetWindowLong API and checking if WS_VScroll style is used should tell you if scrollbar is visible or not. To get the width of a standard scrollbar, use GetSystemMetrics API with SM_CXVSCROLL
    Code:
    Private Const GWL_STYLE As Long = -16
    Private Const WS_VSCROLL As Long = &H200000
    Private Const SM_CXVSCROLL As Long = &H2
    "Air Code" follows - typing from memory
    Code:
    GetClientRect listbox.hWnd, ttm.RC
    If (GetWindowLong(listbox.hWnd, GWL_Style) And WS_VScroll) Then ' vscroll visible
        ttm.RC.Right = ttm.RC.Right - GetSystemMetrics(SM_CXVSCROLL)
    End If
    Last edited by LaVolpe; Jan 22nd, 2010 at 04:20 PM. Reason: added Air Code
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2005
    Posts
    169

    Re: Don't want to show tooltip when over Vscrollbar

    LaVolpe,

    Turns out the call to GetSystemMetrics wasn't necessary, just the call to GetClientRect. I switched to using a MSHFlexgrid, the scrollbars werent included in the client area.

    Thank you!


    Others,
    use TTF_SUBCLASS OR TTF_IDISHWND flag to ignore the client area .rc in the TOOL_INFO structure.
    Last edited by vb_lover; Jan 23rd, 2010 at 02:28 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width