Link to home
Start Free TrialLog in
Avatar of Mayflower1
Mayflower1

asked on

Cursor Positioning

Hi all,

I have created a dialog box with few edit controls in it. When the application runs the cursor parks on OK button. I want it to park on one of the edit controls. How should I do that?

Thanks
Avatar of KurtVon
KurtVon

Do you mean the OK button is the active control?  The easiest way to make a particular control active is to just make it first in the tab order.

If you mean the mouse cursor, first you have to disable the code that is currently moving it, and then call SetCursorPos with the position you want in a place that gets called automatically right after the window is displayed for the first time.  Offhand, I'd think in the WM_ONERASEBACKGROUND handler with a bool to detect whether this is the first time it is called.
GoToDlgCtrl(GetDlgItem(IDC_EDIT1)) ;
If you do use GoToDlgCtrl you will need to do it in the OnInitDialog handler and change the handler to return FALSE.

Like I said, it may be easier to just change the tab order.
ASKER CERTIFIED SOLUTION
Avatar of sreenu_v78
sreenu_v78

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial