Click here to Skip to main content
Click here to Skip to main content

Keyboard messages/accelerators handling in MFC dialog based applications

By , 1 Dec 2001
 

Introduction

There are a substantial number of Windows programmers who insist, often very vehemently, that a programmer should avoid overriding PreTranslateMessage. They have their reasons for saying so and I believe they are correct. But in this article my intention is not to contemplate on whether PreTranslateMessage is good for you or whether you should avoid it like the plague. I have found that PreTranslateMessage can come in quite handy in dialog-based applications for handling keyboard messages. In addition to using PreTranslateMessage I also show you how you can override ProcessMessageFilter for handling accelerator keys in a dialog based application.

Using PreTranslateMessage to handle dialog keystrokes

Very often you hear questions from novice programmers asking how they can trap keystrokes in a dialog based application. Presumably they tried to handle WM_KEYDOWN/WM_KEYUP unsuccessfully. The whole problem is that in a dialog based application the focus is always on one of the child controls and not on the main dialog window. So what do you need to do? You need to override PreTranslateMessage. I'll show you a simple example.

Suppose that you have a dialog based app with a lot of edit boxes on the dialog. It's basically a data entry program and thus you feel it would make it easier for the end-user if pressing the ENTER key would take the focus to the next edit box, just as if he had pressed TAB. The solution is so very easy and straightforward with PreTranslateMessage as I'll demonstrate below.

BOOL CPreTransTestDlg::PreTranslateMessage(MSG* pMsg) 
{
    if(pMsg->message==WM_KEYDOWN)
    {
        if(pMsg->wParam==VK_RETURN)
            pMsg->wParam=VK_TAB;
    }	
    return CDialog::PreTranslateMessage(pMsg);
}

All I have done is to check whether the message is a WM_KEYDOWN, and if it is so, then I check to see if the wParam is VK_RETURN. If I find it so, I change the wParam to VK_TAB and then the base class implementation is called. Easy huh?

Using ProcessMessageFilter to handle dialog-based accelerator keys

Let's say you have a menu in your dialog based app. And you have an accelerator key for some particular task. You'll soon be disappointed to find that the hotkey does not work. The problem is that the modal dialog app's message loop does not call TranslateAccelerator. I do not know why this is so. Presumable the Microsoft team decided that people shouldn't use dialog based apps to write complicated applications, with hotkeys and menus.

But as usual they have suggested a workaround too. Here's is how you go about implementing it. I'd like to state again, that even though this is a Microsoft recommended technique there will be a good majority of MFC gurus, like Joseph Newcomer for example, who would tell you that you shouldn't be doing this. But then sometimes you have to sacrifice elegance for getting things done quickly and with minimum effort.

  • Add a member variable to your CWinApp derived class.
  • HACCEL m_haccel;
  • Use the resource editor to create a new Accelerator, by default it will be named IDR_ACCELERATOR1. And add a new accelerator key that is a short cut for some menu item.
  • Put the following line in your InitInstance just before the line where the CDialog derived object is declared
  • m_haccel=LoadAccelerators(AfxGetInstanceHandle(), 
            MAKEINTRESOURCE(IDR_ACCELERATOR1));
  • Now override ProcessMessageFilter and modify the function so that it looks like :-
    BOOL CPreTransTestApp::ProcessMessageFilter(int code, LPMSG lpMsg) 
    {
        if(m_haccel)
        {
            if (::TranslateAccelerator(m_pMainWnd->m_hWnd, m_haccel, lpMsg)) 
                return(TRUE);
        }
    	
        return CWinApp::ProcessMessageFilter(code, lpMsg);
    }

All we did was to call TranslateAccelerator and if it succeeds then we don't need to call the base class ProcessMessageFilter, as the message has been handled. So we return TRUE.

Disclaimer

The author wishes to state here that the two methods mentioned above are generally used methods and the author is not in any way endorsing these methods. Users should read more on the usage of PreTranslateMessage and ProcessMessageFilter before they use it in their programs.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Nish Sivakumar
United States United States
Member
Nish is a real nice guy who has been writing code since 1990 when he first got his hands on an 8088 with 640 KB RAM. Originally from sunny Trivandrum in India, he has been living in various places over the past few years and often thinks it’s time he settled down somewhere.
 
