how to let CEdit SetFocus in a simple SDI program
-
use SetFocus(...) Good Luck. Uday kiran
-
tried this method several times at many different places, such as when created, when updated, or in InitInstance, can't success. don't know what's the problem
Call it immediatly before exiting your
OnInit
function. If that doesn't work look through your code for any other instances ofSetFocus
, maybe you are setting it but it is later being stolen. -
tried this method several times at many different places, such as when created, when updated, or in InitInstance, can't success. don't know what's the problem
On way is using CEdit::Setfocus in overridden OnActivateView()
Prasad Notifier using ATL
-
On way is using CEdit::Setfocus in overridden OnActivateView()
Prasad Notifier using ATL
-
On way is using CEdit::Setfocus in overridden OnActivateView()
Prasad Notifier using ATL
-
I don't know what's the reason, but i called m_edtContent.SetFocus in my overridden OnActivateView(), are you OK in your side, thanks for your help.
its failing ? Is it giving some ASSERT or just not doing what its intended to do? Have you suppressed its base class call ? You need to do that. It would just look like this,
void CSDIView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
{
m_edtContent.SetFocus();//later you can customize this to set foucs as your need
}Prasad Notifier using ATL
-
I don't know what's the reason, but i called m_edtContent.SetFocus in my overridden OnActivateView(), are you OK in your side, thanks for your help.
yes, really thanks for your help, it succeeds when i call like "CView::OnActivateView(bActivate, pActivateView, pDeactiveView); m_edtContent.SetFocus();" but not if i call like" m_edtContent.SetFocus(); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); ". it's really very good, but after i quit the program, it will say "The exception Breakpoint, A breakpoint has been reached."
-
yes, really thanks for your help, it succeeds when i call like "CView::OnActivateView(bActivate, pActivateView, pDeactiveView); m_edtContent.SetFocus();" but not if i call like" m_edtContent.SetFocus(); CView::OnActivateView(bActivate, pActivateView, pDeactiveView); ". it's really very good, but after i quit the program, it will say "The exception Breakpoint, A breakpoint has been reached."
ikohl wrote:
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
tries to set foucs on view itself. In your case its not needed.
Prasad Notifier using ATL
-
ikohl wrote:
CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
tries to set foucs on view itself. In your case its not needed.
Prasad Notifier using ATL
-
yes, it's ok in sdi program, except for can't focus previous program when this program quits. but for mdi program, there's an error box will jump out when quit this program. really thanks for your help, you're a kind man.
Actually, problem was you can't use SetFocus unless that window ,parent window is visible. OnActivateView is one place where you can achieve this. You can use its parameters for certain checks. Other place I feel is overriding WM_SHOWWINDOW, but it will get called once. You can look for such messages and use SetFocus there.
Prasad Notifier using ATL
-
Actually, problem was you can't use SetFocus unless that window ,parent window is visible. OnActivateView is one place where you can achieve this. You can use its parameters for certain checks. Other place I feel is overriding WM_SHOWWINDOW, but it will get called once. You can look for such messages and use SetFocus there.
Prasad Notifier using ATL