12 #error TnbCeMenuBar.h is only supported on Windows CE platforms.
23 #define TBIF_BYINDEX 0x80000000
104 ::SendMessage(m_mbi.hwndMB, WM_CLOSE, 0, 0);
105 if ( m_menu != NULL )
107 ::DestroyMenu(m_menu);
121 bool Create(HWND hWnd, UINT barId, UINT menuId)
124 return m_Create(hWnd, barId, MAKEINTRESOURCE(menuId));
135 return !! ::IsWindowVisible(m_mbi.hwndMB);
149 bool ShowBar(
bool isShow,
bool withParent =
true)
151 if ( m_mbi.hwndMB == NULL )
158 return !! ::ShowWindow(m_mbi.hwndMB, isShow ? SW_SHOW : SW_HIDE);
161 HDC dc = ::GetWindowDC(NULL);
162 int cx = ::GetDeviceCaps(dc, HORZRES);
163 int cy = ::GetDeviceCaps(dc, VERTRES);
164 ::ReleaseDC(NULL, dc);
165 RECT rc = { 0, 0, cx, cy };
166 HWND hWnd = m_mbi.hwndParent;
169 int height = ::CalcScaleY(26);
170 r &= !! ::SHFullScreen(hWnd, SHFS_SHOWTASKBAR);
171 r &= !! ::ShowWindow(m_mbi.hwndMB, SW_SHOW);
173 rc.bottom -= (2 * height);
174 ::SetForegroundWindow(hWnd);
182 shidi.dwMask = SHIDIM_FLAGS;
183 shidi.dwFlags = SHIDIF_FULLSCREENNOMENUBAR | SHIDIF_SIPDOWN;
184 ::SHInitDialog(&shidi);
186 r &= !! ::SHFullScreen(hWnd, SHFS_HIDETASKBAR);
187 r &= !! ::SHFullScreen(hWnd, SHFS_HIDESIPBUTTON);
188 r &= !! ::ShowWindow(m_mbi.hwndMB, SW_HIDE);
190 r &= !! ::MoveWindow(m_mbi.hwndParent, rc.left, rc.top, rc.right, rc.bottom, TRUE);
201 return min(MAXMENU, ::GetMenuItemCount(m_menu));
223 return SetTopItemState(index, isEnable ? TBSTATE_ENABLED : TBSTATE_INDETERMINATE);
236 TBBUTTONINFO info = { 0 };
237 info.cbSize =
sizeof(TBBUTTONINFO);
238 info.dwMask = TBIF_TEXT | TBIF_BYINDEX;
240 info.cchText = _tcslen(lpszText);
241 LPARAM lParam =
reinterpret_cast<LPARAM
>(&info);
242 return ::SendMessage(m_mbi.hwndMB, TB_SETBUTTONINFO, index, lParam) != 0;
254 TBBUTTONINFO info = { 0 };
255 info.cbSize =
sizeof(TBBUTTONINFO);
256 info.dwMask = TBIF_STATE | TBIF_BYINDEX;
257 info.fsState = down_cast<BYTE>(state);
258 LPARAM lParam =
reinterpret_cast<LPARAM
>(&info);
259 return ::SendMessage(m_mbi.hwndMB, TB_SETBUTTONINFO, index, lParam) != 0;
270 TBBUTTONINFO info = { 0 };
271 info.cbSize =
sizeof(TBBUTTONINFO);
272 info.dwMask = TBIF_STATE | TBIF_BYINDEX;
273 LPARAM lParam =
reinterpret_cast<LPARAM
>(&info);
274 if ( ::SendMessage(m_mbi.hwndMB, TB_GETBUTTONINFO, index, lParam) )
304 bool m_Create(HWND hWnd, UINT barId, LPCTSTR menuName)
308 m_mbi.cbSize =
sizeof(SHMENUBARINFO);
309 m_mbi.hwndParent = hWnd;
310 m_mbi.nToolBarId = barId;
311 m_mbi.hInstRes = hInst;
312 if ( ! ::SHCreateMenuBar(&m_mbi) )
314 _GetLastError(
"SHCreateMenuBar");
317 if ( menuName == NULL )
321 m_menu = ::LoadMenu(hInst, menuName);
323 loop( i, min(MAXMENU, ::GetMenuItemCount(m_menu)) )
325 int len = ::GetMenuString(m_menu, i, NULL, 0, MF_BYPOSITION);
332 if ( ::GetMenuString(m_menu, i, tempName.Ref(), len + 1, MF_BYPOSITION) == 0 )
339 tbb.iBitmap = I_IMAGENONE;
340 tbb.fsState = TBSTATE_ENABLED;
341 UINT state = ::GetMenuState(m_menu, i, MF_BYPOSITION);
342 if ( state != 0xFFFFFFFF && (state & MF_GRAYED) != 0 )
344 tbb.fsState = TBSTATE_INDETERMINATE;
346 LPCTSTR lpsz = tempName;
347 tbb.iString =
reinterpret_cast<int>(lpsz);
348 HMENU sub = ::GetSubMenu(m_menu, i);
351 tbb.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE;
352 tbb.dwData =
reinterpret_cast<DWORD
>(sub);
356 tbb.fsStyle = TBSTYLE_AUTOSIZE;
357 tbb.idCommand = ::GetMenuItemID(m_menu, i);
359 ::SendMessage(m_mbi.hwndMB, TB_INSERTBUTTON, i,
reinterpret_cast<LPARAM
>(&tbb));
368 enum { MAXMENU = 2 };
#define loop(VAR, CNT)
loop構文.
void Zero(V &value)
[設定] ゼロクリア.
HINSTANCE GetInstanceHandleByTnb(EInstanceType type=EI_Process)
[取得] インスタンスハンドル取得.