Nish has been a Microsoft Visual C++ MVP since October, 2002 - awfully nice of Microsoft, he thinks. He maintains an MVP tips and tricks web site - www.voidnish.com where you can find a consolidated list of his articles, writings and ideas on VC++, MFC, .NET and C++/CLI. Oh, and you might want to check out his blog on C++/CLI, MFC, .NET and a lot of other stuff - blog.voidnish.com.
 
Nish loves reading Science Fiction, P G Wodehouse and Agatha Christie, and also fancies himself to be a decent writer of sorts. He has authored a romantic comedy Summer Love and Some more Cricket as well as a programming book – Extending MFC applications with the .NET Framework.
 
Nish's latest book C++/CLI in Action published by Manning Publications is now available for purchase. You can read more about the book on his blog.
 
Despite his wife's attempts to get him into cooking, his best effort so far has been a badly done omelette. Some day, he hopes to be a good cook, and to cook a tasty dinner for his wife.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 3memberSharanyaMahi1 Feb '12 - 0:54 
Thanks a lot for the information..
GeneralMy vote of 5memberRethmeier27 Apr '11 - 22:26 
Exactly what I was looking for! With little MFC knowledge I could finally add keystrokes to a legacy MFC application, thank you!
GeneralMy vote of 5memberMember 774968413 Apr '11 - 11:36 
Finally found what I was looking for, after 3 days of search. Superb site. Best forum for developers!
THANKS NISHANT!!!
THANKS CODEPROJECT!!!!
CHEERS!!!
Raj
GeneralMy vote of 5memberGokulnath0073 Jan '11 - 21:09 
excellent.. wat to say
GeneralAmazingmembervikas02312 Nov '09 - 0:45 
Pretty good article. It works well with accelerators. Earlier I was trying to handle CTRL+ clicks in PreTranslateMessage, the main issue I faced was that if the control is with edit box or some other control, CTRL+ click would not work. For it to start working again, I had to click on the main window(to set focus). But with accelerator, it works really well. No issues faced.
 
One small problem I faced in the beginning was with m_pMainWnd->m_hWnd, which was not defined in the article, but it is actually pointer to CDialog class whose instance is called in InitInstance. One might come across few more problems related to declaring pointer to Cdialog class. One can declare the pointer globally and then assign &dlg to it.(CDialogMain dlg, in my case). All of this will be done in class derived from CWinApp.
 
Cheers,
Generalthanks!memberanowsober19 Jan '09 - 17:30 
3Q
 
china fox also

GeneralAccelerator for child dialogmemberhari_honey20 Aug '08 - 3:01 
I have implemented the given code. It is working fine for main dialog. But for child dialog accelerator keys are not working. Smile | :)
GeneralRe: Accelerator for child dialogmemberDavid Johns21 Sep '10 - 16:07 
Its been forever since you posted this. Did you ever find a solution for this?
GeneralCapture consecutive VK_ENTER messagesmembermrcdsix3 Apr '08 - 8:13 
I have a dialog that needs to capture the Enter key mulitple times. I have impmlemented the PreTranslateMessage as such:
 

if( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN )
{
SetSomeFlag();
return TRUE;
}

 
However, the message does not get handled correctly after the first one(by calling SetSomeFlag()) unless I have a break point set there.
GeneralProblem with PreTranslateMessagememberasi1103 Oct '07 - 21:28 
I have defined this in my dialog class also declared a ON_WM_KEYDOWN()message map, any ideas?
Questioni want to call click event of button with Ctrl + Upmembermaulesh bhojani22 Aug '07 - 5:47 
hi all
i want to call click event of button with "Ctrl + Up" keyboard shortcut.
 
i have used ::PreTranslateMessage(MSG *pMsg) but tell me what could be
value of pMsg->message and pMsg->wParam to handle the same.
 
thanx
 
maulesh

QuestionI need Accelrator table in My Dll?memberramesh_5304 May '07 - 2:14 
how can i use my accelator in my dll?
 
Can you please the code for doing this?
 
and if i use shortcut keys it will work in the main application (My dll functionality as short cut keys)?
 
