Solved

MDI Message Loop

Posted on 1997-03-10
4
294 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

627 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