Proc to set uo Tool Tips

gsbr 0 Tallied Votes 236 Views Share

First it is in RosAsm style.
Sorry I am addicted to its simplicity of use.
The Proc is called from Dialog initiation

[Counter:D$ 0]
   
; Call for the first ToolTip
 Call SetTTip D$hdlg,        ; H Dialog Handle of Dialog or Window
                    1,          ; Tool tip number ID
                    1,          ; Normal (not balloon 2 is balloon type)
                    b_calculate,; Control ID number
                    1           ; Text Pointer to Ressource or pointer to a String
 
;To show success it returns with the  HANDLE of the created Tool tip
[ToolTipsHandles: 0 #16]      ; Space for 16 handles
[TOOLINFOS: 0 #(48*16)]       ; Space for 16 Structures

[Mode1   &TTS_NOPREFIX + &TTS_ALWAYSTIP] ; declaration of  values
[Mode2   Mode1 + &TTS_BALLOON]
[uFlags  &TTF_SUBCLASS + &TTF_IDISHWND]

Proc SetTTip:
;;
Only individuals
Each one has its complete system.
The Proc maintains the data
;;

Arguments   @hWnd,    ; Dialog or Window H
            @ttnb,    ; Tool tip Number
            @Mode,    ; Normal 1, Balloons 2
            @CtlID,   ; ID of Control
            @ttText
Uses ebx 

            [@ToolMode: ?]
            [@hToolHandle: ?]
If D@ttnb > 16
    Call 'USER32.MessageBoxA' D$hdlg,
                      {'Only 16 Possible',0},    ; Text message
                      {'ToolTip Id TOO High',0}, ; Box title
                      0                          ; Box style
    jmp X1>>

End_If
    ; Setup TOLINFO
    mov eax 48
    ; Set for Base 0
    dec D@ttnb
    mul D@ttnb
    add eax TOOLINFOS

    ;ToolInfo base
    mov ebx eax
nop
    ;Setup TOOLINFO(Array)
    mov D$ebx 48          ; .cbSize
    mov D$ebx + 4 uFlags  ; .uFlags
    mov eax D@hWnd
    mov D$ebx + 8 eax     ; .hWnd
    Call 'USER32.GetDlgItem' eax , D@CtlID
    mov D$ebx + 12 eax
    mov eax D$hInstance
    mov D$ebx + 32 eax
    mov eax D@ttText
    mov D$ebx + 36 eax
    If D@Mode = 1
        mov D@ToolMode Mode1
    Else
        mov D@ToolMode Mode2
    End_If

    Call 'USER32.CreateWindowExA' 0,TOOLTIPS_CLASS,0,
                                D@ToolMode,0,0,0,0,
                                D@hWnd,0,
                                D$hinstance,0
    ; Local Handle of Tool Tip
    mov D@hToolHandle eax


    Call 'USER32.SendMessageA' eax,;D@hToolHandle,    ; Handle to tooltip 1
                               &TTM_ADDTOOL,
                               0,
                               ebx;TOOLINFO        ; Ptr to tool
    mov eax D@hToolHandle ; show valid handle,it is in the array anyway
    mov edx D@ttNb
    ;dec edx              ; base to 0 was done at top
    sal edx 2             ; mult by 4
    mov ebx HandlesArray
    add ebx edx
    mov D$ebx  eax
 inc D$Counter ; Satellite for Controlling display

X1:
EndP
gsbr 0 Newbie Poster

Sorry I saw a little thin missing
and I cannopt find < EDIT >
(being new here)

[HandlesArray: 0 #16]
the place holder for the handles.

An other thing:
I assumed that the Handle for the Instance is called hInstance
to allow other names an extra parameter shoud be passed to the proc
declaring it as @hInstance
and changing all $ to @ $=Global @ = Stack local for hInstance(not many)

Sorry for the inconveniance.

I am in the editing buisness !!!
; to toggle vision of tool tip
Proc TTToggle:

Arguments @ID,
@ONOFF ;0,1 ON OFF
uses ebx


mov ebx HandlesArray
mov eax D@ID
dec eax
shl eax 2
add ebx eax
mov eax D@ONOFF
;mov edx D$ebx
mov ebx D$ebx
Call 'USER32.SendMessageA' ebx,
&TTM_ACTIVATE,
eax, ; True/False
0

EndP

gbr.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.