please give some code snippet, which is useful for my question.....Cry | :((
 
Rammy
Questiononly work after minimized it....help me please.memberfikree15 Feb '07 - 14:55 
i've tried using the code. but i can only use the keyboard input after i've minimized and maximized the program i worked out. any suggestion??Confused | :confused: ??
 
anyway,NICE ARTICLE there. keep up the good work!Smile | :)
 
regards,
fikree
QuestionHow to simulate the mouse behavior holding down a button with a keymemberchen_zd24 Nov '06 - 19:56 
Hello Nish
         I want to simulate the mouse behavior holding down a button with a key in a diglog application, and I tried it with your method. But it doesn't work. When i push down the key,the buton was down then up immeidately even if i am still holding down the key ,the button is just like being clicked not holded down as the mouse can do. I want some tips.
         regards
 
BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
{
      // TODO: Add your specialized code here and/or call the base class
      if(pMsg->wParam==VK_RIGHT){
            if(pMsg->message==WM_KEYDOWN && ((pMsg->lParam>>30 & 1)==0))
            m_myButton.SendMessage(WM_LBUTTONDOWN);
            if(pMsg->message==WM_KEYUP)
            m_myButton.SendMessage(WM_LBUTTONUP);
      }
            return CDialog::PreTranslateMessage(pMsg);
}

 
chenzd
Question! Accelerators Active In Child DialogsmemberSynetech4 Aug '06 - 20:42 
I've run into a bit of a problem with this. I've implemented this solution and it works fine except that the accelerators are active not only for the dialog, but for all child dialogs as well.
 
For example, I set Insert, Delete, and Ctrl+A as accelerators to insert an item, delete an item, and select all items in a list control. This is fine, but when the Insert Item or Delete Prompt dialogs come up, those keys are still active and when pressed, perform their action.
 

It should not call TranslateAccelerator if a child dialog has the focus. I am working around this by having my main dialog have a member boolean which I set to false before running any child dialogs and back to true afterwards. I then change the ProcessMessageFilter function like so:
 
if (m_hAccel) {
to
if (m_hAccel&&((CFooBar*)m_pMainWnd)->m_Focus) {
 
I don't like this because it requires casting to the dialog type and accessing a variable (using an accessor function is even worse), and more importantly, it requires setting/clearing the flag before and after each child dialog.
 

Does anyone have a better solution?
 
Thanks.

 
--
Synetech

AnswerRe: ! Accelerators Active In Child DialogsmemberSynetech7 Aug '06 - 13:46 
Hi,
 
I discussed this with Joe Newcomer who has this in one of his articles and we solved it. Just change this line in ProcessMessageFilter:
  if(m_haccel)
to this:
  if (m_hAccel && m_pMainWnd->IsWindowEnabled())
 
Works like a charm. Cool | :cool:
 
--
Synetech

General! Works GreatmemberSynetech22 Jul '06 - 8:20 
Hi,
 
This works very well. I've been wondering why accelerators don't seem to work in my apps and now I know why (although I'm pretty sure I've read the reason before.) I've added those three tiny pieces of code and now my apps are alive with productivity.
 
Thanks a lot.

 
--
Synetech

QuestionHow to set project for always support hots key ?memberMax++10 Jun '06 - 23:41 
In case,while I'm running another program(minimize the program that support Hots key)It will can't use hots key of the program that I minimize it.
If I want to make it always support although I use another program.
How I do for this case?
AnswerRe: How to set project for always support hots key ?memberSynetech22 Jul '06 - 6:34 
You'll need to register a global hotkey. Here's a couple of articles on that:
 
a short one[^]
 
a longer one by the same author as this one[^]
 

HTH Cool | :cool:
 
--
Synetech

Generalerror C2039: 'ProcessMessageFilter' : is not a member of 'CWinApp'memberatrung5 Jun '06 - 17:53 
Why error???
I used POCKET PC 2003 // Win32(WCE emulator) Debug // POCKET PC 2003 emulator
Please, help me !!! thanks
 
BOOL CEX1App::ProcessMessageFilter(int code, LPMSG lpMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(m_haccel)
{
if (::TranslateAccelerator(m_pMainWnd->m_hWnd, m_haccel, lpMsg))
return(TRUE);
}
return CWinApp::ProcessMessageFilter(code, lpMsg); // =>error C2039: 'ProcessMessageFilter' : is not a member of 'CWinApp'}
 
Thanks
General1000 thx!memberchris mook11 Apr '06 - 3:02 
Smile | :)
QuestionHow to do this to a dialog under a child window?memberkezhu31 Mar '06 - 11:34 
Hi:
 
First thanks to the brief short article that gives a clear explaination.
 
I have an application that has main window and child windows. A dialog box under one child window needs to have accelerators.
 
How can I utilise the method suggested in this article?
 
Thank you for any suggestion/advice.
 

kezhu
QuestionHow to call a current Function now?memberbreak;11 Jan '06 - 2:00 
Hello,
this is great, but how to call any function after press, for example, ctrl + D????

// in my Application Class:
BOOL CDialogApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
if(m_haccel)
{
if (::TranslateAccelerator(m_pMainWnd->m_hWnd, m_haccel, lpMsg))
{
OnClear(); // this funktion should be called after the user have press ctrl + D, this is a Dialogclass member!
return(TRUE); // the program run to here, but they dont call the OnClear(); Funktion???!! Why???
}
}
 
return CWinApp::ProcessMessageFilter(code, lpMsg);
}

 
regards
break;
 

-- modified at 8:01 Wednesday 11th January, 2006
AnswerRe: How to call a current Function now?memberbreak;11 Jan '06 - 3:57 
Hi,
i make them like this, but im not sure that is the best solution!!!
 

BOOL CDialogApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
if(m_haccel) // m_haccel hat den "Alt + D" Code!
{
if (::TranslateAccelerator(m_pMainWnd->m_hWnd, m_haccel, lpMsg))
{
CDialogDlg *cDialog = (CDialogDlg*)AfxGetApp()->GetMainWnd(); // Referenz to the Dialogclass who have this OnClear() Funktion
cDialog->OnClear();

return(TRUE);
}
}
 
return CWinApp::ProcessMessageFilter(code, lpMsg);
}
 
Now when the user press "Alt + D" run this OnClear() Funktion and clear all items(controls) on my dialog, or any other Funktion!
 
break;
 


GeneralACCELERATOTsusssadegh salehi12 Sep '05 - 22:34 
Tanks For ever VC++.net programering.
Roll eyes | :rolleyes: Smile | :) Big Grin | :-D
GeneralThanksmemberfastfootskater29 May '05 - 23:36 
Thank you very much. Your article helped me to safe a lot time and moneySmile | :)

