April 27, 2024, 02:30:46 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Windows balloon tips ?

Started by paja, June 16, 2011, 03:14:05 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

paja

Here is screenshot of status I want - device with balloon tip.

Devices are like RNGBUTTONs. Device are offline and thus there are "?" instead of real x/y positions.
In the balloon tips I would like to show some more info about devices (erros for examples) connected over RS485 bus.
If will be for example error(s) then balloon tip will be show until error(s) will be out.







LarryMc

Okay, I'll ask one more time.
Are the yellow boxes in a fixed position on the screen?
How are the yellow boxes drawn ( and don't say like a RGNBUTTON)
   Are they images put there with the showimage command?
   Are they drawn with RECT command?
   Are they bitmaps in a STATIC control?

If you can't answer our simple questions I'm going to have to give up on trying to help you.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Just playing around before I go back to my help file chore.
I ripped off someones code and played with it until I got this.
Compile as a window.
It creates 10 tooltips for the main window; no controls.
Each tooltip appears in a different location.
They only appear when the mouse is in the client area.
If you click in the window they all disappear until the mouse moves out of the client area and then back.

I set up a timer to show/hide tooltips when I want to.

So:
tooltips without controls - check
multiple tooltips showing at one time - check
application control of were tooltips appear - check
application control of when tooltips appear - check

beep- making it so clicking on the window does not hide the tooltips.
But I think I'm done.
$INCLUDE "WindowsSDK.inc"
$INCLUDE "CommCtrl.inc"
INT WinOldProc
UINT hwndTooltip[10]
int px[10]
int py[10]
px[0]=5,35,65,95,125,155,185,215,245,275
py[0]=5,35,65,95,125,155,185,215,245,275
int z=0
WINDOW w1
OPENWINDOW w1,0,0,512,347,0x80C80080,0,"Tooltip",&w1_handler
Init()
starttimer w1,1000
WAITUNTIL w1=0
end

SUB w1_handler
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
SetWindowLong(w1.hwnd, GWL_WNDPROC, WinOldProc)
CLOSEWINDOW w1
CASE @IDCONTROL
case @idtimer
z++:if z>9 then z=0
select z
case 0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,0,0
case 1
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,0,0
case 2
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,0,0
case 3
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,0,0
case 4
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,0,0
case 5
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,0,0
case 6
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,0,0
case 7
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,0,0
case 8
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,0,0
case 9
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,0,0
endselect
    ENDSELECT
RETURN
ENDSUB

SUB MainProc(INT hWin, INT uMsg, INT wParam, INT lParam), INT
pointer pnmhdr : SETTYPE pnmhdr, NMHDR
SELECT uMsg
CASE WM_NOTIFY
pnmhdr = *<NMHDR> lParam
RETURN OnNotify(hWin, #pnmhdr.idFrom, #pnmhdr.code, #pnmhdr.hwndFrom, lParam)
ENDSELECT
RETURN CallWindowProc(WinOldProc, hWin, uMsg, wParam, lParam)
ENDSUB

SUB OnNotify(int hWin, int ctrlid, int code, int hwndCtrl, int lParam), INT
WINRECT rc
POINT pnt

int x
for x=0 to 9
if hwndCtrl = hwndTooltip[x] then breakfor
next x

if x>9 then return 0
SELECT code
CASE TTN_SHOW
GetClientRect(hWin, &rc)
pnt.x = rc.right
pnt.y = rc.bottom
ClientToScreen(hWin, &pnt)
MoveWindow(hwndTooltip[x], px[x]+pnt.x-rc.right, py[x]+pnt.y-rc.bottom, 200, 200, 0)
'MoveWindow(hwndTooltip[x], pa[x].x+pnt.x-200, pa[x].y +pnt.y-200, 200, 200, 0)  
RETURN 1
ENDSELECT

    RETURN 0
ENDSUB

SUB Init()
for x= 0 to 9
hwndTooltip[x] = ToolTipControl(w1, @TTS_ALWAYSTIP|@TTS_BALLOON, 0)
SENDMESSAGE hwndTooltip[x],TTM_SETDELAYTIME,TTDT_INITIAL,0
SENDMESSAGE hwndTooltip[x],TTM_ACTIVATE,0,0
ttAddTool hwndTooltip[x],@TTF_SUBCLASS|@TTF_IDISHWND,w1.hwnd,w1.hwnd,"Black"+str$(x)
next x
   WinOldProc = SetWindowLong(w1.hwnd, GWL_WNDPROC, &MainProc)
ENDSUB


LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

Added some color - the balloons change colors each cycle
$INCLUDE "WindowsSDK.inc"
$INCLUDE "CommCtrl.inc"
INT WinOldProc
UINT hwndTooltip[10]
int px[10]
int py[10]
px[0]=5,35,65,95,125,155,185,215,245,275
py[0]=5,35,65,95,125,155,185,215,245,275
int z=0,y=0
WINDOW w1
OPENWINDOW w1,0,0,512,347,0x80C80080,0,"Tooltip",&w1_handler
Init()
starttimer w1,1000
WAITUNTIL w1=0
end

SUB w1_handler
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
SetWindowLong(w1.hwnd, GWL_WNDPROC, WinOldProc)
CLOSEWINDOW w1
CASE @IDCONTROL
case @idtimer
z++
if z>9 then z=0
y++ :if y>2 then y=0
select y
case 0
clr=rgb(255,0,0)
case 1
clr=rgb(0,255,0)
case 2
clr=rgb(255,255,0)
endselect
select z
case 0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[0],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,0,0
case 1
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[6],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,0,0
case 2
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[1],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,0,0
case 3
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[8],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,0,0
case 4
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[3],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,0,0
case 5
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[9],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,0,0
case 6
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[5],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,0,0
case 7
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[2],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,0,0
case 8
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[7],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,0,0
case 9
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[4],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,0,0
endselect
    ENDSELECT
RETURN
ENDSUB

SUB MainProc(INT hWin, INT uMsg, INT wParam, INT lParam), INT
pointer pnmhdr : SETTYPE pnmhdr, NMHDR
SELECT uMsg
CASE WM_NOTIFY
pnmhdr = *<NMHDR> lParam
RETURN OnNotify(hWin, #pnmhdr.idFrom, #pnmhdr.code, #pnmhdr.hwndFrom, lParam)
ENDSELECT
RETURN CallWindowProc(WinOldProc, hWin, uMsg, wParam, lParam)
ENDSUB

SUB OnNotify(int hWin, int ctrlid, int code, int hwndCtrl, int lParam), INT
WINRECT rc
POINT pnt

int x
for x=0 to 9
if hwndCtrl = hwndTooltip[x] then breakfor
next x

if x>9 then return 0
SELECT code
CASE TTN_SHOW
GetClientRect(hWin, &rc)
pnt.x = rc.right
pnt.y = rc.bottom
ClientToScreen(hWin, &pnt)
MoveWindow(hwndTooltip[x], px[x]+pnt.x-rc.right, py[x]+pnt.y-rc.bottom, 200, 200, 0)
'MoveWindow(hwndTooltip[x], pa[x].x+pnt.x-200, pa[x].y +pnt.y-200, 200, 200, 0)  
RETURN 1
ENDSELECT

    RETURN 0
ENDSUB

SUB Init()
for x= 0 to 9
hwndTooltip[x] = ToolTipControl(w1, @TTS_ALWAYSTIP|@TTS_BALLOON, 0)
SENDMESSAGE hwndTooltip[x],TTM_SETDELAYTIME,TTDT_INITIAL,0
SENDMESSAGE hwndTooltip[x],TTM_ACTIVATE,0,0
ttAddTool hwndTooltip[x],@TTF_SUBCLASS|@TTF_IDISHWND,w1.hwnd,w1.hwnd,"Black"+str$(x)
next x
   WinOldProc = SetWindowLong(w1.hwnd, GWL_WNDPROC, &MainProc)
ENDSUB



LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

paja

Very nice ! Thanks. And I have two small questons:

1) is possible to set dimensions of balloon tip ?
2) is possible to change the font for ballloon tips



LarryMc

Quote from: paja on June 17, 2011, 05:27:59 PM
Very nice ! Thanks. And I have two small questons:

1) is possible to set dimensions of balloon tip ?
2) is possible to change the font for ballloon tips



