|
Thanks Ryan.
That worked. I just put
HMENU hMenu = ::LoadMenu(NULL,MAKEINTRESOURCE(IDR_MYNEWMENU));
::SetMenu(AfxGetMainWnd()->GetSafeHwnd(),hMenu);
::DrawMenuBar(AfxGetMainWnd()->GetSafeHwnd());
in OnInitialUpdate() in the (second) doc.
I just mistakenly thought that specifiying a unique view and a unique menu resource in an MDI app with document templates should work the way I intended.
|
|
|
|
|
flip wrote:
That worked
Good
flip wrote:
I just mistakenly thought that specifiying a unique view and a unique menu resource in an MDI app with document templates should work the way I intended
Unfortunately, it doesn't
Well I've never got it to work, anyway
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hello
I'm writing an application which needs to be run in Systray. This systray icon has a popup menu attached with it. The problem after activating that menu if I click on any other application or any other part of desktop the menu is not deactivated. It's only deactivated if I choose one of the menu elements. I'm using MFC dialogs and my class is subclassing CDialog. I'm creating invisible window in this class. I'm not able to solve this problem.
If anyone knows how to solve this problem please help me with an example.
anxiously waiting for reply
Thanks in advance
Hari.
|
|
|
|
|
|
This is documented in the MSDN docs. The solution is to set your hidden window to be the foreground window before calling TrackPopupMenu() and send a dummy message to your window afterwards:
SetForegroundWindow();
menu.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RIGHTBUTTON, point.x, point.y, this, NULL);
PostMessage(WM_NULL); Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
My Program is trying to open a file, I it comes back with a CFileException::sharingViolation, Is there any way i can find our the process that has the file open/locked?
|
|
|
|
|
|
Thank you, I Used this to work out what was holding the file open, But what i was hoping for was to be able to report from my program the PID of the Naughty Process.
|
|
|
|
|
|
IHTMLWindow3::get_screenLeft(),IHTMLWindow3::get_screenTop() and IHTMLElement2::getBoundingClientRect() seem promising, but i had difficulties to make them work with iframe elemens TIA
|
|
|
|
|
While creating my owner-drawn button class I encountered such a mmm... problem.
E.g. when you launch your app in Visual Studio you can press a button on the toolbar or Ctrl+F5. In the first case standard Windows buttons doesn't draw the focus rectangle untill you press the Tab button, but in second case they draw that damn rect.
How can I do the same.
|
|
|
|
|
I would like to be able to create a CFrameWnd derived class that doesn't need a toolbar. Right now I have a single doc/view architecture and if I remove IDR_MAINFRAME (default menu item), I get an error about not being able to create an empty document. How does one get rid of the toolbar?
Cheers,
Clint
|
|
|
|
|
One way would just be to hide it before the app becomes visible.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Your toolbar is a member variable inside your CFrameWnd-derived class. Just delete the variable and all references to it, and it won't be there.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
clintsinger wrote:
How does one get rid of the toolbar?
Go to CMainFrame::OnCreate() and remove the line that creates the toolbar.
--Mike--
"So where does that leave us? Well, it leaves us right back where we started, only more confused than before." -- Matt Gullett
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I' have a little problem with keyboard input. For control input (shift, crtl, arrow,...) Virtual keys are defined and is use them in th OnKeyPressed function (like you see in de code).
If i press the shift button, is see the right messageBox, if i press the up arrow nothing happens. But if i hold the up-arrow down, and press another key i get a messagebox saying "up key pressed", so the problem is not that the virtual key is wrong, but that no KeyPressed event is fired when the up arrow is pressed. Why? And even more important, what to do about it?
Here's the code
void CKeyboardDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if(::GetKeyState(VK_SHIFT) <0)
MessageBox("Shift pressed");
if(::GetKeyState(VK_UP)<0)
MessageBox("up arrow pressed");
...
}
|
|
|
|
|
There are various kbd messages you need to handle depending on what you want to process: WM_KEYDOWN/UP, WM_SYSKEYDOWN/UP, WM_CHAR, WM_SYSCHAR, WM_DEADCHAR, WM_SYSDEADCHAR.
This is all documented in the SDK Help!
UpArrow etc. are WM_SYSKEYxxx messages from memory.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Dialog boxes are notorious for stealing keypresses, such as Enter, Tab, or the arrow keys. Have a look at the WM_GETDLGCODE message, specifically at the DLGC_WANTALLARROWS flag. Your code is correct, you just need to handle WM_GETDLGCODE as well.
Hope this helps,
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
I was wondering how I get a key pressed that isn't handled by my CView derived class to be passed down to the CFrameWnd container that it is sitting in. I have a OnkeyDown in my CView class and one in my CFrameWnd class. When I fire a keydown event by typing on the keyboard, I only get the message as far as my CView class. What do I need to do so it propagates down to the CFrameWnd class?
Cheers,
Clint
|
|
|
|
|
Put this in your CView::OnKeyDown()
GetParent()->PostMessage(WM_KEYDOWN,nChar,MAKELONG(nRepCnt,nFlags));
John
|
|
|
|
|
Hi,
When a program have a Memory leak, do I get back the memory after the app close? Or is the memory lost until windows restart?
Thanks
Everything's beautiful if you look at it long enough...
|
|
|
|
|
MemLeak wrote:
do I get back the memory after the app close
In most cases you should.
John
|
|
|
|
|
Hi,
I was wondering how to changed the enabled/disabled state of a command button by using messages. Im not using MFC for this so I need to know the proper message to send to it and how to set up the data that goes with it (if it can be done this way).
Thanks in advance
Zak
|
|
|
|
|
One solution is SendMessage().
SendMessage(hButton, WM_ENABLE, static_cast<wparam>(/*TRUE or FALSE*/), 0);
Kuphryn
|
|
|
|
|
If you mean buttons on a dialogbox, you can do the following:
GetDlgItem(IDC_NAMEOFBUTTON)->EnableWindow(TRUE);
TRUE enables, FALSE disables (which is logic)
You cannaot only use this for buttons but for every kind of control (radio buttons, text fields,...
Zedd
|
|
|
|