-
September 12th, 2005, 10:28 AM
#1
opposite to GotoDlgCtrl?
how to get from dialog (or property page) it's focused control?
(asking for GetFocus asks whole system, not concrete dialog)
thanks
-
September 12th, 2005, 12:48 PM
#2
Re: opposite to GotoDlgCtrl?
Why would you like to know that ?
-
September 12th, 2005, 02:46 PM
#3
Re: opposite to GotoDlgCtrl?
i just want to save it and than return back - so is there is standard way to get actual state?
(i have not standard problem with loosing alt-letter hotkeys functionality and seems gotodlgctrl (maybe setfocus) helps, seems to me stupid call gotonext and than previous)
-
September 12th, 2005, 05:24 PM
#4
Re: opposite to GotoDlgCtrl?
Can you be more specific?
Do you need something inverse of NextDlgCtrl? Well, it is PrevDlgCtrl.
Furthermore, what if your dialog loses focus when user press ALT comination (or use any other method to set focus on other windows)? It is responsibily of Windows (OS) to save the state of last active control within some Frame/Dialog window.
-
September 13th, 2005, 01:15 AM
#5
Re: opposite to GotoDlgCtrl?
more specific:
function will return me focused control in dialog also when dialog is not "on top"
(when click on button in dialog1 opens another dialog2 i want function asking for hDialog1 will return me id or hwnd of that button (because it was focused before d2 open and will be focused after d2 close))
-
September 13th, 2005, 01:34 AM
#6
Re: opposite to GotoDlgCtrl?
do u want like this.
Code:
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
GotoDlgCtrl(pBoxOne);
-
September 13th, 2005, 02:03 AM
#7
Re: opposite to GotoDlgCtrl?
no
if gotodlgctrl is set-function
i'm searching get-function, it's parameter should be dialog handler
-
September 13th, 2005, 02:35 AM
#8
Re: opposite to GotoDlgCtrl?
maybe is unclear i'm searching get-only function?
i want just find actual state, that will not change by this get-function call
i do not want DM_GETDEFID, i want focused control (it is that you can set by gotodlgctrl)
-
September 13th, 2005, 03:14 AM
#9
Re: opposite to GotoDlgCtrl?
Originally Posted by real name
if gotodlgctrl is set-function
i'm searching get-function
Well - GotoDlgCtrl() is a way of setting the focus to a specific window (control in this case). The opposite is GetFocus(), it retrieves the window which currently has the focus.
Originally Posted by real name
it's parameter should be dialog handler
Handler? You probably mean handle. Anyway, since only one window on your system can have the focus at any given time, there's no need to pass a parameter.
-
September 13th, 2005, 08:09 AM
#10
Re: opposite to GotoDlgCtrl?
one case i afraid getfocus is not safe enough (f.e. should happen any unexpected messagebox will appear)
next case (already bit out of my problem) how to ask dialog is not actualy "on top" what control will get focus (when child dialogs will close)
-
September 13th, 2005, 08:15 AM
#11
Re: opposite to GotoDlgCtrl?
Originally Posted by real name
one case i afraid getfocus is not safe enough (f.e. should happen any unexpected messagebox will appear)
Not sure what you mean... How would you want an "unexpected message box" to appear? If it occurs in your own thread, your code wouldn't be in control anyway at that moment, so the GetFocus() call would never be made while the messagebox is displayed. And if it's from another thread or process it's not a problem anyway, since GetFocus() always gives you the focussed window of the calling thread.
Besides that, you can always check via GetParent() whether the control having the focus belongs to your dialog or not.
-
September 13th, 2005, 08:27 AM
#12
Re: opposite to GotoDlgCtrl?
maybe we speaking the same?
"Besides that, you can always check via GetParent() whether the control having the focus belongs to your dialog or not."
what to do in case i will receive NULL? i understand getfocus will return != NULL just for one process and thread in system
seems dialog must somehow remember what will make focused again
-
September 13th, 2005, 02:24 PM
#13
Re: opposite to GotoDlgCtrl?
Try to capture the WM_ACTIVATE message and save the control id when when the dialog is deactivated
Code:
void CTESTDLGDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
//m_ActiveId is a class variable
if (WA_INACTIVE != nState && m_ActiveId) {
CString str;
str.Format("ACTIVATE APP: Control id %d", m_ActiveId);
SetWindowText(str);
}
else {
CWnd *pWnd = GetFocus();
if (pWnd && this == pWnd->GetParent()) {
m_ActiveId = pWnd->GetDlgCtrlID();
CString str;
str.Format("DEACTIVATEAPP: Control id %d", m_ActiveId);
SetWindowText(str);
}
}
}
Hope it will help you
-
September 13th, 2005, 03:08 PM
#14
Re: opposite to GotoDlgCtrl?
thanks for tips, seems i made no mistake and get-focus-dlg-ctrl(hdialog) does not exist
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|