|
Post by metro on Mar 31, 2018 5:49:33 GMT -5
'© Dennis McKinney 2002 'You may use this code freely in your own programs. 'This code may not be redistributed, published in whole or in part, 'posted to any group or bulletin board, nor placed on any web site 'without the authors permission.
NoMainWin
'TOOLINFO structure Struct ti, _ cbSize As long, _ uFlags As long, _ hwnd As long, _ uId As long, _ left As long, _ top As long, _ right As long, _ bottom As long, _ hinst As long, _ lpszText As ptr
ti.cbSize.struct = Len(ti.struct) ti.uFlags.struct = 17
WindowWidth = 300 WindowHeight = 200 UpperLeftX = Int((DisplayWidth - WindowWidth) / 2) UpperLeftY = Int((DisplayHeight - WindowHeight) / 2)
button #1.btn, "Red", [x], UL, 5, 5, 40, 25 button #1.btn2, "Blue", [x], UL, 50, 5, 40, 25 button #1.btn3, "Green", [x], UL, 95, 5, 40, 25 open "Easy Tooltips" for window as #1 print #1, "trapclose [quit]" hParent = hwnd(#1)
hTT = CreateTooltip(hParent) call AddTooltip hwnd(#1.btn),"Red",hTT call AddTooltip hwnd(#1.btn2),"Blue",hTT call AddTooltip hwnd(#1.btn3),"Green",hTT
wait
[quit] close #1 end
[x] wait
Function CreateTooltip(hParent) style=64 '0=standard box tooltip 64 = balloon tooltip CallDLL #user32, "CreateWindowExA",0 As long,"tooltips_class32" As ptr,_ 0 As long, style As long,_CW_USEDEFAULT As long,_CW_USEDEFAULT As long,_ _CW_USEDEFAULT As long,_CW_USEDEFAULT As long,hParent As Ulong,_ 0 As long,0 As long,0 As long,CreateTooltip As Ulong End Function
Sub AddTooltip hWnd, Text$, hTT ti.uId.struct = hWnd ti.lpszText.struct = Text$ CallDLL #user32, "SendMessageA",hTT As long,1028 As long, _ 0 As long,ti as ptr,ret As long End Sub
insert code here
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 8, 2018 9:34:24 GMT -5
I changed "Green" to Green$ and set Green$ ="--bla--bla--bla---" a single line works ok, I cannot get a multiline popup to work ! Data terminates after 1st crlf. How can you display a multiline popup?
|
|
|
Post by Brandon Parker on Apr 8, 2018 19:42:02 GMT -5
I changed "Green" to Green$ and set Green$ ="--bla--bla--bla---" a single line works ok, I cannot get a multiline popup to work ! Data terminates after 1st crlf. How can you display a multiline popup? When you add the text to the ToolTip you need to let the ToolTip Control know that the Tip being displayed is allowed to be a Multi-Line ToolTip. To do this you simply need to send the TTM_SETMAXIPWIDTH message to the ToolTip Control. The ToolTip Control will do all the heavy lifting; you can set a max length if desired and the ToolTip will wrap the text when the line reaches that point or you can insert a CR+LF [chr$(13)+chr(10)] where you want the line to wrap. Here's the link to the MSDN How to Implement Multiline TooltipsChange the Subroutine AddTootip to the one shown below and have fun!!! Sub AddTooltip hWnd, Text$, hTT, multiLine ti.uId.struct = hWnd ti.lpszText.struct = Text$ CallDLL #user32, "SendMessageA",hTT As long,1028 As long, _ 0 As long,ti as ptr,ret As long
TTM.SETMAXTIPWIDTH = 1048 CallDLL #user32, "SendMessageA", hTT As ulong, _ TTM.SETMAXTIPWIDTH As long, _ _NULL As long, _ ti As struct, _ AddTooltip As long
End Sub
Let us know if you need any further assistance... {:0) Brandon Parker
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 9, 2018 11:17:54 GMT -5
Thx for that ,, But I think I'm running out of memory, tried embedding about 29k of tooltip's and things stop working.....
Using this method can the tooltip info be retrieved from a file?
I'm currently using my own code to retrieve tip from file, then display tip in a graphic area
|
|
|
Post by Brandon Parker on Apr 9, 2018 23:06:21 GMT -5
What exactly are you trying to show as a ToolTip?
Just place the data you are pulling from the file into a string variable and send that variable as the ToolTip text. I concatenate strings from a PI Server and data evaluated by my main program at work all the time and use variables to do this.
{:0)
Brandon Parker
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 10, 2018 5:54:43 GMT -5
Got it working, I missed a capital letter. Its very slow on large displays, You get about 200 ms to view the display then it disappears.....
Is there any way to control the amount of time for viewing??
I'm displaying GRBL command buttons description of what they do, some descriptions are lengthy.
|
|
|
Post by Brandon Parker on Apr 10, 2018 7:50:39 GMT -5
Why of course there is.... You need to change the Delay Time for the ToolTip Control. This can be accomplished individually for each ToolTip when it is added so you could make the times different if you would like. To do this you need to send the ToolTip Control the TTM_SETDELAYTIME message with TTDT_AUTOPOP as the wParam while the lParam sets the time to delay in ms based on the LOWORD. MSDN TTM_SETDELAYTIME MessageI find that this tends to work well for my application... TTM.SETDELAYTIME = 1027 TTDT.AUTOPOP = 2 CallDLL #user32, "SendMessageA", hCreateToolTip As ulong, _ 'Handle to ToolTip TTM.SETDELAYTIME As long, _ 'Message to Send TTDT.AUTOPOP As long, _ 'lParam 32000 As ulong, _ 'wParam AddTooltip As long 'Return value not used
{:0) Brandon Parker
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 10, 2018 10:27:06 GMT -5
I tried this and other , I can't affect the timing .. I would like a 1-2 sec delay before popup , then 10-30 sec delay depending on Tip length. I tried changing the values, but seen little affect..
Sub AddTooltip hWnd, Text$, hTT, multiLine ti.uId.struct = hWnd ti.lpszText.struct = Text$ '----------------------------------------------------------------- TTM.SETDELAYTIME = 1027 TTDT.AUTOPOP = 2 CallDLL #user32, "SendMessageA", hCreateToolTip As ulong, _ 'Handle to ToolTip TTM.SETDELAYTIME As long, _ 'Message to Send TTDT.AUTOPOP As long, _ 'lParam 32000 As ulong, _ 'wParam AddTooltip As long 'Return value not used '------------------------------------------------------------------ CallDLL #user32, "SendMessageA",hTT As long,1028 As long, _ 0 As long,ti as ptr,ret As long '----------------------------------------------------------------- TTM.SETMAXTIPWIDTH =_WM_USER + 24 '1048 'multiline CallDLL #user32, "SendMessageA", hTT As ulong, _ TTM.SETMAXTIPWIDTH As long, _ _NULL As long, _ ti As struct, _ AddTooltip As long
End Sub
|
|
|
Post by Chris Iverson on Apr 10, 2018 11:04:10 GMT -5
You've copy-pasted the code straight in, and haven't adjusted it properly for your application.
The line hCreateToolTip As ulong needs to change to match what your program specifies as the handle to the tooltip.
In your case, it's hTT.
Change hCreateToolTip to hTT, and it should work.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 10, 2018 11:45:47 GMT -5
Changed to this and I see no difference still displays 5-6 seconds...
Sub AddTooltip hWnd, Text$, hTT, multiLine ti.uId.struct = hWnd ti.lpszText.struct = Text$ '----------------------------------------------------------------- TTM.SETDELAYTIME = 30000 '1027 TTDT.AUTOPOP = 30000 '2 CallDLL #user32, "SendMessageA", hTT As ulong, _ 'Handle to ToolTip TTM.SETDELAYTIME As long, _ 'Message to Send TTDT.AUTOPOP As long, _ 'lParam 32000 As ulong, _ 'wParam AddTooltip As long 'Return value not used '------------------------------------------------------------------ CallDLL #user32, "SendMessageA",hTT As long,1028 As long, _ 0 As long,ti as ptr,ret As long '----------------------------------------------------------------- TTM.SETMAXTIPWIDTH =_WM_USER + 24 '1048 'multiline CallDLL #user32, "SendMessageA", hTT As ulong, _ TTM.SETMAXTIPWIDTH As long, _ _NULL As long, _ ti As struct, _ AddTooltip As long
End Sub
|
|
|
Post by Chris Iverson on Apr 10, 2018 12:00:42 GMT -5
That's because the two values you changed, you shouldn't change. TTM_SETDELAYTIME is the constant message that gets sent that tells the tooltip you want to change one of it's timers. TTDT_AUTOPOP tells the tooltip you want to change how long it stays on the screen.
If you change those values, the tooltip won't think you're trying to change the timers, because you're not using the message for doing so anymore. (Windows messages are all numeric values; they're given constant names so WE know what they mean. TTM_SETDELAYTIME is the constant name; 1027 is the constant value. If you don't pass 1027 in to the function there, it doesn't know you're trying to change the timers.)
The ONLY value you change is the 32000. That specifies the amount, in milliseconds, that you want the tooltip to remain displayed. Change it to 5000, it should stay on screen for 5 seconds(5000 ms).
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 10, 2018 12:57:06 GMT -5
If I understand this ? TTM_SETDELAYTIME = 1027 says I want to set a timer TTDT_AUTOPOP = 2 says to change the display timer
The 32000 is the max timer value +1 [ seems like I found that 32000+ defaults to 5 seconds....] I set 20000 and get approx 20 seconds. Thanks.....
Now is there a way to control the mouse over time before popping up the tip ?
Where can I find these mystical windows codes ?
I read something mentioning InfoTips, but havn't researched yet, do they work the same ?
|
|
|
Post by Brandon Parker on Apr 10, 2018 13:25:30 GMT -5
You will find everything you need at the MSDN Tooltip Control Reference page. Unfortunately not all Windows Constants are included in Liberty BASIC, but a quick google search for say TTM_SETDELAYTIME should provide a quick value for you. Understanding API calls is paramount to getting them to work so spending some dedicated time to study how they work will go a long way. I'm not trying to be mean or sarcastic, but API calls are not always easy and they take time to get used to. Continue posting questions and studying them and you will find it gets easier and easier. {:0) Brandon Parker
|
|
|
Post by Chris Iverson on Apr 10, 2018 16:06:51 GMT -5
If I understand this ? TTM_SETDELAYTIME = 1027 says I want to set a timer TTDT_AUTOPOP = 2 says to change the display timer The 32000 is the max timer value +1 [ seems like I found that 32000+ defaults to 5 seconds....] I set 20000 and get approx 20 seconds. Thanks..... Now is there a way to control the mouse over time before popping up the tip ? Where can I find these mystical windows codes ? I read something mentioning InfoTips, but havn't researched yet, do they work the same ? The exact limit is 32,767 milliseconds. Sorry for not specifying that earlier. According to the documentation, the 4-byte LPARAM value is treated as two separate values: HIPARAM and LOPARAM, the high two-byte word and low two-byte word of the parameter. The HIPARAM part is ignored, and should be zero. The LOPARAM part is a limited range of 0-32767. Anything larger than that is truncated and quite possibly ignored. The MSDN website linked to above provides information on using all of that, but the intricacies of using the Win32 API can take a long time to pick up. Using the Win32 API directly, even in LB, requires knowledge of C/C++, as well as how multiple datatypes are handled internally. LB does a LOT of work under the hood for you, to make it FAR easier to program. However, if you start bypassing those layers, and calling the Win32 API directly, you no longer have LB assisting you in doing so.
|
|
xtal
Junior Member
Posts: 61
|
Post by xtal on Apr 10, 2018 18:12:32 GMT -5
I made a guess and thought I would try this to increase the hover time before displaying ToolTip , But it didn't work ... Can hover time be increased ?
'------------------------------------------------------------------------------------------------------------------- TTM.SETDELAYTIME = 1027 ' 0x403 = 1027 ==> SetTimeDelay ? TTDT.INITIAL = 3 ' 2 =====> Hover Time before popup? 3=hover ? CallDLL #user32, "SendMessageA", _ ' hTT As ulong, _ ' Handle to ToolTip TTM.SETDELAYTIME As long, _ ' Message to Send TTDT.INITIAL As long, _ ' lParam 5000 As ulong, _ ' wParam 1.5 sec (ms) AddTooltip As long ' Return value not used
|
|