Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

A doubt on accelerator & tab order

I have implemented property sheet inside a modal dialog box( as given in CodeGuru by Zafir Anjum ). My property sheet has 8 pages. Each page is having lots of controls. The parent dialog box is also having some buttons. I have given accelerators for those buttons.

1) The problem is that when ever the focus is on the property sheet those accelarators are not working. Actually I have overridden the PreTranslateMessage() of the dialog to to add accelarators. Can someone help me out from this.

2) Another problem is regarding the Tab order. When I press tab key only the first control inside every property page is getting focused. After that the focus is changed to buttons in my dialog box. I have got lots of control in each page which are not getting focused by the tab key. I think I have a solution for this but don't how to achieve it. If I give the dialog box buttons a tab order starting with the biggest tab order in my property sheet, this may get solved. But how can I give a constant tab order the buttons?

Hope someone out there have a solution for my problems.
0
prasanthpooyath
Asked:
prasanthpooyath
  • 10
  • 6
1 Solution
 
ZoppoCommented:
Hi ,

1) try to add a PreTranslateMessage to the property sheets too and there call the parent dialog's PreTranslateMessage first.

the problem 2) may get solved with assigning the WS_EX_CONTROLPARENT style to the property sheets.

hope that helps,

ZOPPO
0
 
prasanthpooyathAuthor Commented:
Hi Zoppo,
   I have already added the WS_EX_CONTROLPARENT style to propertysheet. Even then its not working.

Prasanth
0
 
ZoppoCommented:
hmm, sorry, maybe you need to set this style to the parent of the property sheets (the tab control).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
prasanthpooyathAuthor Commented:
Parent of my propertysheet is a Modal Dialog box. So u mean that I should set that style to my dialog box?
0
 
prasanthpooyathAuthor Commented:
Parent of my propertysheet is a Modal Dialog box. So u mean that I should set that style to my dialog box?
0
 
