Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionHow to change the string of a MFC Menu item that contains '\t'memberhaha_c12 May '13 - 21:40 
Hi,I want to change the string of a menu item,the string contains a '\t',like
"hello\tworld",I use CMenu::ModifyMenu function,I tried many times,the string always "hello",not"hello world",It will lost the string after '\t',Why,How to change it.
 
Thanks
SuggestionRe: How to change the string of a MFC Menu item that contains '\t'mvpRichard MacCutchan12 May '13 - 23:02 
Show some more of the actual code; there may be something wrong with it.
Use the best guess

AnswerRe: How to change the string of a MFC Menu item that contains '\t'professionalJochen Arndt12 May '13 - 23:40 
With menu items, the tab character is used to right align text in a new column (commonly to print accelerator short cuts). See also the MENUITEM statement[^] in the MSDN.
 
So even when its is working, the result may be not the one expected by you.
 
I don't know why the text right of the tab is not shown by your application. Did you call CWnd::DrawMenuBar() after changing the menu content? If not, this may be the reason.
GeneralRe: How to change the string of a MFC Menu item that contains '\t'memberhaha_c13 May '13 - 16:04 
I use vs2010,The Menu item got from CMFCMenuBar,like this:
CMenu *pMenu = CMenu::FromHandle(m_wndMenuBar.GetDefaultMenu());
CMenu *pSubMenu = pMenu ->GetSubMenu(1);
Cstring strText = _T("Hello\tworld");
pSubMenu ->ModifyMenu(ID_CHANGE, MF_BYCOMMAND, ID_CHANGE, strText);
 
I use DrawMenuBar ,it still doesn't work,why
GeneralRe: How to change the string of a MFC Menu item that contains '\t'professionalJochen Arndt13 May '13 - 20:57 
I don't know why.
 
You may check if tabs are shown when using in resource based menus. If not, the problem is application based. You may also check if '\a' is working (same as '\t' but text is left aligned).
QuestionCdialog::Create Never comes backmemberForNow12 May '13 - 18:04 
Hi,
 
I create a derived Cdialog with following code
 
  main_window->progdbg = new CprogDebug(); 
 
main_window is main windows I get the pointer to it via AfxGetMainWInd
 
  CMainFrame*  main_window = (CMainFrame *) AfxGetMainWnd();
 

CMainFrame is created on the heap
 
later on when I try to create the the window modeless dialog it never comes back to me the is that is the create
 
ret =  progdbg->Create(IDD_PROGDBG,(CWnd *)this);
        if(ret == 0 )
            error = GetLastError();

AnswerRe: Cdialog::Create Never comes backmvpRichard MacCutchan12 May '13 - 21:07 
See http://msdn.microsoft.com/en-us/library/ms644996(v=vs.85).aspx#modeless_box[^].
Use the best guess

Questionwhat is the difference between "static" function and "inline" function? [SOLVED] [modified]groupyu-jian12 May '13 - 16:53 
I use the VC++ 2008 to check this question. I define one function named "max2" using keyword "static" and one function named "min2" using keyword "inline". I think that the compiler will use the code inside the min2 function to replace the function called. And the max2 with static keyword will be compiled to be a function.
 

But after the Deassembled in Debug model. I found that the exe both use the "call " assemble code to call these two functions. why does the inline not succeed?

modified 14 May '13 - 10:16.

AnswerRe: what is the difference between "static" function and "inline" function?professionalSoMad12 May '13 - 18:29 
You have the idea right, but there are several issues with inline. Here is a list off the top of my head:
1. You can change the setting in the Project Properties -> C/C++ -> Optimizations -> Inline Function Expansion.
2. You say you de-assembled the Debug build of your exe, but for Debug builds the default setting is Disabled.
3. The inline keyword does not order the compiler to expand the function inline, it is merely a request. The compiler will determine if it is worth making it inline or if it is better left as a function call.
4. If a function is marked as inline and called from multiple other function, it might be inlined in some of the calling functions and not in others. Again the compiler determines whether it is worth it.
5. If you discover that the compiler is not inlining a function you have marked as inline and you really, really, really want it inlined because you think you know better or you want to run profiling with it inlined and not inlined, try using the __forceinline keyword.
 
http://msdn.microsoft.com/en-us/library/z8y1yy88(v=vs.90).aspx[^]
 
Soren Madsen
"When you don't know what you're doing it's best to do it quickly" - Jase #DuckDynasty

GeneralRe: what is the difference between "static" function and "inline" function?groupyu-jian14 May '13 - 4:13 
Thank you for you reply.

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


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid