forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Lining up %tt and %rf controls
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Thu Jun 06, 2013 7:12 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Jun 07, 2013 7:10 am    Post subject: Reply with quote

Thanks. That's very helpful.
Back to top
View user's profile Send private message AIM Address
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Fri Jun 07, 2013 9:43 am    Post subject: Reply with quote

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
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 243
Location: Matlock, Derbyshire, UK

PostPosted: Fri Jun 07, 2013 11:25 am    Post subject: Reply with quote

Jalih -

I have to add that I'm seriously impressed!

- Steve
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Jun 07, 2013 3:55 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
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