WEB开发网
开发学院手机开发Windows Mobile 开发 Windows Mobile SP/PPC 中 Menu Bar 使用完美方案... 阅读

Windows Mobile SP/PPC 中 Menu Bar 使用完美方案

 2010-08-22 12:53:00 来源:WEB开发网   
核心提示:{m_hMenuBar = hMenuBar;}operator HWND(){return m_hMenuBar;}HWND operator =(HWND hMenuBar){return m_hMenuBar = hMenuBar;}// 创建菜单条HWND Create(HWND hParent, UINT u

{

m_hMenuBar = hMenuBar;

}

operator HWND()

{

return m_hMenuBar;

}

HWND operator =(HWND hMenuBar)

{

return m_hMenuBar = hMenuBar;

}

// 创建菜单条

HWND Create(HWND hParent, UINT uBarRes = 0, DWORD dwFlags = 0)

{

SHMENUBARINFO mb = {0};

mb.cbSize = sizeof(SHMENUBARINFO);

mb.hwndParent = hParent;

mb.hInstRes = g_hInst;

mb.nToolBarId = uBarRes;

if (uBarRes)

{

#ifdef TBIF_BYINDEX

mb.dwFlags = dwFlags | SHCMBF_HMENU;

#else

mb.dwFlags = dwFlags;

#endif

}

else

{

mb.dwFlags = SHCMBF_EMPTYBAR;

}

SHCreateMenuBar(&mb);

_Assert(mb.hwndMB);

return m_hMenuBar = mb.hwndMB;

}

// 获取弹出菜单

HMENU GetMenu(BOOL bRight = TRUE)

{

#ifdef TBIF_BYINDEX

TBBUTTON tb;

tb.dwData = NULL;

SendMessage(m_hMenuBar, TB_GETBUTTON, _MBID(bRight), (LPARAM) &tb);

return (HMENU) tb.dwData;

#else

return (HMENU) SendMessage(m_hMenuBar, SHCMBM_GETSUBMENU, 0, _MBID(bRight));

#endif

}

// 重载按键

DWORD OverrideKey(WPARAM wParam = VK_TBACK)

{

return SendMessage(m_hMenuBar, SHCMBM_OVERRIDEKEY, wParam, MAKELPARAM(SHMBOF_NODEFAULT | SHMBOF_NOTIFY, SHMBOF_NODEFAULT | SHMBOF_NOTIFY));

}

// 获取按钮文字

BOOL GetButtonText(PTSTR ptzStr, BOOL bRight = TRUE)

{

TBBUTTONINFO tb;

tb.cbSize = sizeof(TBBUTTONINFO);

tb.dwMask = _MBIF(TBIF_TEXT);

tb.pszText = ptzStr;

tb.cchText = MAX_PATH;

return SendMessage(m_hMenuBar, TB_GETBUTTONINFO, _MBID(bRight), (LPARAM)

Tags:Windows Mobile SP

编辑录入:coldstar [复制链接] [打 印]
赞助商链接