| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Strange problem with hook |
Hello,
I'm trying to create a tool-tip that is actually an image loaded from
a jpg file. It works perfectly when I am running the program from
VB6, but when I compile and run the executable, the tool-tips no
longer appear.
Here is the code for the tool tip.
Here is where I create a tool tip window and assign the tool tip
object and the objects owner.
' Add the Custom ToolTip to the specified object
Public Sub AddCustomToolTip(ObjectHwnd As Long, ImagePath As String,
Ownerhwnd As Long)
Dim TI As TOOLINFO
Dim dwStyle As Long
Dim htip As Long
' A tooltip control with the TTS_ALWAYSTIP style appears when the
cursor is
' on a tool, regardless of whether the tooltip control's owner
window is active
' or inactive. Without this style, the tooltip control appears
when the tool's
' owner window is active, but not when it is inactive.
htip = CreateWindowEx(0&, "tooltips_class32", "", 0, _
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _
Ownerhwnd, 0&, App.hInstance, 0&)
TI.cbSize = Len(TI)
TI.uFlags = TTF_IDISHWND + TTF_SUBCLASS
TI.hWnd = ObjectHwnd
TI.uId = ObjectHwnd
TI.lpszText = ImagePath
SendMessage htip, TTM_ADDTOOL, 0&, TI
' SubClass the tooltip window
ReDim Preserve WndProc(NumTips)
WndProc(NumTips).lPrevWndProc = GetWindowLong(htip, GWL_WNDPROC)
SetWindowLong htip, GWL_WNDPROC, AddressOf CustomTipProc
WndProc(NumTips).hWnd = htip
WndProc(NumTips).Ownerhwnd = Ownerhwnd
WndProc(NumTips).TI = TI
NumTips = NumTips + 1
' Remove Border from ToolTip
dwStyle = GetWindowLong(htip, GWL_STYLE)
dwStyle = dwStyle And (Not WS_BORDER)
SetWindowLong htip, GWL_STYLE, dwStyle
End Sub
Here is where I remove either all of the tool tips, or just those for
a particular owner.
Public Sub RemoveCustomToolTips(Optional Ownerhwnd As Long = -1)
Dim i As Integer
For i = 0 To NumTips - 1
If Ownerhwnd = -1 Or Ownerhwnd = WndProc(i).Ownerhwnd Then
SendMessage WndProc(i).hWnd, TTM_DELTOOL, 0&, WndProc(i).TI
SetWindowLong WndProc(i).hWnd, GWL_WNDPROC,
WndProc(i).lPrevWndProc
End If
Next i
End Sub
This is the custom proc that I call to paint the tooltip with an image
instead of the normal background and text.
Private Function CustomTipProc(ByVal hWnd As Long, ByVal uiMsg As
Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim ps As PAINTSTRUCT
Dim lpszText As String
Dim iTextLen As Integer
Dim rc As RECT
Dim i As Integer
Dim CurPos As POINTAPI
Select Case uiMsg
Case WM_PRINT
PostMessage hWnd, WM_PAINT, 0, 0
CustomTipProc = 1
Case WM_PAINT
' Get the Current Window Rect
GetWindowRect hWnd, rc
GetCursorPos CurPos
rc.Right = CurPos.X - iOffset + 6 + rc.Right - rc.Left
rc.Bottom = CurPos.Y + 20 + rc.Bottom - rc.Top
rc.Left = CurPos.X - iOffset + 6
rc.Top = CurPos.Y + 20
MoveWindow hWnd, rc.Left, rc.Top, rc.Right - rc.Left,
rc.Bottom - rc.Top, False
' prepare the DC for drawing
BeginPaint hWnd, ps
'Get Image Path
iTextLen = GetWindowTextLength(hWnd) + 1
lpszText = Space(iTextLen)
GetWindowText hWnd, lpszText, iTextLen
lpszText = Left(lpszText, Len(lpszText) - 1)
Set Pic = LoadPicture(lpszText)
mdc.hBitmap = Pic.Handle
rc.Right = rc.Left + Pic.Width
rc.Bottom = rc.Top + Pic.Height
' show the window before changing its size
' (work around the WM_PRINT problem/feature)
ShowWindow hWnd, SW_SHOWNA
' apply new size
MoveWindow hWnd, rc.Left, rc.Top, rc.Right - rc.Left,
rc.Bottom - rc.Top, True
SetBkMode ps.hDC, TRANSPARENT
BitBlt ps.hDC, 0, 0, Pic.Width, Pic.Height, mdc.hDC, 0, 0,
vbSrcCopy
' End Paint
EndPaint hWnd, ps
CustomTipProc = 0
Case Else
' Sends message to previous procedure
For i = 0 To NumTips - 1
If WndProc(i).hWnd = hWnd Then
CustomTipProc =
CallWindowProc(WndProc(i).lPrevWndProc, hWnd, uiMsg, _
wParam, lParam)
Exit For
End If
Next
End Select
End Function
The tooltips are being assigned from a custom usercontrol, which is
dropped onto another custom user control.
AddCustomToolTip UserControl.hWnd, App.Path & "\CardImages\fullsize\"
& mCard.BuildingName & ".jpg", UserControl.ContainerHwnd
Anyone out there that can help.....
I'm not holding my breath on this one though, it's a toughy.
Thanks in advance,
Mark
---
þ RIMEGate(tm)/RGXPost V1.14 at BBSWORLD * Info{at}bbsworld.com
---
* RIMEGate(tm)V10.2áÿ* RelayNet(tm) NNTP Gateway * MoonDog BBS
* RgateImp.MoonDog.BBS at 6/29/04 10:44:14 AM
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)SEEN-BY: 633/267 270 @PATH: 278/230 10/345 106/1 2000 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.