Solved

MDI Message Loop

Posted on 1997-03-10
4
293 Views
Last Modified: 2013-12-03
How should the message loop be written in a Windows 95 MDI application so that the application can recieve WM_COMMAND messages using the Keyboard accelerator. ?
I am using BorlandC++ ver 4.02 and write my program in plain C language.
0
Comment
Question by:makhlouf
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 1

Expert Comment

by:winmeister
ID: 1334197
// Enter main message loop

while (GetMessage(&msg, NULL, 0, 0))

    if (!TranslateMDISysAccel(hwndMDIClient, &msg))
      {
            TranslateMessage(&msg);
            DispatchMessage(&msg);
      }


0
 

Author Comment

by:makhlouf
ID: 1334198
When I submitted my question, I already had the loop suggested by
Charles Petzold in his book "Programming Windows 95"
It looks like this

while (GetMessage (&msg, NULL, 0, 0))    {
    if (!TranslateMDISysAccel (hwndClient, &msg) &&
        !TranslateAccelerator (hwndFrame, hAccel, &msg))  {
        TranslateMessage (&msg) ;
        DispatchMessage (&msg) ;
    }
}
Unfortunatly, it does not work.
yours is a sub version of Petzold and does not work also.
I compiled my program with your version of the loop and found that the program does not receive WM_COMMAND messages when I enter a command with the KeyBoard Accelerator
0
 

Author Comment

by:makhlouf
ID: 1334199

0
 
LVL 2

Accepted Solution

by:
r parkinson earned 50 total points
ID: 1334200
If you are using the following message loop :

if(!TranslateMDISysAccel(hwndMDIClient,&msg)&&
  !TanslateAccelerator(hwndFrame,hAccel,&msg))
{
   TranslateMessage(&msg);
   DispatchMessage(&msg);
}

and it does not work then check the following :

1) have you loaded the accelorator table correctly?

e.g.

hAccel=LoadSccelerators(hInstance,MAKEINTRESOURCE(ID_ACCEL));

if this fails then the message loop wont work.  There are two likly reasons for failure, either the ID is wrong or the table is not in the module pointed to by the hInstance parameter.

2)  Are you checking for the WM_COMMAND message in the main window proc or the child window proc?

the message should be sent to the main window proc, i.e. the proc that was defined for the hwndFrame handle.

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question