GeneralAwesome job -- one correction however...memberDouglas R. Keesler30 Apr '05 - 16:46 

Awesome job. The ProcessMessageFilter override works beautifully to handle Accelerator keys in a dialog based application.

There is one correction to the article which needs to be made however. Your sample code for the PreTranslateMessage override is incorrect. It must be overridden in the App class, not the Dlg class.

BOOL CPreTransTestDlg::PreTranslateMessage(MSG* pMsg) 
{
    if(pMsg->message==WM_KEYDOWN)
    {
        if(pMsg->wParam==VK_RETURN)
            pMsg->wParam=VK_TAB;
    }	
    return CDialog::PreTranslateMessage(pMsg);
}

If the dialog class received the KEYDOWN message we wouldn't need to mess with this in the first place, we could just implement a message handler. But since the dialog doesn't receive the WM_KEYDOWN message from the App, the PreTranslateMessage override will have no effect here.

However, if you override it in the App class and copy your existing code into that function, the workaround will work like a charm.

Again... Beautiful job. Thanks for sharing.


 

In business, if two people always agree, one of them is unnecessary.

 


GeneralRe: Awesome job -- one correction however...membersmesser30 Apr '05 - 17:21 
I use this in my dialog class and capture KEYDOWN messages without any problems.
 
The dialog class does recieve KEYDOWN messages. However, if you have even one button or control
on your dialog the keypress messages will automatically get sent to the default control on the dialog. This is exactly why I started capturing the KEYPRESSES from PreTranslateMessage(..) to begin with.
 
Hope that makes sense.
 
PS: This info is based on my experience and my opinions.
GeneralRe: Awesome job -- one correction however...memberchakri1623 Nov '05 - 17:55 
hi anu did you get any solution for the problem?
GeneralRe: Awesome job -- one correction however...memberchakri1623 Nov '05 - 17:57 
sorry keesler i replied to wrong location ,this is for anu who is below your message
QuestionWhat if you have an SDI with an dialog inside...memberPandele Florin28 Apr '05 - 5:04 
I have a sdi (single document) with a CSizingControlBarG(see http://www.datamekanix.com[^]) with a property sheet in it.
Obviously the property sheet thinks it is a modal dialog and does not route the
messages for accelerators.
I have solved the problem by calling in the propertysheet's PreTranslateMessage
 

BOOL CSomethingSheet::PreTranslateMessage(MSG* pMsg)
{

if (pMsg->message == WM_KEYDOWN && m_pMainFrame!=NULL)
{
int nVirtKey = (int) pMsg->wParam;
if (::TranslateAccelerator( m_pMainFrame->m_hWnd,m_pMainFrame->m_hAccelTable,pMsg))
return TRUE;
}
return CPropertySheet::PreTranslateMessage(pMsg);
}

where m_pMainframe is a pointer to the CMainFrame object of the application
If anyone has done this before and knows some problems that can show up or knows a better way to solve this, please let me know.
Generalshort but great!!!!5 for thiz!!!!!memberrateep11 Apr '05 - 1:50 
i have voted 5 for thiz.....
 
regardz...
ratz
 
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
GeneralThank you!memberDavide Calabro24 Jan '05 - 4:09 
You saved me a couple of days of diggin' around MSDN & C. !
 
SoftechSoftware
Davide Calabro'
davide_calabro@yahoo.com
http://www.softechsoftware.it
Generalmaking use of just PreTranslateMessagememberPenguen Efendi14 Nov '04 - 9:33 
Hi!
 
Your technique is quite ok. But i've tried my idea of using only PreTranslateMessage. It's a dialog based app and i created an accelerator table, IDR_KISAYOL, by resource editor. In my dialog's class, i added:
 
class CDiaGiris : public CDialog
{
// ...
HACCEL hKisaYol;
// ...
}
 
BOOL CDiaGiris::OnInitDialog()
{
// ...
hKisaYol=LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_KISAYOL));
// ...
}

 
And i overrided dear PreTranslateMessage as follows:
 
BOOL CDiaGiris::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN || pMsg->message==WM_SYSKEYDOWN){
if(TranslateAccelerator(AfxGetMainWnd()->m_hWnd,hKisaYol,pMsg))return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}

 
I had to handle not only WM_KEYDOWN but also WM_SYSKEYDOWN message too, because some keys like F10 come that way. And i know that some keys like VK_DELETE are suspicious to use as an accel key. By the way, when i use TranslateAccelerator without checking the value pMsg->message, my app crashes when it loses focus. Yes, strange.
Anyway, that's all i did. And my accelerator table working ok in my dialog based app now. I don't exactly know if there are some drawbacks but my app seems happy. If someone knows or finds a drawback or something, please let me know. Hmmm | :|

GeneralPreferred solution for WinCEmemberCoruscant25 Apr '05 - 2:12 
Just a note to say that this is the preferred solution for WinCE simply because CWinApp::ProcessMessageFilter is not available under WinCE!
GeneralRe: making use of just PreTranslateMessagememberMohamed Abdel-Monem23 Sep '05 - 5:03 
I prefer to use m_hWnd instead of AfxGetMainWnd()->m_hWnd inorder not to limit this functionality to the application main window only
GeneralEnter key capturememberAchilles28 Sep '04 - 15:37 
Hi;
 
How can I possibly limit the capturing of enter key in a particular control only? Like perhaps I want it to response only when I pressed entry key while I'm in combobox control. Because I believe that with the routine that you gave works in all controls.
 
Thanks in advance.
D'Oh! | :doh:
Generalaccelerator for child dialogmemberanukutty11 Apr '04 - 18:27 
hi
 
