Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MDI Message Loop

Posted on 1997-03-10
4
Medium Priority
?
295 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 150 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

Enroll in September's Course of the Month

This month’s featured course covers 16 hours of training in installation, management, and deployment of VMware vSphere virtualization environments. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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