|
0 registered members (),
15,606
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Tooltip
[Re: MMike]
#271441
06/13/09 07:31
06/13/09 07:31
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Not that " I" need it any more, but thanks. At least I now know where I was going wrong! I was half-right by trying to force 3DGS to use the "next" version of NOTIFYICONDATA, but I was actually trying to force it to use the next version beyond that, which is vista-specific, which I dont have!Heres a functional (XP tested) summary of all coding required, with a usage details at the bottom.
/////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
#define NIM_ADD 0x00
#define NIM_MODIFY 0x01
#define NIM_DELETE 0x02
#define NIF_MESSAGE 0x001
#define NIF_ICON 0x002
#define NIF_TIP 0x004
#define NIF_INFO 0x010
#define IMAGE_ICON 0x0001
#define LR_LOADFROMFILE 0x00010
#define LR_VGACOLOR 0x00080
#define LR_SHARED 0x08000
//
//
//
typedef struct NOTIFYICONDATA
{
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
long hIcon;
char szTip[128];
DWORD dwState;
DWORD dwStateMask;
char szInfo[256];
DWORD uTimeout;
char szInfoTitle[64];
DWORD dwInfoFlags;
}NOTIFYICONDATA;
//
//
NOTIFYICONDATA _nid;
//
BOOL __stdcall Shell_NotifyIcon(DWORD dwMessage, NOTIFYICONDATA* lpData);
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
BOOL ShowBalloonTip(char* msg, char* title, char* icon, var Timeout)
{
_nid.cbSize =sizeof(NOTIFYICONDATA);
_nid.hWnd = hWnd;
_nid.uID = -hWnd;
_nid.uFlags = NIF_ICON | NIF_TIP | NIF_INFO;
_nid.uTimeout = 10000;
_nid.dwInfoFlags = NIF_MESSAGE;
strcpy(_nid.szInfo, ""); if(msg) strcpy(_nid.szInfo, msg);
strcpy(_nid.szInfoTitle, ""); if(title) strcpy(_nid.szInfoTitle, title);
strcpy(_nid.szTip, ""); if(icon) strcpy(_nid.szTip, icon);
_nid.hIcon = (long)LoadImage(GetModuleHandle(NULL),"26.ico", IMAGE_ICON, 16, 16,
LR_SHARED | LR_LOADFROMFILE | LR_VGACOLOR);
Shell_NotifyIcon(NIM_ADD, &_nid);
wait(-Timeout);
Shell_NotifyIcon(NIM_DELETE, &_nid);
}
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
//
//
/* USAGE - ALL text parameters are optional, use NULL for unused text's
...
ShowBalloonTip("Message text", "Title text", "icon text", 5); //delay is in seconds
//or
ShowBalloonTip(Message_string.chars, Title_string.chars, IconText_string.chars, 5);
...
*/
If some people could test this for me, on differing systems, XP SP1, XP SP2, XP SP3, Vista, or whatever I would be greatful. Thanks again MMike 
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tooltip
[Re: Quad]
#271443
06/13/09 07:58
06/13/09 07:58
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
HOOO-Yeah, that knocks down my largest fear. I was worried that the Win7 shell-notify wouldnt be backwards-compatible to that far back. Thankx Quadraxas. [EDIT] :: PS TO ALL Im currently working on a way for this same function to attach the ballon to an EXISTING shell-notify icon. ... [EDIT2] And this is it. Basically the same usage as before, just a few extra lines of code, and now with better documentation at the bottom. Once again, I would appreciate it if some you guys could give this a test in other operating systems, and ESPECIALLY if you have already implemented a ShellNotifyIcon for my ballon to attach to. I dont have anything using the systemtray icons ATM, so it is only poorly tested in that area. Thanks
/////////////////////////////////////////////////////////////////////////////////////////
#include <acknex.h>
#include <default.c>
#include <windows.h>
//
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
#define NIM_ADD 0x00
#define NIM_MODIFY 0x01
#define NIM_DELETE 0x02
#define NIF_MESSAGE 0x001
#define NIF_ICON 0x002
#define NIF_TIP 0x004
#define NIF_INFO 0x010
#define IMAGE_ICON 0x0001
#define LR_LOADFROMFILE 0x00010
#define LR_VGACOLOR 0x00080
#define LR_SHARED 0x08000
//
//
//
typedef struct NOTIFYICONDATA
{
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
long hIcon;
char szTip[128];
DWORD dwState;
DWORD dwStateMask;
char szInfo[256];
DWORD uTimeout;
char szInfoTitle[64];
DWORD dwInfoFlags;
}NOTIFYICONDATA;
//
//
NOTIFYICONDATA _nid;
//
BOOL __stdcall Shell_NotifyIcon(DWORD dwMessage, NOTIFYICONDATA* lpData);
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
void ShowBalloonTip(char* msg, char* title, char* icon, var Timeout)
{
_nid.cbSize =sizeof(NOTIFYICONDATA);
_nid.hWnd = hWnd;
_nid.uFlags = NIF_ICON | NIF_TIP | NIF_INFO;
_nid.uTimeout = 10000;
_nid.dwInfoFlags = NIF_MESSAGE;
strcpy(_nid.szInfo, ""); if(msg) strcpy(_nid.szInfo, msg);
strcpy(_nid.szInfoTitle, ""); if(title) strcpy(_nid.szInfoTitle, title);
if(!_nid.uID) _nid.hIcon = (long)LoadImage(GetModuleHandle(NULL),"26.ico",
IMAGE_ICON, 16, 16, LR_SHARED | LR_LOADFROMFILE | LR_VGACOLOR);
if(!_nid.uID)
{ //create temporary ShellNotifyIcon, and delete when done with it.
_nid.uID = -hWnd;
strcpy(_nid.szTip, ""); if(icon) strcpy(_nid.szTip, icon);
Shell_NotifyIcon(NIM_ADD, &_nid);
wait(-Timeout);
Shell_NotifyIcon(NIM_DELETE, &_nid); //delete "temporary" _nid
DeleteObject(_nid.hIcon); //Free resources and
_nid.hIcon = 0; //mark "_nid"
_nid.uID = 0; //as being "empty"
return;
}
Shell_NotifyIcon(NIM_MODIFY, &_nid);
}
//
//
/////////////////////////////////////////////////////////////////////////////////////////
//
//
//
/////////////////////////////////////////////////////////////////////////////////////////
// USAGE - ALL text parameters are optional, use NULL for unused text's /
// /
// ShowBalloonTip(char* message, char* title, char* icon_text, var Timeout_in_seconds) /
/////////////////////////////////////////////////////////////////////////////////////////
// /
// If the NOTIFYICONDATA object named "_nid" is already in use for a ShellNotifyIcon /
// then the Ballon message will appear attached to that icon. /
// Note:: Timeout does not yet work if the ballon is attached to an existing Icon /
// /
// But, the NOTIFYICONDATA object named "_nid" is NOT in use, marked by _nid.uID=NULL /
// then the function ShowBalloonTip will create a temporary ShellNotifyIcon to /
// popup from, and will remove it at the end of the Timeout period. /
// /
/////////////////////////////////////////////////////////////////////////////////////////
// /
// ... /
// ShowBalloonTip("Message text", "Title text", "icon text", 5); /
// or /
// ShowBalloonTip(Message_string.chars, Title_string.chars, IconText_string.chars, 5); /
// ... /
// /
/////////////////////////////////////////////////////////////////////////////////////////
Last edited by EvilSOB; 06/13/09 08:40. Reason: Ready for FULL testing.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tooltip
[Re: MMike]
#271454
06/13/09 09:47
06/13/09 09:47
|
Joined: Jul 2004
Posts: 1,710
MMike
OP
Serious User
|
OP
Serious User
Joined: Jul 2004
Posts: 1,710
|
By the way, its possible also to set the ballong icon, to show Warning icon Info ballon type icon Or error ballon type icon Or the Icon you loaded as tray icon. Define then this:
#define ballon_simple 0x000
#define ballon_info_small 0x001
#define ballon_warning_small 0x002
#define ballon_error_small 0x003
#define ballon_warning_big 0x005
#define ballon_error_big 0x006
#define ballon_loading_big 0x007
and set for example: _nid.dwInfoFlags =ballon_info_big;
Last edited by MMike; 06/13/09 09:52.
|
|
|
Re: Tooltip
[Re: MMike]
#271460
06/13/09 10:44
06/13/09 10:44
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
The code IS complete, I just didnt include a tester "main" function. Heres the one I was testing with if you need it. Just paste it at the bottom of the code I have posted above and run it.
int main()
{
video_window(nullvector,nullvector,112,"System Tray Icon Example");
mouse_pointer = 2;
ShowBalloonTip("message text", "title text", "icon text", 5);
}
BTW, its time for bed down here is Oz, so I wont be doing any more work on it tonight, but I'll look into making the ballon-type a parameter tomorrow. Ive still got to figure out why I had to fudge the timeout system anyways. Once those two things are done, and anyone following this thread doesnt find any major bugs, or make any good suggestions, like selectable balloon types, then I'll re-post this snippet into contributions. All thanks to you MMike. 
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tooltip
[Re: MMike]
#275095
06/30/09 04:03
06/30/09 04:03
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Im finally back to working on this issue.
Ballon types as a parameter is sorted out. Still working on allowing the Systray Icon to be a parameter. Then to be working on implementing the API's timeout. (rather than my fake one)
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Tooltip
[Re: EvilSOB]
#275123
06/30/09 08:14
06/30/09 08:14
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
If anyone is still interested in this issue, follow this LINK to my latest Lite-C Contribution. Developed here on this thread with the help of MMike.....
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|