|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Thu Jun 06, 2013 7:12 pm Post subject: |
|
|
I made some small modifications into my previous sample and got rid of GetInstance() function. Updated package available here.
MiniBasic source for the tooltip.dll:
Code: |
##ifndef WIN32
##define WIN32
##endif
##ifdef WIN32
##define WIN32_LEAN_AND_MEAN
##endif
##include "winsdk\windef.mbi"
##include "winsdk\winuser.mbi"
##include "winsdk\winbase.mbi"
##include "winsdk\Commctrl.mbi"
##NOCONSOLE
##MAKEDLL
export ToolTip
func ToolTip(HWND hwnd, string title, string tiptext)
TOOLINFO tif
HINSTANCE g_hInst
HWND chwnd
g_hInst = GetWindowLongA(hwnd,GWL_HINSTANCE)
tif.cbSize = len(tif)
tif.uFlags = TTF_SUBCLASS|TTF_TRANSPARENT
tif.hWnd = hwnd
tif.uId = 99
tif.hinst = g_hInst
tif.lpszText = tiptext
chwnd = CreateWindowEx(WS_EX_TOPMOST,"tooltips_class32",NULL,_
WS_POPUP |TTS_NOPREFIX|TTS_ALWAYSTIP,_
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,_
hwnd,NULL,g_hInst,NULL)
SetWindowPos(chwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE)
GetClientRect(hwnd,tif._rect)
SendMessageA(chwnd,TTM_SETTIPBKCOLOR,RGB(255,255,128),0)
SendMessageA(chwnd,TTM_SETTIPTEXTCOLOR,RGB(0,0,255),0)
SendMessageA(chwnd,TTM_SETTITLE,TTI_INFO,&title)
SendMessageA(chwnd,TTM_ADDTOOL,0,&tif)
endf
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Jun 07, 2013 7:10 am Post subject: |
|
|
Thanks. That's very helpful. |
|
Back to top |
|
|
jalih
Joined: 30 Jul 2012 Posts: 196
|
Posted: Fri Jun 07, 2013 9:43 am Post subject: |
|
|
Another small update...
Added support for balloon tooltips and user specified icon.
Updated files available here
MiniBASIC source for the updated DLL:
Code: |
##ifndef WIN32
##define WIN32
##endif
##ifdef WIN32
##define WIN32_LEAN_AND_MEAN
##endif
##include "winsdk\windef.mbi"
##include "winsdk\winuser.mbi"
##include "winsdk\winbase.mbi"
##include "winsdk\Commctrl.mbi"
##NOCONSOLE
##MAKEDLL
const NORMAL = 0
const BALLOON = 1
export ToolTip
func ToolTip(HWND hwnd, uint tiptype, HICON icon, string title, string tiptext)
TOOLINFO tif
HINSTANCE g_hInst
HWND chwnd
uint tipstyle
g_hInst = GetWindowLongA(hwnd,GWL_HINSTANCE)
tif.cbSize = len(tif)
tif.uFlags = TTF_SUBCLASS|TTF_TRANSPARENT
tif.hWnd = hwnd
tif.uId = 99
tif.hinst = g_hInst
tif.lpszText = tiptext
tipstyle = WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP
if tiptype = BALLOON then tipstyle |= TTS_BALLOON
chwnd = CreateWindowEx(WS_EX_TOPMOST,"tooltips_class32",NULL,tipstyle,_
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,_
hwnd,NULL,g_hInst,NULL)
SetWindowPos(chwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE)
GetClientRect(hwnd,tif._rect)
SendMessageA(chwnd,TTM_SETTIPBKCOLOR,RGB(255,255,128),0)
SendMessageA(chwnd,TTM_SETTIPTEXTCOLOR,RGB(0,0,255),0)
SendMessageA(chwnd,TTM_SETTITLE,icon,&title)
SendMessageA(chwnd,TTM_ADDTOOL,0,&tif)
endf
|
|
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 248 Location: Matlock, Derbyshire, UK
|
Posted: Fri Jun 07, 2013 11:25 am Post subject: |
|
|
Jalih -
I have to add that I'm seriously impressed!
- Steve |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Jun 07, 2013 3:55 pm Post subject: |
|
|
I have added [balloon] to the options for %th (in fact it was already there but commented out).
Also the help text will be able to take the form:
"|*Title|Info"
Starts with a pipe symbol,
then * or ! or # (as in %si) for the info icon etc.
then the title
then another pipe
then the information. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|