Welcome to shell: revealed Sign in | Join | Help

Add icons to standard menus and preserve the visual styling

File Details
Downloads: 1829 File Size: 10.4kB
Posted By: ksykes Views: 4496
Date Added: 6 Feb 2007

A common reason to use owner-draw menus is to render icons.  In Windows Vista we now apply Visual Styling to menus but disable that styling for owner-draw menus.  This code shows how to convert an icon to an alpha blended bitmap and add it to your menu without using owner-draw.

See the associated blog post for more details.

Comments
 

gdicy said:

I can't compile it. I am using VS 2005 and on Vista enterprise rtm. How do I set up WIC to build this? >------ Build started: Project: CVistaMenuApp, Configuration: Debug Win32 ------ 1>Compiling... 1>GDI_CVistaMenuApp.cpp 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(141) : error C2065: 'HPAINTBUFFER' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(141) : error C2146: syntax error : missing ')' before identifier 'hPaintBuffer' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(141) : error C2059: syntax error : ')' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(142) : error C2143: syntax error : missing ';' before '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(142) : error C2447: '{' : missing function header (old-style formal list?) 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2065: 'BP_PAINTPARAMS' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2146: syntax error : missing ';' before identifier 'paintParams' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2065: 'paintParams' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2059: syntax error : '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2143: syntax error : missing ';' before '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(192) : error C2143: syntax error : missing ';' before '}' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(193) : error C2228: left of '.cbSize' must have class/struct/union 1> type is ''unknown-type'' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(193) : error C2070: ''unknown-type'': illegal sizeof operand 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(194) : error C2228: left of '.dwFlags' must have class/struct/union 1> type is ''unknown-type'' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(194) : error C2065: 'BPPF_ERASE' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(195) : error C2228: left of '.pBlendFunction' must have class/struct/union 1> type is ''unknown-type'' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(198) : error C2146: syntax error : missing ';' before identifier 'hPaintBuffer' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(198) : error C2065: 'hPaintBuffer' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(198) : error C2065: 'BPBF_DIB' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(198) : error C3861: 'BeginBufferedPaint': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(208) : error C3861: 'EndBufferedPaint': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(268) : error C2065: 'LIM_SMALL' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(268) : error C3861: 'LoadIconMetric': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(327) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(327) : error C2146: syntax error : missing ';' before identifier 'qit' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(327) : error C2065: 'qit' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(327) : error C2059: syntax error : ']' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(328) : error C2143: syntax error : missing ';' before '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(329) : error C2143: syntax error : missing ';' before '}' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(329) : error C2143: syntax error : missing ';' before ',' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(331) : error C3861: 'QISearch': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(382) : error C2061: syntax error : identifier 'SHSTOCKICONID' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2065: 'SHSTOCKICONINFO' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2146: syntax error : missing ';' before identifier 'sii' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2065: 'sii' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2059: syntax error : '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2143: syntax error : missing ';' before '{' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2070: ''unknown-type'': illegal sizeof operand 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(384) : error C2143: syntax error : missing ';' before '}' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(385) : error C2065: 'siid' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(385) : error C3861: 'SHGetStockIconInfo': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(387) : error C2228: left of '.hIcon' must have class/struct/union 1> type is ''unknown-type'' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(389) : error C3861: 'SHGetStockIconInfo': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(391) : error C2228: left of '.hIcon' must have class/struct/union 1> type is ''unknown-type'' 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(403) : error C2065: 'SIID_APPLICATION' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(405) : error C3861: 'BufferedPaintInit': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(414) : error C3861: 'BufferedPaintUnInit': identifier not found 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(432) : error C2065: 'IDI_SHIELD' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(476) : error C2065: 'COINIT_DISABLE_OLE1DDE' : undeclared identifier 1>c:\msdn\vistamenus\gdi_cvistamenuapp.cpp(476) : error C3861: 'CoInitializeEx': identifier not found 1>Build log was saved at "file://c:\msdn\VistaMenus\Debug\BuildLog.htm" 1>CVistaMenuApp - 50 error(s), 0 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
14 Feb 2007 6:09 PM

Add Comment

Name (required)
Web Site (optional)
Comment (required)
Add
Powered by Community Server, by Telligent Systems © 2006 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement.