|
Thanks. I just posted a similar result based on the previous response. I appreciate the help.
|
|
|
|
|
I've started moving an MFC application to VS2008 MFC Feature Pack and got some problem with MainFrame menu manipulation.
Now the menu class is CMFCMenuBar is derived from CMFCToolbar and not rely anymore on CMenu. Seems I need to rewrite whole menu manipulation chunk the new way.
I didn't found any example of dynamic menu manipulation in Internet(like former: RemoveMenu, GetSubMenu, InsertMenu, GetSubMenu, AppendMenu, ModifyMenu, etc.)
- Is there any web resources/solutions on CMFCMenuBar dynamic menu manipulations?
Appreciate any suggestions.
Thanks.
|
|
|
|
|
use CMenu* pMenu = CMenu::FromHandle(mBar->GetHMenu());
where mBar is your CMFCMenuBar, now you can apply all the CMenu function on pMenu .
Never complain,never explain,just do your work.
|
|
|
|
|
Thanks, it works on pop-up menus, but don't work for top level menu.
|
|
|
|
|
The problem is a "glitch" (that's how I refer to it) in BCG's design of these extensions. The correct code is below (an example for removing an item), but be sure to look below the code for the important part. NOTE: "n" = your sub menu and "ID" = the ID of the menu item you want to remove.
CMenu* pMenu = CMenu::FromHandle( m_wndMenuBar.GetHMenu() );
CMenu* pSubMenu = pMenu ? pMenu->GetSubMenu( 0 ) : NULL;
if( pSubMenu ) pSubMenu->RemoveMenu( ID, MF_BYCOMMAND );
IMPORTANT (see below, too): You must FIRST go to the registry and DELETE the entry for you product. HKCU/Software/Your Product. You can just delete the correct folder for the menu, but that's up to you to figure out which one it is.
PROBLEM: This will solve it for you and new users of your product. However, existing users will never see the changes. There is a function CWinAppEx::CleanState(), which is supposed to remove memory from the registry. But, you will then have an app with no memory of toolbars, menus, etc...meaning customization is pointless.
Good luck!
|
|
|
|
|
Hi all.
In my SDI application, the window frame shrinks everytime i click FILE>NEW.
My application starts maximized(SW_MAXIMIZE instead of SW_SHOW in InitInstance() of the App Class)
Anyway, as soon a click file>new, the window shrinks a bit and still shows as maximized.
My application has a splitter window, i dont know if that got to do anything this.
I am kinda new to C++ and MFC. appreciate your help.
Regards
|
|
|
|
|
theAce89 wrote:
Anyway, as soon a click file>new, the window shrinks a bit and still shows as maximized.
My application has a splitter window, i dont know if that got to do anything this.
That is strange... it could be a number of things. The best thing to do is use the debugger to locate the responsible class. Here is how I would go about it:
1.) Locate your IDE path: (example) C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc
2.) Open the core MFC file 'winocc.cpp' in your IDE.
3.) Run a Debug build of your project.
4.) Set a breakpoint on CWnd::MoveWindow and click File->New.
You may also want to check if CWnd::OnNcCalcSize or CWnd::SetWindowPos is the culprit, there are a few ways to move a CWnd derived window.
Best Wishes,
-David Delaune
|
|
|
|
|
Thanks David.
The culprit was actually my fault... i used the following code in the OnInitInstance() of the view classes:
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
regards.
|
|
|
|
|
Hey Friends
I am looking to get a list of applications running, or to be more specific i need main window handle only as task manager displays.
Tried EnumWinndows, but it gives many many windows, which i do not want
Many Window(s) have parent Window as 0
Looks like EnumWindows is correct way
Need Help.
Regards
|
|
|
|
|
In addition to that you should check the window styles. That is you can avoid the invisible windows, child windows, etc.
- ns ami -
|
|
|
|
|
Check this[^]
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
Hi experts,
How I can change length of dialog box at run time?
|
|
|
|
|
CWnd::SetWindowPos[^] to the rescue.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
|
|
Hello,
i've a problem with a subclassed CEdit on WindowsCE 5.0.
If i use SetPasswordChar and SetFont in the same subclassed CEdit it generates an acces violation
[Stack fault]: Thread=9a431400 Proc=98328d20 'xxxxxx.exe'
AKY=00004001 PC=0017ba6c(xxxxxx.exe+0x0016ba6c) RA=000318e8(xxxxxx.exe+0x000218e8) BVA=1e2a1ee4 FSR=00000007
my Code:
...
if(edit->SubclassDlgItem(IDC_EDIT1, this)){
edit->SetFont(m_Font, FALSE);
edit->SetPasswordChar(0x25CF); // --> stack fault
}
...
If i don't use SetFont OR SetPasswordChar it works fine...
whats wrong ???
can anybody help me?
Thanx for replys...
edit:
// Initialization
Controls.edit2 = new CMyEdit();
Controls.edit2->__SubClassControl(this, IDC_EDIT2);
Controls.edit2->__SetMaxTextLength(9);
//Controls.edit2->SetPasswordChar('*'); // --> stack fault
Controls.edit2->SetPasswordChar(0x25CF); // --> stack fault
// Control-Code
BOOL CMyEdit::__SubClassControl(CMyDialog *pParent, int nID)
{
// subclassing per SubclassDlgItem is okay, SubclassWindow does not work
m_pParent = pParent;
m_nID = nID;
BOOL ret = SubclassDlgItem(m_nID, m_pParent);
// changing FontSize to parentfont and the heigth of the Control
LOGFONT lf;
if(m_pParent->GetFont()->GetLogFont(&lf) != 0){
// m_Font is a derived class from CFont and an Item of my CMyEdit for better Fonthandling
// if i use CFont the same Problem exist with SetPasswordChar (isn't the reason)
m_Font->_SetLogFont(lf);
if(m_bFontResizing == TRUE){
CRect rect;
GetClientRect(&rect);
rect.DeflateRect(2,2,2,2);
m_Font->_SetHeight(rect.Height());
}
SetFont((CFont*)m_Font, FALSE);
}
return ret;
}
void CMyEdit::__SetMaxTextLength(int maxLen)
{
m_maxLen = maxLen;
// del mask
m_Mask = _T("");
}
modified on Friday, January 23, 2009 7:14 AM
|
|
|
|
|
No real idea here but what happens if you change the order, use SetPasswordChar first and then use SetFont? Any change?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
i try it, but it has no effect...
the message EM_SETPASSWORDCHAR raises the error, mfc is not the reason...
|
|
|
|
|
So let me get this clear:
edit.SetFont(somefont);
edit.SetPasswordChar(whatever); <- it crashes here
crashes and
edit.SetPasswordChar(whatever); <- it crashes here again, so SetFont never gets called
edit.SetFont(somefont);
crashes too but
edit.SetPasswordChar(whatever); <- works ok, no SetFont around
works. That is very strange, i don't really see the great difference between the later two cases since SetFont never gets called at all in either case.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
not directly...
edit.SetFont(somefont);
edit.SetPasswordChar(whatever); <- it crashes here
edit.SetPasswordChar(whatever);
edit.SetFont(somefont);<- it crashes here
edit.SetPasswordChar(whatever); <- works ok, no SetFont around
i check now if the subclassing is the reason...
wait a moment...
|
|
|
|
|
Ah, i see. Where do you perform all this? I mean, the subclassinc of the edit and the rest? I mean, in what method, at what event...?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
in OnInitDialog...
i've rewritten a little class to encapsulate this problem, it looks like a WindowsCE-Problem...
in Win32 works fine...
edit:
give up...
in pocketpc-emulator it works always fine :-|
it must be devicedependend or a devicemistake...
|
|
|
|
|
If your edit control is set to multiline, that could be the problem. MSDN states that SetPasswordChar is not supported on multi-line edit controls.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
MSDN says the Function has on effect in multineedit...
i test it...
edit: tested, but no effect
|
|
|
|
|
Here's a quote from MSDN:
Remarks
When a password character is set, that character is displayed for each character the user types.
This member function has no effect on a multiple-line edit control.
When the SetPasswordChar member function is called, CEdit will redraw all visible characters using the character specified by ch.
If the edit control is created with the ES_PASSWORD style, the default password character is set to an asterisk (*). This style is removed if SetPasswordChar is called with ch set to 0.
For more information, see EM_SETPASSWORDCHAR in the Platform SDK.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|