1. win32lib: support for longer than 80-char long tooltips

i modified win32lib so that longer than 80 characters long tooltips are whole
shown.
Derek, you could add this to win32lib.
it's from MSDN article
"HOWTO: Display More Than 80 Characters in a Tooltip Control"

i dont know if i did it correct.

it's for win32lib Version:     0.60.5 05/September/2004


article says u have to use TTS_NOPREFIX flag, so:
setHintEx (id, "tip", TTS_NOPREFIX)
better add it to win32lib docs.


I also made it so that width of tooltip is auto calculated, based on widest
tooltip text line.



-- start tone skoda: support for longer than 80-char long tooltips
atom TTTextPtr
TTTextPtr = 0
-- end tone skoda
----------------------------------------------------
function fDoTTN_GETDISPINFO(integer id, atom hWnd, atom wParam, atom lParam)
----------------------------------------------------
    sequence lText
    atom hFrom
    atom lTextLen

    -- start tone skoda: autowidth of tooltip
    sequence lineText
    integer largestWid, lineWid
    sequence screenSize
    -- end tone skoda

    id = getId( wParam )
    if id = 0 then
        id = w32fetch(lParam, NMHDR_idFrom )
    end if

    if id > 0 and id <= length(ctrl_Hint_Text) then
        if atom(ctrl_Hint_Text[id]) then
            if integer(ctrl_Hint_Text[id]) and ctrl_Hint_Text[id] >= 0 then
                -- The user routine returns either a string or a sequence in
                -- the form of { string, width }, eg. {"Sample text", 120}
                lText = call_func(ctrl_Hint_Text[id], {id, ctrl_Hint_Width[id]})
if length(lText) = 2 and sequence(lText[1]) and
                integer(lText[2]) then
                    ctrl_Hint_Width[id] = lText[2]
                    lTextLen = lText[2]
                    lText = lText[1]
                elsif length(lText) = 0 then
                    lTextLen = 0
                else
                    lTextLen = ctrl_Hint_Width[id]
                end if
            else
                lText = sprintf("Invalid routine_id %g", ctrl_Hint_Text[id])
                lTextLen = ctrl_Hint_Width[id]
            end if
        else
            lText = ctrl_Hint_Text[id]
            lTextLen = ctrl_Hint_Width[id]
       end if

        w32store( lParam, NMTTDISPINFO_szText, lText )
  
        -- start tone skoda: support for longer than 80-char long tooltips
        if length (lText) > 80 then
            if TTTextPtr != 0 then
                w32release_mem (TTTextPtr)
            end if
            TTTextPtr = w32acquire_mem (0, lText)
            w32store( lParam, NMTTDISPINFO_lpszText, TTTextPtr )
        end if        
        -- end tone skoda
  
        
        -- start tone skoda: autowidth of tooltip

        -- 1.get largestWid
        lineText = ""
        largestWid = 0
        for i = 1 to length (lText) do
            if lText [i] = '\n' or i = length (lText) then
                if i = length (lText) then
                    lineText &= lText [i]
                end if
                lineWid = getTextWidth (tooltipControl, lineText)
                if lineWid > largestWid then
                    largestWid = lineWid
                end if
                lineText = ""
            else
                lineText &= lText [i]
            end if            
        end for

        -- 2. get lTextLen, if larger than screen then adjust to screen
        lTextLen = largestWid
        screenSize = getCtlSize( Screen )
        if lTextLen > screenSize [1] then
            lTextLen = screenSize [1]
        end if
        -- end tone skoda


        VOID = w32Func(xSendMessage,{w32fetch(lParam, NMHDR_hwndFrom ),
                          TTM_SETMAXTIPWIDTH, 0,
                          lTextLen})

    end if

   return {kMainMsg}
end function

new topic     » topic index » view message » categorize

2. Re: win32lib: support for longer than 80-char long tooltips

Something sounds 'fishing' smile

Sounds like you'd want to use a multiline tool tip control rather
than a single line...looks neater on screen anyway.


Take care,
Al

And, good luck with your Euphoria programming!

My bumper sticker: "I brake for LED's"

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu