|
|
// *********************************************************
// コンストラクタ
// *********************************************************
LboxMenu::LboxMenu( )
{
LboxMenu::hMenu = NULL;
}
// *********************************************************
// デストラクタ
// *********************************************************
LboxMenu::~LboxMenu()
{
}
| |
|
|
|
|
// *********************************************************
// ベースメニューセット
// 戻り値 : 無し
// *********************************************************
void LboxMenu::SetBaseMenu( HMENU hTarget )
{
LboxMenu::hMenu = hTarget;
LboxMenu::hCurMenu = hTarget;
}
void LboxMenu::SetBaseMenu( HWND hTarget )
{
LboxMenu::hMenu = GetMenu( hTarget );
if ( !(IsMenu( LboxMenu::hMenu )) ) {
LboxMenu::hMenu = NULL;
}
LboxMenu::hCurMenu = LboxMenu::hMenu;
}
| |
|
|
|
|
// *********************************************************
// メニューアイテム追加
// 戻り値 : 無し
// *********************************************************
void LboxMenu::AddItem( LPTSTR lpTarget, LPTSTR lpItem, int nID )
{
int nCount;
MENUITEMINFO minfo;
LboxMenu::SetSubMenu( lpTarget );
nCount = LboxMenu::Count( lpTarget );
ZeroMemory( &minfo, sizeof( MENUITEMINFO ) );
minfo.cbSize = sizeof( MENUITEMINFO );
minfo.fMask = MIIM_TYPE | MIIM_ID;
minfo.fType = MFT_STRING;
minfo.dwTypeData = lpItem;
minfo.wID = nID;
InsertMenuItem( LboxMenu::hCurMenu, (UINT)nCount, true, &minfo );
}
| |
|
|
|
|
// *********************************************************
// セパレートアイテム追加
// 戻り値 : 無し
// *********************************************************
void LboxMenu::AddSeparator( LPTSTR lpTarget )
{
int nCount;
MENUITEMINFO minfo;
LboxMenu::SetSubMenu( lpTarget );
nCount = LboxMenu::Count( lpTarget );
ZeroMemory( &minfo, sizeof( MENUITEMINFO ) );
minfo.cbSize = sizeof( MENUITEMINFO );
minfo.fMask = MIIM_TYPE;
minfo.fType = MFT_SEPARATOR;
InsertMenuItem( LboxMenu::hCurMenu, (UINT)nCount, true, &minfo );
}
| |
|
|
|
|
// *********************************************************
// ポップアップメニュー項目以外の削除
// 戻り値 : 無し
// *********************************************************
void LboxMenu::ResetItem( LPTSTR lpTarget )
{
LboxMenu::SetSubMenu( lpTarget );
if ( IsMenu( LboxMenu::hCurMenu ) ) {
int nCount,i;
nCount = LboxMenu::Count();
for( i = 0; i < nCount; i++ ) {
if ( GetSubMenu( LboxMenu::hCurMenu, i ) == NULL ) {
RemoveMenu( LboxMenu::hCurMenu, i, MF_BYPOSITION );
i--;
nCount--;
}
}
}
}
| |
|
|
|
|
// *********************************************************
// メニューの項目数
// 戻り値 : 項目数
// *********************************************************
int LboxMenu::Count( LPTSTR lpTarget )
{
LboxMenu::SetSubMenu( lpTarget );
return LboxMenu::Count( );
}
int LboxMenu::Count( void )
{
return GetMenuItemCount( LboxMenu::hCurMenu );
}
| |
|
|
|
|
// *********************************************************
// 使用不可・解除
// 戻り値 : 無し
// *********************************************************
void LboxMenu::Disable( int nID, BOOL bDisable )
{
MENUITEMINFO minfo;
ZeroMemory( &minfo, sizeof( MENUITEMINFO ) );
minfo.cbSize = sizeof( MENUITEMINFO );
minfo.fMask = MIIM_STATE;
if ( bDisable ) {
minfo.fState = MFS_DISABLED;
}
else {
minfo.fState = MFS_ENABLED;
}
SetMenuItemInfo( LboxMenu::hCurMenu, nID, false, &minfo );
}
void LboxMenu::Disable( LPTSTR lpTarget, int nID, BOOL bDisable )
{
LboxMenu::SetSubMenu( lpTarget );
LboxMenu::Disable( nID, bDisable );
}
void LboxMenu::Disable( LPTSTR lpTarget, LPTSTR lpPos, BOOL bDisable )
{
LboxToken *Token = new LboxToken( );
LboxString *Work = new LboxString( );
LboxString *Pos = new LboxString( );
LboxMenu::SetSubMenu( lpTarget );
Token->CreateToken( lpPos, "," );
MENUITEMINFO minfo;
int i;
for( i = 0; i < Token->nCount; i++ ) {
Work->operator = ( Token->Token[i] );
ZeroMemory( &minfo, sizeof( MENUITEMINFO ) );
minfo.cbSize = sizeof( MENUITEMINFO );
minfo.fMask = MIIM_STATE;
if ( bDisable ) {
minfo.fState = MFS_DISABLED;
}
else {
minfo.fState = MFS_ENABLED;
}
SetMenuItemInfo( LboxMenu::hCurMenu, Work->Atoi(), true, &minfo );
}
delete Pos;
delete Work;
delete Token;
}
| |
|
|
|
|
// *********************************************************
// カレントメニューセット
// 戻り値 : 無し
// *********************************************************
void LboxMenu::SetSubMenu( int nPos )
{
LboxMenu::hCurMenu = GetSubMenu( LboxMenu::hCurMenu, nPos );
}
void LboxMenu::SetSubMenu( LPTSTR lpTarget )
{
LboxToken *Token = new LboxToken( );
LboxString *Work = new LboxString( );
Work->operator = (lpTarget);
if ( Work->operator == ( "" ) ) {
LboxMenu::hCurMenu = LboxMenu::hMenu;
return;
}
Token->CreateToken( lpTarget, "," );
int i;
HMENU hSavePopup;
for( i = 0; i < Token->nCount; i++ ) {
if ( i == 0 ) {
Work->operator = ( Token->Token[i] );
hSavePopup = LboxMenu::hMenu;
LboxMenu::hCurMenu = GetSubMenu( LboxMenu::hMenu, Work->Atoi() );
}
else {
Work->operator = ( Token->Token[i] );
hSavePopup = LboxMenu::hCurMenu;
LboxMenu::hCurMenu = GetSubMenu( LboxMenu::hCurMenu, Work->Atoi() );
}
}
if ( !IsMenu( LboxMenu::hCurMenu ) ) {
MENUITEMINFO minfo;
HMENU hPopup;
hPopup = CreatePopupMenu( );
ZeroMemory( &minfo, sizeof( MENUITEMINFO ) );
minfo.cbSize = sizeof( MENUITEMINFO );
minfo.fMask = MIIM_SUBMENU;
minfo.hSubMenu = hPopup;
Work->operator = ( Token->Token[Token->nCount-1] );
SetMenuItemInfo( hSavePopup, Work->Atoi(), true, &minfo );
}
delete Work;
delete Token;
}
| |
|
|
|
|
// *********************************************************
// カレントメニューセット
// 戻り値 : 無し
// *********************************************************
void LboxMenu::ResetSubMenu( void )
{
LboxMenu::hCurMenu = LboxMenu::hMenu;
}
| |
|
|
|