|
Hi All,
When I clickoon system tray icon first time menu works fine , but second time I am getting error like this ;
"Debug assertion failed!
Program: ...
File: F:\rtm\vctools\vc7libs\ship\atlmfc\winmenu.cpp
line 84
retry abort "
code is goes like:
LRESULT CDialogOnTopDlg::onTrayNotify(WPARAM wParam,LPARAM lParam)
{
UINT uMsg = (UINT) lParam;
switch (uMsg )
{
case WM_RBUTTONDOWN:
m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
CPoint pt;
GetCursorPos(&pt);
m_TrayMenu.GetSubMenu(0)->TrackPopupMenu(0,pt.x,pt.y,this);
break;
}
return TRUE;
}
Plz tell me wot could be possible causes.
|
|
|
|
|
My guess would be that you already have that menu loaded and you try to load it again using the same CMenu, either load it once or delete/destroy it before you try to load it again.
> 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. <
|
|
|
|
|
yes you r correct, actully i am using same menu for right click on tray icon and right click on dialog box (anywhere on dialog box),
so plz tell me hadnle same menu for these two things? how to destroy/delete after work os done?
|
|
|
|
|
Well, i think you can do generally 2 things:
1. Load your menu only once and keep it around until your program exits (for example you can load it in the OnInitDialog of your dialog)
2. Load, use and destroy it "on sight", for example, you can use TrackPopupMenuEx[^] with TPM_RETURNCMD, if you do this, when the TrackPopupMenuEx call finishes you will get the command back from the call telling you what the user clicked on (or 0 if he dismissed the menu) and then you can use DestroyMenu[^] to destroy it. Of course doing so you will no longer need your CMenu to hang around so you can make it a local variable and then it will destroy the menu in its destructor when your method exits.
Judging by what i have seen of your code i guess for you the first aproach could be better.
> 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'm certain code-o-mat is correct in his answer to you.
But you really should have used the debugger to see the actual ASSERT line - that will give you lots of information you need to fix your own problem. I/we don;t mind helping - but you are much better learning debugging skills to find the issue out your self.
I bet the ASSERT line was something like:
BOOL CMenu::LoadMenu (UINT nBlah)
{
ASSERT (m_hMenu == NULL);
which would have told you what your problem was.
And that's more than half the battle of solving the problem.
Iain.
Codeproject MVP for C++, I can't believe it's for my lounge posts...
|
|
|
|
|
crazy_sam wrote: m_TrayMenu.LoadMenu(IDR_MENU1); // second time crashing here
Make m_TrayMenu local to the OnTrayNotify() method.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I am using MFC picture control for displaying bmps on property dialog boxes. So I added picture contrl from the tools and changed the type to bitmap. Then selected a bmp resource to be loaded into the control. At design time the bmp is visible but at run time its not. I have done this before but the project used a MBCS. Now its Unicode.
Does that matter? If not what might be the problem?
TIA
|
|
|
|
|
Can you show your code ?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
There is no code actually. Its all done in design time.
|
|
|
|
|
Did you change from MBCS to Unicode in the same project? If yes, try cleaning and rebuilding the whole project if you did not try it yet.
> 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. <
|
|
|
|
|
Thats the thing Im doing now.. I'll let you know..
|
|
|
|
|
But I added a new dialog, placed a picture control on it and loaded a bmp. It works fine in unicode also. I think it should not be specific to property sheets.
what do you say ?
|
|
|
|
|
Hi,
Cant you help me?
what is the command for c++ if i want to read the line but with the condition.
if LINE contains "my" copy the whole LINE.
example:
myData.txt
1. Hello my dear!
2. Good day!
when i access the myData.txt the first line is "Hello my dear!"
i want to copy the line if contains "my" .
thanks
|
|
|
|
|
Common sense says:
- Read a line (exit on 'no-more-lines' condition).
- Search for
"my" inside the read string. - Copy the line if the search of point (2) was succesful.
- Goto point (1).
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]
|
|
|
|
|
thanks but my question is "What is the command?"
|
|
|
|
|
If you're using MFC , the CString::Find method [^] is the proper 'command'.
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]
|
|
|
|
|
i will try this..
thanks...
|
|
|
|
|
Hey, nice algo. I doubt he could convert it into proper code. But he should !
|
|
|
|
|
can you help me?
its like in visual basic, but im beginner in c++.
InStr(1, line, "string", vbTextCompare)
thanks
|
|
|
|
|
Along with the link given by CPallini, you can have a look at this[^] for reference if you aren't using MFC.
|
|
|
|
|
mac_g wrote: what is the command...
There is no single command to do this. It will all depend on what type of variable you are reading the line of text into (e.g, CString , string , char ).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
I developed an MFC SDI application.I need to provide multimonitor support for my application.
Can any body help ...me on this issue..
Thanks in Advance,
Ashok.
|
|
|
|
|
ashokbngr wrote: I need to provide multimonitor support for my application.
Is this your requirement or your issue?
(just joking...)
- ns ami -
|
|
|
|
|
|
Thanks for the information..
If I move my application to another monitor..How to get and set the coordinates of the monitor( I mean at (0,0) location of the other monitor).
Thanks in advance,
Ashok.
|
|
|
|