Solved

MDI Message Loop

Posted on 1997-03-10
4
287 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
  • 2
4 Comments
 
LVL 1

Expert Comment

by:winmeister
Comment Utility
// Enter main message loop

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

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


0
 

Author Comment

by:makhlouf
Comment Utility
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
Comment Utility

0
 
LVL 2

Accepted Solution

by:
r parkinson earned 50 total points
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now