ImageVerifierCode 换一换
格式:DOCX , 页数:8 ,大小:16.93KB ,
资源ID:5995511      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/5995511.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(BitmapMenu.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

BitmapMenu.docx

1、BitmapMenu#include #include resource.hVOID WINAPI LoadChartBitmaps(HBITMAP *paHbm);VOID WINAPI CreateLineBitmaps(HBITMAP *paHbm, HWND hwnd);VOID WINAPI AddBitmapMenu(HWND hwnd, LPTSTR lpszText, UINT uID, HBITMAP *paHbm, int cItems); LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wPara

2、m, LPARAM lParam );/ Menu-item identifiers #define IDM_SOLID 500 #define IDM_DASH 501 #define IDM_DOT 502#define IDM_DASHDOT 503 #define IDM_DASHDOTDOT 504 / Number of items on the Chart and Lines menus #define C_LINES 5 #define C_CHARTS 3 / Dimensions of the line bitmaps #define CX_LINEBMP 40 #defi

3、ne CY_LINEBMP 10 HINSTANCE g_hinst ;int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow) TCHAR szAppName 16, szCaption 64, szErrMsg 64 ; HWND hwnd ; MSG msg ; WNDCLASS wndclass ; LoadString (hInstance, IDS_APPNAME, szAppName, sizeof (szAppName) / sizeof (TC

4、HAR) ; LoadString (hInstance, IDS_CAPTION, szCaption, sizeof (szCaption) / sizeof (TCHAR) ; wndclass.style = CS_HREDRAW | CS_VREDRAW ; wndclass.lpfnWndProc = MainWindowProc ; wndclass.cbClsExtra = 0 ; wndclass.cbWndExtra = 0 ; wndclass.hInstance = hInstance ; wndclass.hIcon = LoadIcon (hInstance, sz

5、AppName) ; wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ; wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ; wndclass.lpszMenuName = szAppName ; wndclass.lpszClassName = szAppName ; if (!RegisterClass (&wndclass) LoadStringA (hInstance, IDS_APPNAME, (char *) szAppName, sizeof (szApp

6、Name) ; LoadStringA (hInstance, IDS_ERRMSG, (char *) szErrMsg, sizeof (szErrMsg) ; MessageBoxA (NULL, (char *) szErrMsg, (char *) szAppName, MB_ICONERROR) ; return 0 ; g_hinst =hInstance; hwnd = CreateWindow (szAppName, szCaption, WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT,

7、CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL) ; ShowWindow (hwnd, iCmdShow) ; UpdateWindow (hwnd) ; while (GetMessage (&msg, NULL, 0, 0) TranslateMessage (&msg) ; DispatchMessage (&msg) ; return msg.wParam ;LRESULT CALLBACK MainWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa

8、ram ) static HBITMAP aHbmLinesC_LINES; static HBITMAP aHbmChartC_CHARTS; int i; switch (uMsg) case WM_CREATE: / Call application-defined functions to load the / bitmaps for the Chart menu and create those for / the Lines menu. LoadChartBitmaps(aHbmChart); CreateLineBitmaps(aHbmLines,hwnd); / Call an

9、 application-defined function to create / menus containing the bitmap menu items. The function / also adds a menu name to the windows menu bar. AddBitmapMenu( hwnd, / menu bars owner window TEXT(&Chart), / text of menu name on menu bar IDB_PIE, / ID of first item on menu aHbmChart, / array of bitmap

10、 handles C_CHARTS / number of items on menu ); AddBitmapMenu(hwnd, TEXT(&Lines), IDM_SOLID, aHbmLines, C_LINES); DrawMenuBar(hwnd); break; case WM_DESTROY: for (i = 0; i C_LINES; i+) DeleteObject(aHbmLinesi); for (i = 0; i C_CHARTS; i+) DeleteObject(aHbmCharti); PostQuitMessage(0); break; / Process

11、additional messages here. default: return (DefWindowProc(hwnd, uMsg, wParam, lParam); return 0; VOID WINAPI LoadChartBitmaps(HBITMAP *paHbm) paHbm0 = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_PIE); paHbm1 = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB_LINE); paHbm2 = LoadBitmap(g_hinst, MAKEINTRESOURCE(IDB

12、_BAR); VOID WINAPI CreateLineBitmaps(HBITMAP *paHbm, HWND hwnd) HDC hdc = GetDC(hwnd); HDC hdcMem = CreateCompatibleDC(hdc); COLORREF clrMenu = GetSysColor(COLOR_MENU); HBRUSH hbrOld; HPEN hpenOld; HBITMAP hbmOld; int fnDrawMode; int i; / Create a brush using the menu background color, / and select

13、it into the memory DC. hbrOld = SelectObject(hdcMem, CreateSolidBrush(clrMenu); / Create the bitmaps. Select each one into the memory / DC that was created and draw in it. for (i = 0; i C_LINES; i+) / Create the bitmap and select it into the DC. paHbmi = CreateCompatibleBitmap(hdc, CX_LINEBMP, CY_LI

14、NEBMP); hbmOld = SelectObject(hdcMem, paHbmi); / Fill the background using the brush. PatBlt(hdcMem, 0, 0, CX_LINEBMP, CY_LINEBMP, PATCOPY); / Create the pen and select it into the DC. hpenOld = SelectObject(hdcMem, CreatePen(PS_SOLID + i, 1, RGB(0, 0, 0); / Draw the line. To preserve the background

15、 color where / the pen is white, use the R2_MASKPEN drawing mode. fnDrawMode = SetROP2(hdcMem, R2_MASKPEN); MoveToEx(hdcMem, 0, CY_LINEBMP / 2, NULL); LineTo(hdcMem, CX_LINEBMP, CY_LINEBMP / 2); SetROP2(hdcMem, fnDrawMode); / Delete the pen, and select the old pen and bitmap. DeleteObject(SelectObje

16、ct(hdcMem, hpenOld); SelectObject(hdcMem, hbmOld); / Delete the brush and select the original brush. DeleteObject(SelectObject(hdcMem, hbrOld); / Delete the memory DC and release the desktop DC. DeleteDC(hdcMem); ReleaseDC(hwnd, hdc); VOID WINAPI AddBitmapMenu( HWND hwnd, / window that owned the men

17、u bar LPTSTR lpszText, / text of menu name on menu bar UINT uID, / ID of first bitmap menu item HBITMAP *paHbm, / bitmaps for the menu items int cItems ) / number bitmap menu items HMENU hmenuBar = GetMenu(hwnd); HMENU hmenuPopup = CreatePopupMenu(); MENUITEMINFO mii; int i; / Add the bitmap menu it

18、ems to the menu. mii.cbSize = sizeof(MENUITEMINFO); for (i = 0; i cItems; i+) mii.fMask = MIIM_ID | MIIM_BITMAP; mii.wID = uID + i; mii.hbmpItem = paHbmi; / mii.dwItemData = IDStart + i; InsertMenuItem(hmenuPopup, i, TRUE, &mii); / Add a menu name to the menu bar. mii.fMask = MIIM_STRING | MIIM_DATA | MIIM_SUBMENU; mii.fType = MFT_STRING; mii.hSubMenu = hmenuPopup; mii.dwTypeData = lpszText; InsertMenuItem(hmenuBar, GetMenuItemCount(hmenuBar), TRUE, &mii);

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1