prasanthpooyathAuthor Commented:
I tried that 2.. Again not working.. :-( I have used a custom made spin control in each of my pages. I have a feeling that after the focus is in this spin control, it is not moving to the next item in the page. I have used the code from CodeGuru for the spin control. (http://codeguru.earthweb.com/controls/SpinEdit.html ) Can that be my problem?
0
 
ZoppoCommented:
no, sorry, I think I get a bit confuzed with property-sheets and -pages.

I think it needs to be somehow like this:
dialog: doesn't need special styles for this
property-sheet (the tab control as parent of the property pages): need style WS_EX_CONTROLPARENT
property-page (the child dialogs): set style DS_CONTROL for these

see MSDN about DS_CONTROL:
----------------------------------------------------------------------------------------
DS_CONTROL: Creates a dialog box that works well as a child
 window of another dialog box, much like a page in a property
sheet. This style allows the user to tab among the control
windows of a child dialog box, use its accelerator keys, and so on.
----------------------------------------------------------------------------------------

maybe this helps solving the accelerator problem too.

ZOPPO
0
 
prasanthpooyathAuthor Commented:
I tried that 2.. Again not working.. :-( I have used a custom made spin control in each of my pages. I have a feeling that after the focus is in this spin control, it is not moving to the next item in the page. I have used the code from CodeGuru for the spin control. (http://codeguru.earthweb.com/controls/SpinEdit.html ) Can that be my problem?
0
 
prasanthpooyathAuthor Commented:
I tried that 2.. Again not working.. :-( I have used a custom made spin control in each of my pages. I have a feeling that after the focus is in this spin control, it is not moving to the next item in the page. I have used the code from CodeGuru for the spin control. (http://codeguru.earthweb.com/controls/SpinEdit.html ) Can that be my problem?
0
 
prasanthpooyathAuthor Commented:
I tried setting DS_CONTROL style with my property pages. Again not working. I think the spincontrol is troubling me 'cos after the focus is in the spincontrol only this problem arises. Thanx for the accelerator help. I added the PreTranslateMessage to my property sheet and i think its working fine.
 
     I need another favour. In each of my propery pages I have lot of controls including edit controls, radio buttons, check boxes etc. I was thinking of a good way to handle these controls. Like, if I use the DDX/DDV for each control its virtually impossible. Is it possible to add an array of controls(ex. Edit controls) in DDX/DDV? Since I have a lot of edit controls, I thought this would be the best idea. Do u have any idea on this?
0
 
ZoppoCommented:
well, you can use an array of i.e. CEdit controls, i.e.:

// sample for four edit controls

// in header
const int iEditNum = 4;
const int iEditCtrl[iEditNum] = {
 IDC_EDIT1,
 IDC_EDIT2,
 IDC_EDIT3,
 IDC_EDIT4,
};

class CDtDlg : public CDialog
{
...
public:
// Dialog Data
 //{{AFX_DATA(CDtDlg)
 enum { IDD = IDD_DT_DIALOG };
 //}}AFX_DATA
 CString     m_szEdit[iEditNum]; // make sure this is outside of AFX_DATA block
...
}

// in .cpp file
CDtDlg::CDtDlg(CWnd* pParent /*=NULL*/)
     : CDialog(CDtDlg::IDD, pParent)
{
 //{{AFX_DATA_INIT(CDtDlg)
 //}}AFX_DATA_INIT
 for ( int i = 0; i < iEditNum; i++ )
  m_szEdit[i] = _T("");
...
}

void CDtDlg::DoDataExchange(CDataExchange* pDX)
{
 CDialog::DoDataExchange(pDX);
 //{{AFX_DATA_MAP(CDtDlg)
 //}}AFX_DATA_MAP
 for ( int i = 0; i < iEditNum; i++ )
 {
  DDX_Text(pDX, iEditCtrl[i], m_szEdit[i]);
 }
}


hope that helps,

ZOPPO


BTW, to find out if other problem really comes form the spin control simply try the same dialog without using these spin controls...
0
 
prasanthpooyathAuthor Commented:
I tried replacing the SpinControls with an edit control and it work out well. So the problem resides in the SpinConrtol( http://codeguru.earthweb.com/controls/SpinEdit.html ). BTW, I had a problem with the PreTranslateMessage() part. I had actually called the parent windows PreTranslate first and then the CPropertySheet one to return.

BOOL CDDEPropertySheet::PreTranslateMessage(MSG* pMsg)
{

this->GetParent()->PreTranslateMessage(pMsg);

return CPropertySheet::PreTranslateMessage(pMsg);

}

But I had problems with this sending messages twice to the propertysheet. So now I have made it to return this->GetParent()->PreTranslateMessage(pMsg); I hope there is no problems with this.
0
 
ZoppoCommented:
well, prasanthpooyath, I think best would be to do it somehow like this:

BOOL CDDEPropertySheet::PreTranslateMessage(MSG* pMsg)
{
 BOOL bRet = GetParent()->PreTranslateMessage(pMsg);
 if ( !bRet )
  bRet = CPropertySheet::PreTranslateMessage(pMsg);
 return bRet;
}

otherwise maybe you'll getting problems with pressing
CTRL-ENTER within multi-line edit controls with style
ES_WANTRETURN within property-pages.


Further, I took a look at code for this SpinEdit-control and
think I found the bug. Replace in CSpinEdit::ShowEdit()
following code
...
else if( nChar == VK_TAB )
{
 GetParent()->SetFocus();
}
...
with this code:
...
else if( nChar == VK_TAB )
{
 ((CDialog*)GetParent())->NextDlgCtrl();
}
...

In this way it worked for me.

cheers,

ZOPPO
0
 
prasanthpooyathAuthor Commented:
Hey,,,, Thanx a lot... That worked well.. You were really helpfull.. Once again thanx a lot .....  :-)
0
 
prasanthpooyathAuthor Commented:
Thanx !!!! You were really detail and helpfull ... Best Wishes...
0
 
ZoppoCommented:
you're welcome...

have a nice day,

regards,

ZOPPO
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 10
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now