1) It automatically adjust to the size of the displayed text. You can set a max width which is how you make it do multiline, as I understand it.
2) there is no simple message to change font that I am aware of.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

paja

I asked for font changing because I want to use font with special characters - for example like pictograms.
See font "GuIFx_v2_Transports.ttf".

Paja

LarryMc

did a little more reading and it appears that tooltips does respond to the setfont API(not to be confused with IWBasic's SETFONT command.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

paja

The font change solved !

Thanks LarryMc !



$INCLUDE "WindowsSDK.inc"
$INCLUDE "CommCtrl.inc"

Def hfont:UINT

INT WinOldProc
UINT hwndTooltip[10]
int px[10]
int py[10]
px[0]=5,35,65,95,125,155,185,215,245,275
py[0]=5,35,65,95,125,155,185,215,245,275
int z=0,y=0
WINDOW w1
OPENWINDOW w1,0,0,512,347,0x80C80080,0,"Tooltip",&w1_handler
hfont = CreateFontA(15,0,0,0,0,0,0,0,1,0,0,0,2,"Arial")
Init()

starttimer w1,1000
WAITUNTIL w1=0
end

SUB w1_handler
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW w1
CASE @IDCLOSEWINDOW
SetWindowLong(w1.hwnd, GWL_WNDPROC, WinOldProc)
CLOSEWINDOW w1
CASE @IDCONTROL
case @idtimer
z++
if z > 9 then z = 0
y++ :if y > 2 then y = 0
select y
case 0
clr=rgb(255,0,0)
case 1
clr=rgb(0,255,0)
case 2
clr=rgb(25,2,250)
endselect
select z
case 0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[0],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[0],TTM_SETTIPTEXTCOLOR,rgb(255,0,0),0
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,0,0
case 1
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[6],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,0,0
case 2
SENDMESSAGE hwndTooltip[1],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[1],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,0,0
case 3
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[8],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[0],TTM_ACTIVATE,0,0
case 4
SENDMESSAGE hwndTooltip[3],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[3],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,0,0
case 5
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[9],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[6],TTM_ACTIVATE,0,0
case 6
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[5],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[8],TTM_ACTIVATE,0,0
case 7
SENDMESSAGE hwndTooltip[2],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[2],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,0,0
case 8
SENDMESSAGE hwndTooltip[7],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[7],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[9],TTM_ACTIVATE,0,0
case 9
SENDMESSAGE hwndTooltip[4],TTM_ACTIVATE,1,0
SENDMESSAGE hwndTooltip[4],TTM_SETTIPBKCOLOR,clr,0
SENDMESSAGE hwndTooltip[5],TTM_ACTIVATE,0,0
endselect
    ENDSELECT
RETURN
ENDSUB

SUB MainProc(INT hWin, INT uMsg, INT wParam, INT lParam), INT
pointer pnmhdr : SETTYPE pnmhdr, NMHDR
SELECT uMsg
CASE WM_NOTIFY
pnmhdr = *<NMHDR> lParam
RETURN OnNotify(hWin, #pnmhdr.idFrom, #pnmhdr.code, #pnmhdr.hwndFrom, lParam)
ENDSELECT
RETURN CallWindowProc(WinOldProc, hWin, uMsg, wParam, lParam)
ENDSUB

SUB OnNotify(int hWin, int ctrlid, int code, int hwndCtrl, int lParam), INT
WINRECT rc
POINT pnt

int x
for x=0 to 9
if hwndCtrl = hwndTooltip[x] then breakfor
next x

if x>9 then return 0
SELECT code
CASE TTN_SHOW
GetClientRect(hWin, &rc)
pnt.x = rc.right
pnt.y = rc.bottom
ClientToScreen(hWin, &pnt)
MoveWindow(hwndTooltip[x], px[x]+pnt.x-rc.right, py[x]+pnt.y-rc.bottom, 200, 200, 0)
'MoveWindow(hwndTooltip[x], pa[x].x+pnt.x-200, pa[x].y +pnt.y-200, 200, 200, 0)    
RETURN 1
ENDSELECT

    RETURN 0
ENDSUB

SUB Init()
for x= 0 to 9
hwndTooltip[x] = ToolTipControl(w1, @TTS_ALWAYSTIP|@TTS_BALLOON,0)
SENDMESSAGE hwndTooltip[x],TTM_SETDELAYTIME,TTDT_INITIAL,0
SENDMESSAGE hwndTooltip[x],TTM_ACTIVATE,0,0
ttAddTool hwndTooltip[x],@TTF_SUBCLASS|@TTF_IDISHWND,w1.hwnd,w1.hwnd,"Black"+str$(x)

SendMessage(hwndTooltip[x],WM_SETFONT,hfont,0)

next x
   WinOldProc = SetWindowLong(w1.hwnd, GWL_WNDPROC, &MainProc)
ENDSUB

paja

June 19, 2011, 04:57:22 AM #34 Last Edit: June 19, 2011, 05:33:26 AM by paja
Hi,

I found two problems:

1) the time for show balloon tips is only short time
2) the balloon tips are shown only when mouse is in defined window and on single and doubleclick are balloon tips
disabled

