Findus | Jonathan (27.02.2013)
Hi, Perhaps can the Yes someone use: an Include, with the one on each beliebigen Window over each beliebigen area (relatively (0 To 1) and utterly (Pixel)) a Tooltip produce can, even mehrzeilig. here The Include: 'TOOLTIPS EVERYWHERE - TOOLTIP-INCLUDE FOR TOOLTIPS ON JEGLICHEN FENSTER-BEREICHEN
'==================================================================================
'
'(c) 2013 Jonathan
'These Include must spare uses and modifiziert go. circa a Info on the
'ursprünglichen Author becomes gebeten, at least in the Source.
Struct TTE_lpPoint = X&, Y&
'{GLOBALE VARIABLEN
Declare TTE_Tooltip_hWnd&'the Tooltip-Window
Declare TTE_Tooltip_text$[]'Text the Tooltips [X]
Declare TTE_Tooltip_grp&[]'group the Tooltips [X]
Declare TTE_Tooltip_tWnd&[]'Window the Tooltips [X]
Declare TTE_Tooltip_xpos![]'X-position the Tooltip-Bereichs [X]
Declare TTE_Tooltip_ypos![]'Y-position the Tooltip-Bereichs [X]
Declare TTE_Tooltip_xsz![]'X-Size the Tooltip-Bereichs [X]
Declare TTE_Tooltip_ysz![]'Y-Size the Tooltip-Bereichs [X]
Declare TTE_Tooltip_isRelative%[]'Relative Coordinates for Tooltip [X]?
Declare TTE_Tooltip_aktnum&'number the currently visible Tooltips
Declare TTE_Tooltip_aktmaxgrp&'Maximale vergebene groups-ID
Declare TTE_DisplayFont$'Nichtproportionaler Font
Declare TTE_TempStr$
TTE_Tooltip_aktmaxgrp& = -1
TTE_Tooltip_aktnum& = -1
'}
'{INITIALISIEREN DES TOOLTIP-FENSTERS
Window Style 16 + 64 + 128 + 1024
TTE_Tooltip_hWnd& = @Create("Window", %hwnd, "", 0, 0, 128, 20)
@External("User32.dll", "SetWindowPos", TTE_Tooltip_hWnd&, ~HWND_TOPMOST, 0, 0, 0, 0, ~SWP_NOMOVE | ~SWP_NOSIZE | ~SWP_FRAMECHANGED)
StartPaint TTE_Tooltip_hWnd&
USEP 5, 0, 0
UseBrush 1, 0
Rectangle 0, 0 - Width(TTE_Tooltip_hWnd&), Height(TTE_Tooltip_hWnd&)
EndPaint
ShowWindow(TTE_Tooltip_hWnd&, 0)
Window Style 1 + 2 + 4 + 8
'}
Proc TTE_ShowTooltip
Parameters X&, Y&, Text$
Declare Tooltip_imgbuffer&, TextLines$[], maxlen&
'@ShowWindow(Tooltip_hWnd&, 8)
TextLines$[] = @Explode(Text$, "\n")
maxlen& = 1
WhileLoop 0, @SizeOf(TextLines$[]) - 1
If @Len(TextLines$[&loop]) > maxlen&
maxlen& = @Len(TextLines$[&loop])
EndIf
EndWhile
Tooltip_imgbuffer& = @Create("hNewPic", 8 * maxlen&, 16 * @SizeOf(TextLines$[]), 0)
StartPaint Tooltip_imgbuffer&
WhileLoop 0, @SizeOf(TextLines$[]) - 1
UseFont TTE_displayFont$, 16, 8, 0, 0, 0
Text Color @Rgb(255, 255, 255), -1
DrawText 0, 16 * &loop, TextLines$[&loop]
EndWhile
EndPaint
~SetWindowPos(TTE_Tooltip_hWnd&, ~HWND_TOPMOST, X&, Y&, @Width(Tooltip_imgbuffer&), @Height(Tooltip_imgbuffer&), ~SWP_NOACTIVATE | ~SWP_NOOWNERZORDER | ~SWP_NOZORDER | ~SWP_SHOWWINDOW)
'SetWindowPos Tooltip_hWnd& = X&, Y& - @Width(Tooltip_imgbuffer&), @Height(Tooltip_imgbuffer&)
StartPaint TTE_Tooltip_hWnd&
DrawPic Tooltip_imgbuffer&, 0, 0; 0
EndPaint
DeleteObject Tooltip_imgbuffer&
ENDPROC
Proc TTE_HideTooltip
@ShowWindow(TTE_Tooltip_hWnd&, 0)
ENDPROC
Proc TTE_ToolTipRoutine
Declare MousePos#, X!, Y!, MousePosInWnd#
Dim MousePos#, TTE_lpPoint
Dim MousePosInWnd#, TTE_lpPoint
~GetCursorPos(MousePos#)
'Print MousePos#.X&, MousePos#.Y&
If TTE_Tooltip_aktnum& <> -1
MousePosInWnd# = MousePos#
~ScreenToClient(TTE_Tooltip_tWnd&[TTE_Tooltip_aktnum&], MousePosInWnd#)
If TTE_Tooltip_isRelative%[TTE_Tooltip_aktnum&]
X! = MousePosInWnd#.X& / Width(TTE_Tooltip_tWnd&[TTE_Tooltip_aktnum&])
Y! = MousePosInWnd#.Y& / Height(TTE_Tooltip_tWnd&[TTE_Tooltip_aktnum&])
Else
X! = MousePosInWnd#.X&
Y! = MousePosInWnd#.Y&
EndIf
Ifnot @Between(X!, TTE_Tooltip_xpos![TTE_Tooltip_aktnum&], TTE_Tooltip_xpos![TTE_Tooltip_aktnum&] + TTE_Tooltip_xsz![TTE_Tooltip_aktnum&], Y!, TTE_Tooltip_ypos![TTE_Tooltip_aktnum&], TTE_Tooltip_ypos![TTE_Tooltip_aktnum&] + TTE_Tooltip_ysz![TTE_Tooltip_aktnum&]) And (@GetActiveWindow() = TTE_Tooltip_tWnd&[TTE_Tooltip_aktnum&])
TTE_Tooltip_aktnum& = -1
TTE_ToolTipRoutine
Else
TTE_ShowTooltip MousePos#.X& + 20, MousePos#.Y& + 20, TTE_Tooltip_text$[TTE_Tooltip_aktnum&]
'@SetActiveWindow(Tooltip_tWnd&[&loop])
EndIf
Else
WhileLoop 0, @SizeOf(TTE_Tooltip_text$[]) - 1
If (TTE_Tooltip_text$[&loop] <> "") And (@GetActiveWindow() = TTE_Tooltip_tWnd&[&loop]) And (TTE_Tooltip_tWnd&[&loop] <> -1)
MousePosInWnd# = MousePos#
~ScreenToClient(TTE_Tooltip_tWnd&[&loop], MousePosInWnd#)
If TTE_Tooltip_isRelative%[&loop]
X! = MousePosInWnd#.X& / Width(TTE_Tooltip_tWnd&[&loop])
Y! = MousePosInWnd#.Y& / Height(TTE_Tooltip_tWnd&[&loop])
Else
X! = MousePosInWnd#.X&
Y! = MousePosInWnd#.Y&
EndIf
If @Between(X!, TTE_Tooltip_xpos![&loop], TTE_Tooltip_xpos![&loop] + TTE_Tooltip_xsz![&loop], Y!, TTE_Tooltip_ypos![&loop], TTE_Tooltip_ypos![&loop] + TTE_Tooltip_ysz![&loop])
TTE_Tooltip_aktnum& = &loop
'@MessageBox(@Str$(Tooltip_aktnum&), "", 0)
BREAK
EndIf
EndIf
'@MessageBox(@Str$(Tooltip_aktnum&), "", 0)
EndWhile
If TTE_Tooltip_aktnum& = -1
TTE_HideTooltip
EndIf
EndIf
Dispose MousePos#
Dispose MousePosInWnd#
ENDPROC
Proc TTE_RegisterTooltip
Parameters tWnd&, X!, Y!, SZX!, SZY!, isRelative%, Group&, Text$
Declare freePos&
freePos& = -1
WhileLoop 0, @SizeOf(TTE_Tooltip_text$[]) - 1
If (TTE_Tooltip_text$[&loop] = "") And (TTE_Tooltip_tWnd&[&loop] = -1)
freePos& = &loop
BREAK
EndIf
EndWhile
If freePos& = -1
freePos& = @SizeOf(TTE_Tooltip_tWnd&[])
EndIf
'@MessageBox(@Str$(freePos&), "", 0)
TTE_Tooltip_tWnd&[freePos&] = tWnd&
TTE_Tooltip_xpos![freePos&] = X!
TTE_Tooltip_ypos![freePos&] = Y!
TTE_Tooltip_xsz![freePos&] = SZX!
TTE_Tooltip_ysz![freePos&] = SZY!
TTE_Tooltip_isRelative%[freePos&] = isRelative%
TTE_Tooltip_grp&[freePos&] = Group&
TTE_Tooltip_text$[freePos&] = Text$
'@MessageBox(@Str$(X!) + " " + @Str$(Y!) + " - " + @Str$(SZX!) + " " + @Str$(SZY!) + " = " + Text$, "", 0)
Return freePos&
ENDPROC
Proc TTE_UnregisterTooltip
Parameters Num&, Grp&
If Num& <> -1
TTE_Tooltip_text$[Num&] = ""
TTE_Tooltip_tWnd&[Num&] = -1
Else
WhileLoop 0, @SizeOf(TTE_Tooltip_tWnd&[]) - 1
If TTE_Tooltip_grp&[&loop] = Grp&
TTE_Tooltip_text$[&loop] = ""
TTE_Tooltip_tWnd&[&loop] = -1
EndIf
EndWhile
EndIf
ENDPROC
Proc TTE_GetNewTooltipGroupID
Inc TTE_Tooltip_aktmaxgrp&
Return TTE_Tooltip_aktmaxgrp&
ENDPROC
Proc TTE_SetTooltipFont
Parameters F$
TTE_DisplayFont$ = F$
ENDPROC
Proc TTE_destroyWnd
@DestroyWindow(TTE_Tooltip_hWnd&)
ENDPROC
and here small example-Program: $H windows.ph
$I TooltipsEverywhere.Inc
CLS
TTE_SetTooltipFont "Consolas"
TTE_RegisterTooltip %hwnd, 0, 0, .5, .5, 1, -1, "Links oben"
TTE_RegisterTooltip %hwnd, .5, 0, .5, .5, 1, -1, "Rechts oben"
TTE_RegisterTooltip %hwnd, 0, .5, .5, .5, 1, -1, "Links unten"
TTE_RegisterTooltip %hwnd, .5, .5, .5, .5, 1, -1, "Rechts unten"
User Messages 16
WhileNot %umessage = 16
WaitInput 10
TTE_ToolTipRoutine
EndWhile
TTE_destroyWnd
has one once a Tooltip prepares, becomes this automatically displayed and ausgeblendet. with relativen Coordinates becomes the Tooltip with of/ one Änderung the Fenstergröße automatically new positioniert. one need itself means not any more therefore To concern. TTE_ToolTipRoutine must simply regularly (z.B. in 20msec-intervals) called go. These routine checks, which Tooltip active is, draw it etc. TTE_RegisterTooltip tWnd, X, Y, SZX, SZY, isRelative, Group, Text prepares a Tooltip on window tWnd on position X, Y with Size SZX, SZY. If isRelative = 1, go The Coordinates as relatively respected, so one there instead of Pixeln values between 0 and 1 types. 1 means "volle wide/Höhe the Fensters", between 0 and 1 are arbitrary Abstufungen possible. with "Group" can a groups-ID indicate, circa several Tooltips to a group zusammenzufassen. If one no group wants, can -1 indicate. Text is the Tooltip-Text, therein are Zeilenumbrüche with \n possible. Returnwert: lever the erstellten Tooltips. TTE_UnregisterTooltip H, Group deletes whom Tooltip with the lever H. is H = -1, go any Tooltips the group with the ID Group deleted. TTE_GetNewTooltipGroupID Created a new groups-ID, The to that summarize of Tooltips used go can. Returnwert: groups-ID TTE_SetTooltipFont s setting The type, The for Tooltips uses go should. must to the first process of TTE_ToolTipRoutine tuned go! TTE_destroyWnd destroy the Tooltip-Window. must after closing the Program carryed out go, thereafter must TTE_ToolTipRoutine not any more carryed out go! The Include must at the beginning the program eingebunden go. Also needed tappt im dunkeln windows.ph. Greeting Jonathan |
|