Click here to Skip to main content
15,890,512 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: MFC help : code error 0000007B Pin
jawadali47716-May-12 19:19
jawadali47716-May-12 19:19 
GeneralRe: MFC help : code error 0000007B Pin
soaringpilot17-May-12 6:19
soaringpilot17-May-12 6:19 
QuestionResponding To Asynchronous Functions Pin
AmbiguousName14-May-12 20:38
AmbiguousName14-May-12 20:38 
AnswerRe: Responding To Asynchronous Functions Pin
CPallini14-May-12 22:08
mveCPallini14-May-12 22:08 
AnswerRe: Responding To Asynchronous Functions Pin
TinyDevices15-May-12 3:31
professionalTinyDevices15-May-12 3:31 
AnswerRe: Responding To Asynchronous Functions Pin
soaringpilot15-May-12 10:51
soaringpilot15-May-12 10:51 
AnswerRe: Responding To Asynchronous Functions Pin
TomasRiker217-May-12 8:12
TomasRiker217-May-12 8:12 
QuestionHow do I check or change text in a VS2008 menu bar menu item Pin
soaringpilot14-May-12 12:22
soaringpilot14-May-12 12:22 
I must be doing something really stupid, but... I cannot get any of the changes to my menu items reflected in visual appearance. If I check a menu item, or change string I can see changes if I test in code, but not when I click on the menu bar.

I use standard default bar creation in main frame OnCreate:

C++
CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMFCVisualManagerWindows));
if (!m_wndMenuBar.Create(this))
{
    TRACE0("Failed to create menubar\n");
    return -1;      // fail to create
}
m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);


I then create a menu message handler in a view and in it I put something like this:
C++
MENUITEMINFO info;
TCHAR buf[32];

info.cbSize=sizeof(MENUITEMINFO);
info.fMask=MIIM_STATE|MIIM_ID|MIIM_STRING;
info.fType=MFT_STRING;
info.dwTypeData=0;

HMENU hMenusafe= ((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_wndMenuBar.GetHMenu();
HMENU hMenu=::GetSubMenu(hMenusafe,0);
DWORD err=GetLastError();
int er=GetMenuItemInfo(hMenu,3,1,&info);
 err=GetLastError();
 info.cch++;
 if( info.cch > 32)
      info.cch = 32;
 info.dwTypeData=buf;
 er=GetMenuItemInfo(hMenu,3,1,&info);
 err=GetLastError();

if(info.fState & MFS_CHECKED)
{
    info.fState &=~MFS_CHECKED;
    info.fState|=MFS_UNCHECKED;
    _tcscpy(buf,_T("Menu is unchecked"));
    info.cch=_tcslen(buf)+1;
}
else
{
    info.fState &=~MFS_UNCHECKED;
    info.fState  |=MFS_CHECKED;
    _tcscpy(buf,_T("Menu is checked"));
    info.cch=_tcslen(buf)+1;
}

er=SetMenuItemInfo(hMenu,3,1,&info);
((CMainFrame*)(AfxGetApp()->m_pMainWnd))->DrawMenuBar();


As I click on the menu item I never see a check, nor changed text. However as I am stepping through the code debugging, I see that changes did take place. What am I doing wrong?

Any help appreciated
Henryk
AnswerRe: How do I check or change text in a VS2008 menu bar menu item Pin
«_Superman_»14-May-12 16:32
professional«_Superman_»14-May-12 16:32 
GeneralRe: How do I check or change text in a VS2008 menu bar menu item Pin
soaringpilot15-May-12 10:21
soaringpilot15-May-12 10:21 
Questionc++ win32, What's the best way to handle large fonts 120 dpi Pin
jkirkerx14-May-12 8:33
professionaljkirkerx14-May-12 8:33 
AnswerRe: c++ win32, What's the best way to handle large fonts 120 dpi Pin
enhzflep14-May-12 11:06
enhzflep14-May-12 11:06 
GeneralRe: c++ win32, What's the best way to handle large fonts 120 dpi Pin
jkirkerx14-May-12 11:38
professionaljkirkerx14-May-12 11:38 
QuestionVfw decompression - real sample code wanted Pin
Vaclav_14-May-12 8:24
Vaclav_14-May-12 8:24 
QuestionDrawImage from 2 image buffer Pin
john563213-May-12 23:34
john563213-May-12 23:34 
AnswerRe: DrawImage from 2 image buffer Pin
Richard MacCutchan14-May-12 0:17
mveRichard MacCutchan14-May-12 0:17 
QuestionIPC using named pipes Pin
ForNow13-May-12 9:27
ForNow13-May-12 9:27 
GeneralRe: IPC using named pipes Pin
«_Superman_»13-May-12 16:15
professional«_Superman_»13-May-12 16:15 
AnswerRe: IPC using named pipes Pin
ThatsAlok13-May-12 20:06
ThatsAlok13-May-12 20:06 
AnswerRe: IPC using named pipes Pin
Software_Developer14-May-12 0:02
Software_Developer14-May-12 0:02 
Questionc++, CryptGetHashParam works in XP, Vista, but not Windows 7 Pin
jkirkerx13-May-12 8:49
professionaljkirkerx13-May-12 8:49 
Answer[SOLVED] Re: c++, CryptGetHashParam works in XP, Vista, but not Windows 7 Pin
jkirkerx13-May-12 10:13
professionaljkirkerx13-May-12 10:13 
Questionwhere should add the try-catch? Pin
yu-jian13-May-12 5:55
yu-jian13-May-12 5:55 
AnswerRe: where should add the try-catch? Pin
Richard MacCutchan13-May-12 6:45
mveRichard MacCutchan13-May-12 6:45 
GeneralRe: where should add the try-catch? Pin
yu-jian13-May-12 18:39
yu-jian13-May-12 18:39 

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.