mfc >> App with multip CFrameWnds

by Adrian Kole » Fri, 21 Nov 2003 00:14:41 GMT

I have an application with multiple CFrameWnd or derived windows: one for
the main window, another for an editor that can pop up that has its own
menu, toolbar, and splitter. Everything works fine (has for years) except
that the editor's menu cannot be accessed from the keyboard. Specifically,
pressing Alt+F pulls up the menu item from the main CFrameWnd window--even
when the editor window has the focus.

- I've tried calling BeginModalState() from the editor. This only seems to
set the modal state for the main window, oddly enough--even though I've
taken care to call this on the editor window.
- I've tried to subclass the editor window to have messages routed to it.
That just locks up the application.
- I've also tried Create()ing the editor window with the pParent argument
set to the main window as well as to NULL--same effect.

Anyone have any ideas. I need to be able to select items from the editor
window when it has the focus.

Thanks in Advance,
Adrian




mfc >> App with multip CFrameWnds

by David Robbins » Fri, 21 Nov 2003 00:45:07 GMT





Specifically,
to

lets see, i think i am doing what you want to do. i have a class derived
from cframewnd, in its constructor i call create like:
DWORD Style = WS_OVERLAPPEDWINDOW | WS_VISIBLE;
Create( NULL, name, Style, CFrameWnd::rectDefault, pView );
where pView is the pointer to the main cframewnd's currently active view...
that may be one thing to try.

in my override of OnCreate i do (among other things):

if( CFrameWnd::OnCreate(lpCreateStruct) == -1 )
return -1;
...
SetIcon(::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON)),FALSE);
WindowMenu.LoadMenu(IDR_MENU);
SetMenu(&WindowMenu);

if( m_ToolBar.Create( this, WS_CHILD | WS_VISIBLE | CBRS_TOP |
CBRS_TOOLTIPS |CBRS_FLYBY ))
if(m_ToolBar.LoadToolBar(IDR_TOOLBAR))
{
m_ToolBar.EnableDocking(CBRS_ALIGN_TOP);
EnableDocking(CBRS_ALIGN_TOP);
DockControlBar(&m_ToolBar);
}

LoadAccelTable(MAKEINTRESOURCE(IDR_BASIC_EDITS));
...
return 0;

where IDR_BASIC_EDITS has things like ctrl+c, ctrl+v, ctrl+x, etc...

the only things in here that may affect your problem i think are the loading
and setting of the menu and the accellerator table.









mfc >> App with multip CFrameWnds

by Adrian Kole » Fri, 21 Nov 2003 03:46:23 GMT

Thanks for the reply.

I tried making the current view of the main window the parent of this other
CFrameWnd-derived window and nothing changed. Have you verified that you
can access the menu items (Alt keys) from the keyboard in your app?





for
except
window--even
it.
argument
editor
view...
SetIcon(::LoadIcon(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_ICON)),FALSE);
loading




App with multip CFrameWnds

by Adrian Kole » Fri, 21 Nov 2003 23:45:19 GMT

Another thing I discovered: if the menu item does not exist on the main
(CMainFrame) CFrameWnd, it will come up in the editor one. So it appears to
be a matter of priority. Does anyone out there know how I can overried the
CMainFrame menu and instead give priority to another CFrameWnd menu when it
has the focus? For instance, if I hit Alt+F, pull up the File menu in the
other CFrameWnd.



other




App with multip CFrameWnds

by David Robbins » Tue, 25 Nov 2003 20:03:38 GMT

yes, the second cframewnd can access menus from the keyboard, even if the
main window has the same menus. i.e. both windows have edit and help menus,
which ever one has focus pulls down its menu for alt-h or alt-e.



to
the
it


you




Similar Threads

1. Service App, Form App, or Console App? - CSharp/C#

2. Console App - howto determine if an app is a console app

How can I find out if an application is a console app or a windows app.
I realize that if there the header starts with 0xd4 0x5a it cannot be
run in "DOS" mode but that not mean a windows 2000 console app. I have
win2k console apps and they also start with 0x4d 0x5a.

thanks for the help


john

3. Problem when connecting Java App with C++ App using Windows So

4. Problem when connecting Java App with C++ App using Windows Socket

I encounter such a strange problem: 
We have a VC++ Application, which needs to communicate with another Java 
application using socket (in VC++ we use Windows socket indeed). The Java App 
acts as the server and VC++ App as the client. The two works well when 
implement them in the same computer. However, if they are implemented in 
different computers, whether in a LAN or in a WAN (acrossing routers), 
problem encounters: the Java App often reported it detects socket error and 
close the socket (and the connection) which the VC++ client makes, then the 
VC++ client will try to reconnect the Java App again, thus result in such a 
situation, the connection is made, then about 20-30 seconds later, the 
connection is closed, then reconnect,... 
We found that often the Java App detected socket error when it tried to 
write data to the client. if there was no data to write to client, Java won't 
detect the socket error. Of course, the link between the two app is OK. 
We don't know why, the Java App is developed by another company, and we 
don't have much experience in Java so we couldn't give much advice to them. 
However, in our point, we think socket programming model is universal 
acrossing different platforms and different programming languages. Maybe we 
are wrong? If we want to communicate Java App using Windows socket, we need 
to do something special ?

Thanks 

Kevin Liu


5. destructor in c++ app opened from c# app

6. Shell out .Net C# app from VB6 app passing parameters

Has anyone used Shell.exe from inside a VB6 app to open 
up a .Net C# app passing into the C# app a parameter? I 
want the user to be able to click on a menu item in VB6 
and pass a "ID-value" to the C# app as a variable / 
parameter.

Thanks!

OhCee

7. Is VB.Net app possible inside c# app? - Microsoft .NET Framework

8. Why x64 app runs slower than x86 app ?

I have played with Parallel Extensions and noticed to my surprise that
executable compiled for x64 runs slower than compiled for x86:

    private static double HeavyMath( int I )
    {
      double D1 = Math.Sqrt( I ) * Math.Pow( I, Math.PI ) * Math.Pow( I, 1 / 
Math.E );
      double D2 = Math.Sqrt( I ) / Math.Pow( I, Math.PI ) / Math.Pow( I, 1 / 
Math.E );
      return D1 / D2 + D2 / D1;
    }

    private static double Sequential( int N )
    {
      double R = 0;
      for ( int I = 1; I <= N; I++ )
      {
        double D = HeavyMath( I );
        R += D;
      }
      return R;
    }

    private static object lockThis = new object();

    private static double Parallel1( int N )
    {
      double R = 0;
      Parallel.For( 1, N + 1,
        I =>
        {
          double D = HeavyMath( I );
          lock ( lockThis )
          {
            R += D;
          }
        }
      );
      return R;
    }

    private static void CallMethod( Func<int, double> M )
    {
      Stopwatch SW;
      double D;
      const int N = 20000000;

      SW = Stopwatch.StartNew();
      D = M( N );
      SW.Stop();
      Console.WriteLine( "{0}: {1:F0}", M.Method.Name, D );
      Console.WriteLine( "{0}: {1} ms", M.Method.Name, 
SW.ElapsedMilliseconds );
    }

    static void Main( string[] args )
    {
      CallMethod( Sequential );
      CallMethod( Parallel1 );
    }

Sequential method takes ~11,2 sec if compiled for x64, but only ~9,8 sec if 
compiled for x86.
Parallel1 method takes ~7,1 sec if compiled for x64, but only ~6,7 sec if 
compiled for x86.

Environment is VS2008, Vista Ultimate 64-bit, Core 2 Duo 2.40 GHz.

Are such times result from use of double arithmetic ?
Or what else ?

Oleg Subachev