|
Can you at least show the relevant code?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Most decidedly, this has nothing to do with CFile itself, but that you're doing something wrong. Can you show us your code?
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Without seeing your code, most likely you're trying to open the file with read/write access, which will fail. If you show your code, perhaps we can be more helpful.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi
I used following code to replace my application menu.
CMenu mu;
mu.LoadMenu(nMenuID);
SetMenu(&mu);
DrawMenuBar();
The new menu was loaded. But whenever I tried to get MENU Handle, I will get an assertion error.
CMenu* pMenu = GetMenu();
HMENU hmenu = pMenu->GetSafeHmenu(); --->Assertion error.
How can I solve this?
Thanks,
modified on Wednesday, November 18, 2009 9:04 AM
|
|
|
|
|
I'm not an expert about, but I suppose in not a good idea using a CMenu temporary object.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Do you have any good idea to do this?
What is good way to replace my application menu?
Thanks,
|
|
|
|
|
CPallini wrote: I'm not an expert about, but I suppose in not a good idea using a CMenu temporary object.
Apparently[^], using a local object is the canonical way to set a menu, but CMenu::Detach()[^] nneds to be called before the temp object goes out of scope.
Ah, the beauties of MFC
|
|
|
|
|
Nemanja Trifunovic wrote: Ah, the beauties of MFC
(I would like to know Rajesh's thoughts about...)
Nemanja Trifunovic wrote: Apparently[^], using a local object is the canonical way to set a menu, but CMenu::Detach()[^] nneds to be called before the temp object goes out of scope.
Of course, the canonical way depends on the documentation author of the moment... [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
OK, I just read this post.
Well, I see that MFC is *actually* beautiful. One mistake is that most frequently done by newbies is putting a CFont object on the stack, setting the font of a control with this, and then wondering why it "didn't work". But they'll eventually get things to work and will appreciate the framework.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
transoft wrote: CMenu mu;
mu.LoadMenu(nMenuID);
SetMenu(&mu);
DrawMenuBar();
Is mu local or does it have class scope?
What line of what file is asserting?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
The Debugger did not guide me to there.
Thanks
|
|
|
|
|
Assertions have nothing to do with the debugger. When an assertion fires, you'll see:
Assertion Failed: File %hs, Line %d
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
atlmfc\include\afxwin1.inl: Line 900
Thanks,
|
|
|
|
|
So did you look at line 900 of afxwin1.inl to see what condition is asserting?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
{ ASSERT(this == NULL || m_hMenu == NULL || ::IsMenu(m_hMenu));
I think the menu was destroyed.
|
|
|
|
|
transoft wrote: CMenu* pMenu = GetMenu();
Does not return a CMenu* . You should be calling CWnd::GetMenu() .
|
|
|
|
|
Richard MacCutchan wrote: Does not return a CMenu*.
It does if called in the context of a CWnd -derived class.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
DavidCrow wrote: It does if called in the context of a CWnd-derived class.
My (mis-)reading of the documentation implied that you had to call this on a CWnd object reference.
Mr brain thought he was on holiday ...
|
|
|
|
|
Richard MacCutchan wrote: Mr brain thought he was on holiday ...
Ask Rajesh for a new monkey.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
After the call to SetMenu() you need to call mu.Detach() so the destructor does not destroy the handle.
|
|
|
|
|
I am not quite familar with this search engine!
|
|
|
|
|
Although not a C++ question: go to your home page and click on messages.
|
|
|
|
|
Hello,
I am developing multilingual MFC application.
My application has very heavy GUI, and I want to create resource DLL for each language, which my application load at run time when needed.
So I want to make resource DLL for application per language which just contain "string table" nothing else, and remaining resource should use from application default resource.
Basic requirement:
1) Don't want to redundant Image, Dialog and Menus in each resource DLL.
Can anyone suggest way for same?
Parag Patel
Sr. Software Eng, Varaha Systems
|
|
|
|
|
ParagPatel wrote: Don't want to redundant Image, Dialog and Menus in each resource DLL.
You just need to create a resource set comprising strings only. If there are any other auto-generated items they can be deleted.
|
|
|
|
|
Thanks Richard,
But I want to in a way so I no need to do any compilation and code change to support new language. Thats way i was preferring separate resource DLL.
What is your view/solution?
Parag Patel
Sr. Software Eng, Varaha Systems
|
|
|
|