PowerBASIC Forums
  Programming
  To William Burns (Page 1)

Post New Topic  Post A Reply
profile | register | preferences | faq | search

UBBFriend: Email This Page to Someone!
This topic is 2 pages long:   1  2 
next newest topic | next oldest topic
Author Topic:   To William Burns
Bob Scott
Member
posted November 27, 2004 02:33 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
William,

This post is relative to the ToolTips code.

I like your ToolTips very much but I am currently experiencing a problem. If a ToolTip is repeatedly changed then the prior ToolTip does not seem to be removed and an increasing memory usage exists. I have never seen the problem before because I almost never revise the ToolTip. Am I blowing smoke again?

The following sample program will demonstrate what I am seeing if memory use is monitored using Task Manager or equivalent. If the modified ToolTips2.inc file is not used then the RemoveToolTip command must be commented out.

Thanks for your help.

~Bob
[update] code was modified to add two more controls for test purposes and also to include
the modified ToolTips2.inc file located at the ToolTips link. [/update]

#COMPILE EXE
#DIM ALL

#INCLUDE "win32api.inc"
#INCLUDE "ToolTips.inc" ' Use for initial tests
' #INCLUDE "ToolTips2.inc" ' Use for modified version tests


%Message = 1001
%Button1 = 1002
%Button2 = 1003

DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG

'----------------------------------------------------------------
SUB ShowToolTips(hDlg AS DWORD)

LOCAL i AS LONG, sMsg AS STRING
STATIC Pass AS LONG, Busy AS LONG
IF ISTRUE Busy THEN EXIT SUB
Busy = %TRUE

IF Pass => 100 THEN Pass = 0 ' Limits size of ToolTip text

' Make a long Message
FOR i = 1 TO 4
sMsg = sMsg & "This is pass #" & FORMAT$(Pass, "###,###") & $CRLF
NEXT

SetToolTip hDlg, %Message, sMsg

INCR Pass

Busy = %FALSE

END SUB
'----------------------------------------------------------------
FUNCTION PBMAIN()
ShowDIALOG1 %HWND_DESKTOP
END FUNCTION
'----------------------------------------------------------------
CALLBACK FUNCTION ShowDIALOG1Proc()

STATIC hTimer1 AS DWORD

SELECT CASE CBMSG
CASE %WM_INITDIALOG
' Create a timer event every 100 mSec
hTimer1 = SetTimer(CBHNDL, 1, 100, BYVAL %NULL)

SetToolTip CBHNDL, 0, "This is the Window"
SetToolTip CBHNDL, %Button1, "This is button1"
SetToolTip CBHNDL, %Button2, "This is button2"

CASE %WM_Timer
ShowToolTips CBHNDL

CASE %WM_DESTROY
' Destroy the timer
IF hTimer1 THEN KillTimer CBHNDL, 1

CASE %WM_COMMAND
SELECT CASE CBCTL
CASE %Button1
IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
' RemoveToolTip CBHNDL, 0 ' Comment out if not using
END IF ' ToolTips2.INC

CASE %Button2
IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
SetToolTip CBHNDL, 0, "This is the Window"
END IF
END SELECT

END SELECT

END FUNCTION
'----------------------------------------------------------------
' ** Dialogs **
'----------------------------------------------------------------
FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
LOCAL lRslt AS LONG

LOCAL hDlg AS DWORD


DIALOG NEW hParent, "Tool Tips Test", , , _
150, 150, %WS_POPUP OR %WS_BORDER OR %WS_DLGFRAME OR _
%WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN OR %WS_SYSMENU, TO hDlg

CONTROL ADD LABEL, hDlg, %Message, $CRLF & $CRLF & $CRLF & _
" Place mouse here to see Tool Tip", 5, 5, 140, 120, _
%WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %SS_NOTIFY, _
%WS_EX_LEFT OR %WS_EX_LTRREADING
CONTROL SET COLOR hDlg, %Message, -1, %White

CONTROL ADD BUTTON, hDlg, %Button1, "Button1", 20,130, 40, 15
CONTROL ADD BUTTON, hDlg, %Button2, "Button2", 90,130, 40, 15


DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc

END FUNCTION


------------------


[This message has been edited by Bob Scott (edited November 30, 2004).]

IP: Logged

