Cursor Positioning

Posted on 2003-03-27
Medium Priority
Last Modified: 2013-11-20
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?

Question by:Mayflower1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 11

Expert Comment

ID: 8220487
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.

Expert Comment

ID: 8222613
GoToDlgCtrl(GetDlgItem(IDC_EDIT1)) ;
LVL 11

Expert Comment

ID: 8224847
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.

Accepted Solution

sreenu_v78 earned 80 total points
ID: 8229394
Set the Tab Order in design time,
to do this.

Use(CTRL+A) Select the all Controls in Dialog.
Press (CTRL+D) for show the tab order.

change the tab order as ur wish.

Other wise

Use SetFocus() in coding

best wishes

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question