Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Общие вопросы > Проблемы с полноцветными иконками в SystemTray


Автор: Гость_Ruslan 27.11.2003, 10:05
Собственно пишу на MS VC++.NET.
Иконку загружаю так:
trayIcon.hIcon=(HICON) LoadImage(AfgGetAppInstance(),(LPCSTR) IDI_ICON1, IMAGE_ICON,16,16, LT_DEFAULTCOLOR);

(писал на память, может где наврал)

Где то на форумах нашел, что LoadImage лучше подгружает, чем LoadIcon. Поэтому и гружу через нее.

Мучался на Win2k полночи, ну никак не захотела показываться в полноцвете - уродско конвертируется в 16 цветов, похоже. УТром попробовал на машине с WinXP - все отлично, красочная икона. Попал совсем в растерянность. Под Win98,Me,Nt попробовать нет возможности, т.к. нет уже таких машин у моих знакомых...=)

Буду очень признателен за любой совет.

Если не затруднит - дубликат ответа пошлите по почте: worldwide-yar@yandex.ru

Автор: Гость_Ruslan 30.11.2003, 22:25
Блин, неуж то никто не сталкивался?

Привожу фрагменты кода:

Код

void Cuser_statDlg::CreateTrayIcon(void)
{
NOTIFYICONDATA trayIcon;

trayIcon.hWnd = m_hWnd;
trayIcon.hIcon = (HICON) LoadImage(AfxGetInstanceHandle(), (LPCTSTR) IDR_MAINFRAME,IMAGE_ICON,GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),LR_DEFAULTCOLOR);
trayIcon.uID = 5100;
trayIcon.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
trayIcon.uCallbackMessage = WM_SYSCOMMAND;
sprintf(trayIcon.szTip,"Royal User Agent");

trayIcon.cbSize = sizeof(NOTIFYICONDATA);

Shell_NotifyIcon(NIM_ADD,&trayIcon);
}



stdafx.h
Код

// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently,
// but are changed infrequently

#pragma once

#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN  // Exclude rarely-used stuff from Windows headers
#endif

// Modify the following defines if you have to target a platform prior to the ones specified below.
// Refer to MSDN for the latest info on corresponding values for different platforms.
#ifndef WINVER    // Allow use of features specific to Windows 95 and Windows NT 4 or later.
#define WINVER 0x0500  // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif

#ifndef _WIN32_WINNT  // Allow use of features specific to Windows NT 4 or later.
#define _WIN32_WINNT 0x5000  // Change this to the appropriate value to target Windows 98 and Windows 2000 or later.
#endif      

#ifndef _WIN32_WINDOWS  // Allow use of features specific to Windows 98 or later.
#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
#endif

#ifndef _WIN32_IE   // Allow use of features specific to IE 4.0 or later.
#define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later.
#endif

#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit

// turns off MFC's hiding of some common and often safely ignored warning messages
#define _AFX_ALL_WARNINGS

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes

#include <afxdtctl.h>  // MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>   // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxsock.h>  // MFC socket extensions
#include <afxdisp.h>

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)