Pat Logan
Member
posted November 27, 2004 07:32 PM     Click Here to See the Profile for Pat Logan     Edit/Delete Message   Reply w/Quote
Bob, have no clue about Williams code, but . . .
you need to delete existing entry text before adding new text.
' SendMessage hToolTip, %TTM_DELTOOL, 0, BYVAL VARPTR(TT)
' SendMessage hToolTip, %TTM_ADDTOOL, 0, BYVAL VARPTR(TT)
Thanks,
P.

------------------

IP: Logged

Bob Scott
Member
posted November 28, 2004 03:16 AM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
It appears that %TTM_DELTOOL & %TTM_ADDTOOL are not proper for what is required in my application. In fact, I have never seen a case where the %TTM_DELTOOL message is triggered. It appears that once the ToolTip has been added, that %TTM_UPDATETIPTEXT should be used similar to the following:

IF ISFALSE Update THEN
FUNCTION = SendMessage(hWnd_ToolTip, _
%TTM_ADDTOOL, 0, BYVAL VARPTR(TI))
ELSE
FUNCTION = SendMessage(hWnd_ToolTip, _
%TTM_UPDATETIPTEXT, 0, BYVAL VARPTR(TI))
END IF


~Bob

------------------

IP: Logged

Bob Scott
Member
posted November 28, 2004 01:29 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
Deleted

[This message has been edited by Bob Scott (edited November 30, 2004).]

IP: Logged

Bob Scott
Member
posted November 29, 2004 01:20 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
Deleted

[This message has been edited by Bob Scott (edited November 30, 2004).]

IP: Logged

Bob Scott
Member
posted November 30, 2004 04:31 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
I have modified William Burns ToolTips code to inhibit excessive memory use when the ToolTip Text is continually updated. What I have programmed is as follows:

1. Get Last ToolTip Text.
2. If Last ToolTip Text is a NULL then Add the ToolTip.
3. If the Last ToolTip Text is not a NULL but is different than the new ToolTip Text then Update the ToolTip Text.

Also,
4. I have added a separate function to the INCLUDE file:
RemoveToolTip hDlg. CtlID

~Bob

------------------

IP: Logged

Gösta H. Lovgren-2
Member
posted February 09, 2006 01:29 PM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
ToolTips is a great addition to the PB toolchest. However
I can't figure out how to turn them on/off. There is no
RemoveToolTip function in the include file.

------------------
Thx............Gösta
[EMAIL]Gosta AT SwedesDock.com[/EMAIL]
http://www.SwedesDock.com
http://www.PondersBible.com

IP: Logged

Bob Scott
Member
posted February 09, 2006 01:49 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by Gösta H. Lovgren-2:
I can't figure out how to turn them on/off. There is no
RemoveToolTip function in the include file.


Gösta,

If you use the ToolTips2.inc file, there is a RemoveToolTip function. Make sure you get the ToolTips2.inc file.

The command format is: RemoveToolTip hDlg, CtlID

Regards,

~Bob
----------------------
Composed with EZ-Post!

------------------

[This message has been edited by Bob Scott (edited February 19, 2006).]

IP: Logged

Gösta H. Lovgren-2
Member
posted February 10, 2006 10:16 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
quote:
Originally posted by Bob Scott:
[/b]


Bob,

The file I have:
' ToolTips.inc by William Burns Last revised on 9/25/04
and the file is called ToolTips2.Inc but it apparently
is the wrong one. I just plugged in the right one (hopefully)
and will let you know if it works for me.

Thx

------------------
Thx............Gösta
[EMAIL]Gosta AT SwedesDock.com[/EMAIL]
http://www.SwedesDock.com
http://www.PondersBible.com

[This message has been edited by Gösta H. Lovgren-2 (edited February 10, 2006).]

IP: Logged

Gösta H. Lovgren-2
Member
posted February 10, 2006 10:49 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Works fine now Bob. Thanks. I just had the wrong ToolTips.Inc.

------------------
Thx............Gösta
[EMAIL]Gosta AT SwedesDock.com[/EMAIL]
http://www.SwedesDock.com
http://www.PondersBible.com
Newby Tips http://www.swedesdock.com/powerbasic/pb_shortcuts.html

IP: Logged

Michael Mattias
Member
posted February 16, 2006 09:38 AM     Click Here to See the Profile for Michael Mattias     Edit/Delete Message   Reply w/Quote
I ran into an error in that file just the other day....

When style of the tooltip is being created based in the level of common controls available, the styles are inconsistent.

