|
If you are using resource editor, you can set the tab order there. It is available in "Layout" menu in VC6 and "Format" menu VC9. Shortcut key is Ctrl + D (in VC6 keyboard shortcut map). Then you can see the tab order indication for all controls. You can click on each controls to sequence.
If you are creating the controls dynamically, the creation order sets the tab order. You can change it by using SetWindowPos().
- ns ami -
|
|
|
|
|
Hi ns Ami,
I am creating dynamic edit box in Group Box. My current Tab order is Group Box, OK, Cancel button. Now I want tab order as:
Group box-> Edit Box 1 -> Edit Box 2 -> Edit Box 3 -> OK -> Cancel.
How can i achieve this? do you have any idea?
Regards,
Anshul
|
|
|
|
|
I presume that "dynamic edit box" means you are creating edit box dynamically at run time. If so, you can use SetWindowPos API to set the Z-order of edit control. You will get more information from the API documentation. The parameter hWndInsertAfter (or pWndInsertAfter in the case of MFC) can be the window handle of control, which is needed to be before in tab order.
For example,
m_edit2.SetWindowPos( &m_edit1, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZER | SWP_NOACTIVATE );
This will set the tab order as edit1 -> edit2.
Hope this info will help.
- ns ami -
|
|
|
|
|
Hi Ami,
I am creating edit box in Group box as:
#define ID_CURRENT_SN_EDIT 2000
m_gbGroupBox = (CStatic*)GetDlgItem(IDC_GROUPBOX);
int pointY = 0;
int i = 0;
for (int x = 0; x < m_vecpData->size(); x++, i++)
{
pointY = 30 + (i * 35);
m_ceEdit = new CEdit;
m_ceEdit->Create(WS_VISIBLE| WS_BORDER |ES_READONLY | WS_TABSTOP, CRect(10, pointY, 130, pointY + 25), m_gbGroupBox, ID_CURRENT_SN_EDIT + i);
m_ceEdit->SetWindowText(m_vecpData->at(x).c_str());
m_ceEdit->SetWindowPos(m_gbGroupBox, HWND_BOTTOM , 10, pointY, 130, pointY + 25, SWP_NOSIZE);
m_ceEdit->ShowWindow(SW_SHOWNORMAL);
}
|
|
|
|
|
In this case the tab order will be same as the creation order. So no need to set the Z-order again. Anyway, is this a compilable code? Argument count of SetWindowPos seems as wrong.
Note that you are creating edit control as child of that GroupBox (a static control, i think). In that case the tab key navigation will not enter to the controls inside the GroupBox. Applying WS_EX_CONTROLPARENT style to GroupBox will help you.
For instance,
m_gbGroupBox->ModifyStyleEx( 0, WS_EX_CONTROLPARENT );
- ns ami -
|
|
|
|
|
This is my modified compilable code but tab order is not working as GRPBox -> Edit 1 -> Edit 2 -> Edit 3 -> OK -> CANCEL.
It is still working as GRPBox -> OK -> CANCEL.
#define ID_CURRENT_SN_EDIT 1003
m_gbGroupBox = (CStatic*)GetDlgItem(IDC_GROUPBOX);
m_gbGroupBox->ModifyStyleEx( 0, WS_EX_CONTROLPARENT);
m_btnOK = (CButton*)GetDlgItem(IDC_OK);
m_btnCancel = (CButton*)GetDlgItem(IDC_CANCEL);
int pointY = 0;
int i = 0;
for (int x = 0; x < m_vecpData->size(); x++, i++)
{
pointY = 30 + (i * 35);
m_ceEdit = new CEdit;
m_ceEdit->Create(WS_VISIBLE| WS_BORDER |ES_READONLY, CRect(10, pointY, 130, pointY + 25), m_gbGroupBox, ID_CURRENT_SN_EDIT + i);
m_ceEdit>SetWindowText(m_vecpData->at(x).c_str());
int nCtlrID = ID_CURRENT_SN_EDIT + i;
if (x > 0)
{
CEdit* pEdit = (CEdit*)GetDlgItem(nCtlrID - 1);
m_ceEdit->SetWindowPos(pEdit, 10, pointY, 130, pointY + 25, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
}
m_ceEdit->ShowWindow(SW_SHOWNORMAL);
}
Any Help or Suggestion!! I do not know what to do now.
|
|
|
|
|
Well, you missed WS_TABSTOP style.
AJ83 wrote: m_ceEdit->Create(WS_VISIBLE| WS_BORDER |ES_READONLY, CRect(10, pointY, 130, pointY + 25), m_gbGroupBox, ID_CURRENT_SN_EDIT + i);
And the following is not needed...
AJ83 wrote: if (x > 0)
{
CEdit* pEdit = (CEdit*)GetDlgItem(nCtlrID - 1);
m_ceEdit->SetWindowPos(pEdit, 10, pointY, 130, pointY + 25, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
}
m_ceEdit->ShowWindow(SW_SHOWNORMAL);
- ns ami -
|
|
|
|
|
Hey Ami,
Thanks a lot for your valuable suggestion. It is working now. great :) !!!
Now my another task is:
There is one Static GRPbox which has been created in CFormView by using ToolBox. Now in Static Groupbox, I am creating "n" number of dynamic GrpBox. In Dynamic GrpBox, I am creating dynamic Edit Box (few are READ ONLY too).
Now I have to set taborder for that also. Any suggestion on this.?
Regards,
Anshul
|
|
|
|
|
I believe that, since you could understand your first solution well, you can implement this easily.
Or, are you in any trouble with that?
- ns ami -
|
|
|
|
|
Well, In first round it is working but once it comes to OK or CANCEL button is not going back to edit box.
I am trying for that...
I will post code after few minutes or if you do have idea of why is it not coming back to edit box, you can let me know..
Regards,
Anshul
|
|
|
|
|
Hi Ami,
My problem has been resolved. your given suggestion worked out.
Thanks a lot once again..... :)
|
|
|
|
|
how to get the full length of the string that contains 0's inbetween.
I tried _tcslen() on the LPCTSTR, but it gives the string len till the first occurrence of a 0.
TIA
|
|
|
|
|
But in that case, how will you find the end of the string?
|
|
|
|
|
Are you talking about a 0 or a NULL present in your string.
If it's a 0, it shouldn't be a problem.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
you may try this :
CString strTemp;
---
--
--
// if you need length of string
strTemp.GetLength ();
|
|
|
|
|
ThisIsMeRon wrote: string that contains 0's inbetween.
In this case how do you know the end of string?
In this manner, normally the last string will be ending with two consecutive nulls (0s). Is your string so?
- ns ami -
|
|
|
|
|
hey guys I fixed it. It wasn't a 0 problem.
|
|
|
|
|
- ns ami -
|
|
|
|
|
|
You gotta set "Right To Left" attribute for any edit box you wanna use Arabic in it. Don't confuse with "Right Align"!
|
|
|
|
|
I am not confused with Right Alignment. What is confusing and not clear is the misplacement of the closing brackets.
|
|
|
|
|
Hi All
i am useing hide dialog for this function RunModalLoop(). it's working well but problem is that it's flash on screen then hide.I don't want to flash on screen.So how can i do?Plz help me
|
|
|
|
|
|
ok
I am useing code in abc.cpp class in this function
BOOL CABCApp::InitInstance()
{
CABCDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse;
if (m_lpCmdLine[0] == _T('h'))
{
dlg.Create( CABCDlg::IDD );
dlg.ShowWindow(SW_HIDE );
nResponse = dlg.RunModalLoop();
}
else
{
nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
}
}
Plz help me
|
|
|
|
|
Untick the visible style ( WS_VISIBLE ) style of the dialog and try again.
|
|
|
|