I need use balloon tips independent on mouse move and positions.

Paja

LarryMc

June 19, 2011, 08:57:39 AM #35 Last Edit: June 19, 2011, 09:06:09 AM by LarryMc
Quote from: paja on June 19, 2011, 04:57:22 AM
Hi,

I found two problems:

1) the time for show balloon tips is only short time
2) the balloon tips are shown only when mouse is in defined window and on single and doubleclick are balloon tips
disabled

I need use balloon tips independent on mouse move and positions.

Paja

1) that can be adjusted by sending the proper message
2) you could have found that out by reading my post on the 17th where I first posted the code. I listed several conditions I met and indicated that condition was met with the word check. What you 'discovered' was indicated by:
Quotebeep- making it so clicking on the window does not hide the tooltips.
'beep' meaning the condition wasn't met.  I should have been more clear.

Based upon what you have stated about your needs and what I have found playing with tooltips, I suggest you do the following:
1. For each location you want a balloon you create a captionless window and use the @hidden flag when you create it.
2. In your code that controls the moving of the device on the screen you move this hidden window along with it.
3. When you need the window to show you use the SHOWWINDOW command to show the window (after you have set the font, colors, and text to what ever you require)
4. When you no longer need it to show you simply hide it until the next time you need it.
The simple way is to just use a normal rectangle window.  If you insist on it looking like a bubble then you can use the @NOAUTODRAW flag on the window and draw it to look like you want (like a RGNB?UTTON ;) in the processing the @IDPAINT message for the window) (That's where Graham's posted code could be of some help).

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library