Whith "old" common controls, the style is....


iStyle = %TTS_NOPREFIX 'default in case common control ver is too old

If balloons are available, the style is set to:


iStyle = %TTS_ALWAYSTIP Or %TTS_BALLOON

For consistency when balloons are available the style should be


iStyle = %TTS_ALWAYSTIP Or %TTS_BALLOON OR %TTS_NOPREFIX
'****or****
iStyle = iStyle OR %TTS_ALWAYSTIP OR %TTS_BALLOON

(Yup, I created some tooltip text containing ampersands this past week).

MCM

[This message has been edited by Michael Mattias (edited February 16, 2006).]

IP: Logged

Bob Scott
Member
posted February 16, 2006 12:36 PM     Click Here to See the Profile for Bob Scott     Edit/Delete Message   Reply w/Quote
quote:
I ran into an error in that file just the other day....

Michael,

Thanks very much for the "Tip" . I really appreciate the way you feedback required changes and explain them. Thank you very much!!!

ToolTips2.inc has been updated to the required change.

Best Regards,

~Bob
----------------------
Composed with EZ-Post!

------------------

IP: Logged

Gösta H. Lovgren-2
Member
posted February 23, 2006 08:29 PM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Bob,

After I upgraded to the latest TT2, I ran into a funny thing. Whenever a TT
was tripped it closed the Dialog it is in. The original TT2 worked
fine. This is in an app I am now developing so I don't know if TT2
is the problem or it's in my code somewhere. And I overwrote the
original TT2 so I can't try that now.

I tried the original TT (William's version) and it works fine
EXCEPT it doesn't recognize $CrLf's (multi line tips). It just
puts a square (unrecognizable character) when a CR or LF is.

Would you still have a copy of the original TT2 so I could try
that to see if the problem is in TT2 or in my code?


Working on the solution of a problem, it always helps if you know the answer.

------------------
Thx............Gösta
[EMAIL]Gosta AT SwedesDock.com[/EMAIL]
http://www.SwedesDock.com
http://www.PondersBible.com
Newby Tips http://www.swedesdock.com/powerbasic/pb_shortcuts.html

[This message has been edited by Gösta H. Lovgren-2 (edited February 23, 2006).]

IP: Logged

Gösta H. Lovgren-2
Member
posted February 25, 2006 09:17 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
Found the problem I was having with ToolTips2. I am using several Dialogs.
It appears that whatever Dialog is called first is the one the TT's
work in.

When a TT is summoned in the next/second dialog it may cause an error
(GPF?) and cause the dialog to close.

Just found this, so may be more at play here.

Apparently (so far) TT1 (Wm Burns original) doesn't have the problem BUT
it doesn't recognize $CrLf's.


_______Wagner's music is better than it sounds. - Twain__________


[This message has been edited by Gösta H. Lovgren-2 (edited February 25, 2006).]

IP: Logged

Gösta H. Lovgren-2
Member
posted February 25, 2006 10:35 AM     Click Here to See the Profile for Gösta H. Lovgren-2     Edit/Delete Message   Reply w/Quote
UPDATE ALERT UPDATE ALERT UPDATE ALERT

DISREGARD ALL PREVIOUS COMPLAINTS {STOP}

BOZO PROGRAMMER LOOSE ON FORUM! {STOP}

I was creating a "child" dialog with %HWND_DESKTOP instead of
the handle of the parent dialog. ToolTip2s works fine now.

What I often do is call a child dialog from PB Main before the
main dialog is called while programming. (Saves a few clicks on
each run.)

Then when I remmed the early call to run the full program, that's
when I had the TT problem.


______________When in doubt, Burn the manual... _________________

------------------
Thx............Gösta
[EMAIL]Gosta AT SwedesDock.com[/EMAIL]
http://www.SwedesDock.com
http://www.PondersBible.com
Newby Tips http://www.swedesdock.com/powerbasic/pb_shortcuts.html

IP: Logged


This topic is 2 pages long:   1  2 

All times are EasternTime (US)

next newest topic | next oldest topic

Administrative Options: Close Topic | Archive/Move | Delete Topic
Post New Topic  Post A Reply
Hop to:

Contact Us | PowerBASIC BASIC Compilers

Copyright © 1999-2005 PowerBASIC, Inc. All Rights Reserved.


Ultimate Bulletin Board 5.45c