Click here to Skip to main content
15,904,494 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Binary to ASCII Pin
Christian Graus25-May-05 15:59
protectorChristian Graus25-May-05 15:59 
GeneralRe: Binary to ASCII Pin
heng098731-May-05 4:40
heng098731-May-05 4:40 
GeneralRe: Binary to ASCII Pin
heng098731-May-05 10:33
heng098731-May-05 10:33 
GeneralGetting it to work in Windows 2000 and Windows XP Pin
droozenrule@yahoo.com25-May-05 11:05
sussdroozenrule@yahoo.com25-May-05 11:05 
GeneralRe: Getting it to work in Windows 2000 and Windows XP Pin
Ravi Bhavnani25-May-05 11:32
professionalRavi Bhavnani25-May-05 11:32 
GeneralRe: Getting it to work in Windows 2000 and Windows XP Pin
Graham Bradshaw25-May-05 12:27
Graham Bradshaw25-May-05 12:27 
GeneralRe: Getting it to work in Windows 2000 and Windows XP Pin
droozenrule@yahoo.com26-May-05 11:22
sussdroozenrule@yahoo.com26-May-05 11:22 
Questionhow to completely remove a menu item during run-time Pin
elephantstar25-May-05 10:31
elephantstar25-May-05 10:31 
Hi there,

I need to delete the Options menu during run-time. Currently it deletes it when the application first starts up. Then as I open up other CMultiDocTemplate windows, it reappears. These are the two functions I have in the CMainFrame class. I called the OnChangeFileMenu() function within the application class in InitInstance(). I thought that would do the trick but somehow it reappears as I open up other modal windows.

void CMainFrame::OnChangeFileMenu()
{
CWnd* pMain = AfxGetMainWnd();

// Get the menu from the application window.
CMenu* mmenu = pMain->GetMenu();

int pos = FindMenuItem(mmenu, "&Options");
if (pos > -1)
mmenu->RemoveMenu(pos, MF_BYPOSITION);

pMain->DrawMenuBar();
}

int CMainFrame::FindMenuItem(CMenu *menu, LPCTSTR menustr)
{
ASSERT(menu);
ASSERT(::IsMenu(menu->GetSafeHmenu()));

int count = menu->GetMenuItemCount();
for (int i = 0; i < count; i++)
{
CString str;
if (menu->GetMenuString(i, str, MF_BYPOSITION) &&
(strcmp(str, menustr) == 0))
return i;
}

return -1;
}

Besides inserting the below code in InitInstance, I also included it in the document view class's OnInitialUpdate:

// Get MDI Frame window
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();

#ifdef MODE_1
pMainFrame->OnChangeFileMenu();
#endif

That did the trick for only one document view class but not others. It does not detect the presence of the menu when it's called yet it reappears afterwards. How can I remove it completely without having to insert the above code in numerous places. It should have taken care of it in InitInstance(). Thanks.
AnswerRe: how to completely remove a menu item during run-time Pin
Iain Clarke, Warrior Programmer26-May-05 1:32
Iain Clarke, Warrior Programmer26-May-05 1:32 
GeneralRe: how to completely remove a menu item during run-time Pin
elephantstar27-May-05 7:15
elephantstar27-May-05 7:15 
GeneralHooking problem - need urgent help Pin
YaronNir25-May-05 8:47
YaronNir25-May-05 8:47 
Questionhow to change window's start button text? problem with my program Pin
ELY M.25-May-05 7:40
ELY M.25-May-05 7:40 
AnswerRe: how to change window's start button text? problem with my program Pin
Ravi Bhavnani25-May-05 8:47
professionalRavi Bhavnani25-May-05 8:47 
AnswerRe: how to change window's start button text? problem with my program Pin
David Crow25-May-05 8:59
David Crow25-May-05 8:59 
GeneralRe: how to change window's start button text? problem with my program Pin
ELY M.25-May-05 9:07
ELY M.25-May-05 9:07 
GeneralRe: how to change window's start button text? problem with my program Pin
David Crow25-May-05 9:11
David Crow25-May-05 9:11 
GeneralRe: how to change window's start button text? problem with my program Pin
ELY M.27-May-05 15:14
ELY M.27-May-05 15:14 
GeneralRe: how to change window's start button text? problem with my program Pin
ELY M.27-May-05 15:27
ELY M.27-May-05 15:27 
QuestionFind out if user logged in? Pin
jaycush25-May-05 7:09
jaycush25-May-05 7:09 
AnswerRe: Find out if user logged in? Pin
David Crow25-May-05 10:43
David Crow25-May-05 10:43 
AnswerRe: Find out if user logged in? Pin
CodeBeetle26-May-05 7:01
CodeBeetle26-May-05 7:01 
GeneralExit an application Pin
Gagnon Claude25-May-05 5:51
Gagnon Claude25-May-05 5:51 
GeneralRe: Exit an application Pin
BlackDice25-May-05 6:22
BlackDice25-May-05 6:22 
GeneralRe: Exit an application Pin
Ivan Cachicatari25-May-05 8:21
Ivan Cachicatari25-May-05 8:21 
GeneralRe: Exit an application Pin
David Crow25-May-05 9:15
David Crow25-May-05 9:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.