i am doing a multidialog application, and i have to add accelerators to a menu in a child dialog(since the dialog has no app class i cant find the 'ProcessMessageFilter'.
Can anything be done about it.
 
anu
GeneralRe: accelerator for child dialogmemberchakri1623 Nov '05 - 17:59 
hi anu did you get solution for the problem you had?
GeneralRe: accelerator for child dialogmemberbreak;11 Jan '06 - 3:13 
Hi,
and how to access the keys "Alt + D" to call some Functions???
This ist what i want to do with the Accelerators! Confused | :confused:
 
regards
break;
GeneralRe: accelerator for child dialogmemberbreak;11 Jan '06 - 3:57 
Hi,
i make them like this, but im not sure that is the best solution!!!
 

BOOL CDialogApp::ProcessMessageFilter(int code, LPMSG lpMsg)
{
if(m_haccel) // m_haccel hat den "Alt + D" Code!
{
if (::TranslateAccelerator(m_pMainWnd->m_hWnd, m_haccel, lpMsg))
{
CDialogDlg *cDialog = (CDialogDlg*)AfxGetApp()->GetMainWnd(); // Referenz to the Dialogclass who have this OnClear() Funktion
cDialog->OnClear();
 
return(TRUE);
}
}
 
return CWinApp::ProcessMessageFilter(code, lpMsg);
}
 
Now when the user press "Alt + D" run this OnClear() Funktion and clear all items(controls) on my dialog, or any other Funktion!
 
break;

GeneralRe: accelerator for child dialogmemberchakri1623 Nov '05 - 19:40 
hi anu I got the solution for the problem and my applivation is now working fine if you want got the following link
http://www.codeguru.com/Cpp/W-D/dislog/tutorials/article.php/c4965"
and i think you had already done with that.
GeneralRe: accelerator for child dialogmemberchakri1623 Nov '05 - 21:37 
hi anu I got the solution for the problem and my application is now working fine if you want got the following link
http://www.codeguru.com/Cpp/W-D/dislog/tutorials/article.php/c4965"
and i think you had already done with that.
Generalthank umemberdivya pg11 Apr '04 - 10:12 
hi nishant
 

It helped me a lot.I used it for my dialog based application .And urs work fine for that.Thank u so much..............
 
divya
Smile | :)
 


QuestionHow to make keyboard accelerators always visible?membernguyen_a5 Apr '04 - 8:12 
Hello,
I have been trying to make the keyboard accelerators (underlines below the function characters) always visible but I was not successful. When the app comes up, the ALT is toggles those accelerators to be visible or not, but never come up "already visible"...
 
First, I tried to use SendMessage to Query (0x129) and then Change (0x127) the UI State but the query always returned zero indicating that the keyboard & focus accelerator are On (not true).
 
Second, I tried to use SendMessage with Update command (0x128) to force the set visibility command to the keyboard accelerators (0x2 in high-order word, 0x1 in low-order word of wParam)
 
Finally, I tried to use CWnd::OnUpdateUIState function as stated in MSDN but then the function does not exist in Visual C++ 6.0
Did I do something wrong or miss something ?

AnswerRe: How to make keyboard accelerators always visible?memberPandele Florin28 Apr '05 - 2:41 
It's a Windows "feature".Lies deeply burried in the display properties/appearance tab/effects (for XP)...
Smile | :)
QuestionHow to control msg in a multi-dll app?memberchifon10 Mar '04 - 1:22 
I have a app which uses dll.
how can i to control the message?
 
if i want to press key 'a' to call the function in first dll, and 'b' to call the function in second dll.
what should i do?
 
i try many times .it failed.Cry | :((
 
please help me. thanks.
Generaldoes not work with CCtrlViewmemberpradeep gurav13 Feb '04 - 6:12 
I am using an instance of a view derived from CCtrlView. Inside this view i add 3 pages to a propertysheet. These 3 pages are created from a dialog resource using
CChildDialog* pDialog = new CChildDialog;
and add controls to it as
treeControl->SubclassDlgItem (IDC_TREE1, GetPage (nIndex));
 
Now as you said I have to add
m_haccel = LoadAccelerators(AfxGetInstanceHandle(),
MAKEINTRESOURCE(ID_HOT_KEY));
before the declaration of CDialog dlg;
I tried at diff places, e.g. just after the
if (!ProcessShellCommand(cmdInfo))
return FALSE;
just before the call
CChildDialog* pDialog = new CChildDialog;
 

But none of these worked. These dialogs are modeless.
 
Can you provide a solution for this?
Thanks,
 


GeneralJust Can't Get EnoughmemberAurimas Amanavičius19 Jan '04 - 8:01 
ghmm
GeneralNeed Help in VC++ (Very Urgent)membereshban28425 Nov '03 - 19:49 
Here is the problem.
 
I have a "Dialog Based Application".I made two "Check Boxes" in a
Dialog. So I want , whenever i press "UP Arrow Key" , a check box
is "checked". And when i release "Up Arrow" a check box is "un-
checked".
 

If anyone know this, then plz help me as soon as possible .
 
I shall be thankful to you.

 
EsHbAn BaHaDuR

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 2 Dec 2001
Article Copyright 2001 by Nish Sivakumar
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid