BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Resource files???

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Jeff
Guest





PostPosted: Fri Aug 05, 2005 4:34 pm    Post subject: Resource files??? Reply with quote



I'm have a heck of a time trying to get a tray icon to change during
runtime. I've added a second icon to my resource file, using Borland's Image
Editor, but the image doesn't appear to be in the exe? I use the LoadIcon()
function to load it during runtime; see code below.

void __fastcall TfrmMain::UpdateIcon(const char *ptr_chrHint, bool
boolDisIcon)
{
NOTIFYICONDATA IconData;

if (boolDisIcon) //Disabled icon desired
IconData.hIcon = LoadIcon(HInstance, "DISABLEDICON");
else
IconData.hIcon = LoadIcon(HInstance, "MAINICON");

IconData.cbSize = sizeof(NOTIFYICONDATA);
IconData.uID = IDC_TRAY1;
IconData.hWnd = Handle;
IconData.uFlags = NIF_MESSAGE | NIF_TIP;
IconData.uCallbackMessage = WM_TRAYNOTIFY;
lstrcpy(IconData.szTip, ptr_chrHint);

Shell_NotifyIcon(NIM_MODIFY,&IconData);
}

The .res file has been added to the project, and the MAINICON is in there,
but what am I missing?

Thanks,
Jeff


Back to top
Mike Collins
Guest





PostPosted: Fri Aug 05, 2005 5:06 pm    Post subject: Re: Resource files??? Reply with quote



Don't know if this helps, as I'm not 100% on trayicons but,
1) LoadIcon has been superseeded by LoadImage:

LoadImage(HInstance, "DISABLEDICON", IMAGE_ICON, 16, 16,
LR_DEFAULTSIZE);

2) Form what I remember, there's a TrayIcon vcl that comes with builder and
uses an TImageList to hold the various images that you may wish to assign.

3) My experiance of including other resource files with the automatically
generated (AG) resource file has thrown up many problems. I've always found
that when the reource linker tries to combine my other resource with the AG
resource file I get errors or the combination does not occure as predicted.
Generally I always remove the AG resource file and replace it with a
completely new one (including main icon, version info and other resource)
created in Visual C++ (thats the only thing it's good for).

4) Have you tested handle that is returned from LoadIcon to see if it is
sucessful?

Just some thoughts,

HIH

Mike C


"Jeff" <Jeff (AT) nospam (DOT) com> wrote

Quote:
I'm have a heck of a time trying to get a tray icon to change during
runtime. I've added a second icon to my resource file, using Borland's
Image Editor, but the image doesn't appear to be in the exe? I use the
LoadIcon() function to load it during runtime; see code below.

void __fastcall TfrmMain::UpdateIcon(const char *ptr_chrHint, bool
boolDisIcon)
{
NOTIFYICONDATA IconData;

if (boolDisIcon) //Disabled icon desired
IconData.hIcon = LoadIcon(HInstance, "DISABLEDICON");
else
IconData.hIcon = LoadIcon(HInstance, "MAINICON");

IconData.cbSize = sizeof(NOTIFYICONDATA);
IconData.uID = IDC_TRAY1;
IconData.hWnd = Handle;
IconData.uFlags = NIF_MESSAGE | NIF_TIP;
IconData.uCallbackMessage = WM_TRAYNOTIFY;
lstrcpy(IconData.szTip, ptr_chrHint);

Shell_NotifyIcon(NIM_MODIFY,&IconData);
}

The .res file has been added to the project, and the MAINICON is in there,
but what am I missing?

Thanks,
Jeff




Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Aug 05, 2005 5:43 pm    Post subject: Re: Resource files??? Reply with quote




"Jeff" <Jeff (AT) nospam (DOT) com> wrote


Quote:
I'm have a heck of a time trying to get a tray icon to change
during runtime. I've added a second icon to my resource file,
using Borland's Image Editor, but the image doesn't appear
to be in the exe?

Which resource file are you editing exactly? If you are editing the default
resource file that every project has, then that is why your icon is missing.
The IDE manages that file and recreates it on every compile, thus frequently
losing any custom changes you make to it. Custom resources should always be
placed in their own resource file that you then add to the project.


Gambit



Back to top
Michael Gillen
Guest





PostPosted: Fri Aug 05, 2005 5:52 pm    Post subject: Re: Resource files??? Reply with quote

Jeff wrote:

Quote:
I'm have a heck of a time trying to get a tray icon to change during runtime. I've added a second
icon to my resource file, using Borland's Image Editor, but the image doesn't appear to be in the
exe? I use the LoadIcon() function to load it during runtime; see code below.

void __fastcall TfrmMain::UpdateIcon(const char *ptr_chrHint, bool boolDisIcon)
{
NOTIFYICONDATA IconData;

if (boolDisIcon) //Disabled icon desired
IconData.hIcon = LoadIcon(HInstance, "DISABLEDICON");
else
IconData.hIcon = LoadIcon(HInstance, "MAINICON");

IconData.cbSize = sizeof(NOTIFYICONDATA);
IconData.uID = IDC_TRAY1;
IconData.hWnd = Handle;
IconData.uFlags = NIF_MESSAGE | NIF_TIP;
IconData.uCallbackMessage = WM_TRAYNOTIFY;
lstrcpy(IconData.szTip, ptr_chrHint);

Shell_NotifyIcon(NIM_MODIFY,&IconData);
}

The .res file has been added to the project, and the MAINICON is in there, but what am I missing?

Thanks,
Jeff

Try changing this line
IconData.uFlags = NIF_MESSAGE | NIF_TIP;
to
IconData.uFlags = NIF_MESSAGE|NIF_ICON|NIF_TIP;

--
-Michael Gillen

Back to top
Jeff
Guest





PostPosted: Fri Aug 05, 2005 5:54 pm    Post subject: Re: Resource files??? Reply with quote

Thanks, that's what was happening. The IDE was constantly overwriting my
resource file.

"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote

Quote:

"Jeff" <Jeff (AT) nospam (DOT) com> wrote in message
news:42f39510 (AT) newsgroups (DOT) borland.com...

I'm have a heck of a time trying to get a tray icon to change
during runtime. I've added a second icon to my resource file,
using Borland's Image Editor, but the image doesn't appear
to be in the exe?

Which resource file are you editing exactly? If you are editing the
default
resource file that every project has, then that is why your icon is
missing.
The IDE manages that file and recreates it on every compile, thus
frequently
losing any custom changes you make to it. Custom resources should always
be
placed in their own resource file that you then add to the project.


Gambit





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
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, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.