detecting which control has focus

I have an application that I am writing and I need to be able to detect
which control has focus (I am using edit controls).  I figured out how to
set the focus by creating a member control variable and using the setfocus()
function, but how do detect which control has focus?  There is a getfocus()
in the control member variable, but I have been unsuccessful in using it?  I
am using the PreTranslateMessage(MSG* pMsg) function to detect when the
Return key is pressed and then I automatically go the the next edit control,
but I want to do different code depending on which Edit control has focus
and I have not figured out a good way to do this.

    Roger


0
10/9/2003 3:03:40 PM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
1025 Views

Similar Articles

[PageSpeed] 25

Well, Get Focus returns the pointer to the window that has the focus.  After
calling that you can compare it's m_hWnd to the m_hWnd of your edits to see
which one is the one with the focus.
One thing comes to mind here.  I don't know how usefull this would be to
you.  But I would derive a class from CEdit or whatever control it is that
you are trying to keep track of and have the control send a custom message
back to the parent everytime his WM_SETFOCUS is called.

Ali R.

"R.H." <roger.huggins@intermec.com> wrote in message
news:%23bTnbXnjDHA.2416@TK2MSFTNGP10.phx.gbl...
> I have an application that I am writing and I need to be able to detect
> which control has focus (I am using edit controls).  I figured out how to
> set the focus by creating a member control variable and using the
setfocus()
> function, but how do detect which control has focus?  There is a
getfocus()
> in the control member variable, but I have been unsuccessful in using it?
I
> am using the PreTranslateMessage(MSG* pMsg) function to detect when the
> Return key is pressed and then I automatically go the the next edit
control,
> but I want to do different code depending on which Edit control has focus
> and I have not figured out a good way to do this.
>
>     Roger
>
>


0
nospam1696 (83)
10/9/2003 3:28:29 PM
Reply:

Similar Artilces:

MultiWorkbook Change Event Detection / Spell Checker
Excel 2003 or 2007. Looking to be able to force spell checking whenever any cell content is is changed. I've been successful on a single workbooks by adding Spell Check execution on Worksheet_Change. I'm hoping to take this one step further - make it an 'Add-In' so the check will run for any workbook. It looks like the Worksheet_Change event only triggers for the host workbook so an 'Add-in' will not do the job. Any suggestions to force spell checking on a change for any workbook/worksheet I modifiy? TIA, - Pat The way I would go about this i...

How to detect changes in a column?
If I have a table with sales forecast data (columns) like Customer, Amount and Status, what would be the best way to track changes in this table so I can compare my forecast week after week? -- inomata ------------------------------------------------------------------------ inomata's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=18938 View this thread: http://www.excelforum.com/showthread.php?threadid=493571 ...

detect and repair
my outlook 2002 had some hyperlink problems which were corrected when i used the 'detect and repair' option in help. now i have lost my addresses and all the e-mail that was in my inbox. How do i recover these items? Check this page for all you need to know: http://www.slipstick.com/config/backup.htm -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP http://home.hawaii.rr.com/schorr **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "Mark Conner" <mdconner@prodigy.net> wrote ...

Cycle through Controls on form
Thanks for taking the time to read my question. Question 1: how do I determine the position or control number of a control on a form. I can type in me.controls(1) and it will go somewhere, but I'd like the code to put in the "1" for me. Something like me.controls.number??? Question 2: I'd like to cycle through all the controls on a form where the Tag <> "Skip" Code: For Each c In Me Debug.Print c.Tag If c.Tag <> "Skip" Then Debug.Print c Me.Controls(c).BackStyle = 1 Debug.Print c End If Next c starts ...

Backup Domain controller
I am trying to create a backup domain controller. I am using windows server 2000, and exchange 2000 which are currently on the same server(I know the microsoft recomendation but I didn't install this.) I installed windows 2000 server on another machine and ran dcpromo to setup a backup domain controller. When I open users and computers on the new DC, it only has the standard AD information without the extra exchange extensions. I didn't install exchange originally so I'm not too familiar with the process but while reading about it, I couldn't find any reference to in...

Duplicate detection detecting inactive records?
Is there any way to configure duplicate detection to not look at inactive records? I can't find any way to set this on the rules. Thank you! ...

static control color in Custom Control in MFC
Hi, In the win32 application I have written WM_CTLCOLORSTATIC which was processed and white brush was returned(GetStockObject(WHITE_BRUSH)), so the static control which is child windows of the custom control looked white. In the corresponding MFC program I have the OnCtlColor for the "custom control" handled as:- HBRUSH CEditHold::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CWnd::OnCtlColor(pDC, pWnd, nCtlColor); int id = pWnd->GetDlgCtrlID(); if(nCtlColor == CTLCOLOR_STATIC && (id > 0 && id < 9)) { return (HBRUSH)GetStockObje...

Picture control flickering
Hi all, can any1 plz help me out with this question I have a picture control embedded in a Form View of Splitter window (in a MDI-based app). How exactly can I avoid flickering of the contro while I resize the ChildWindow? I tried implementin OnEraseBkgnd in the Form View and also in a seperat CWnd class as follows // PictureControlWn IMPLEMENT_DYNAMIC(PictureContorlWnd, CWnd PictureContorlWnd::PictureContorlWnd( BEGIN_MESSAGE_MAP(PictureContorlWnd, CWnd ON_WM_ERASEBKGND( END_MESSAGE_MAP( BOOL VRMediaPlayerPictureContorlWnd::OnEraseBkgnd(CDC pDC return TRUE; // i tried even FALSE ...

How to Detect and prevent CD burn
HI, How can i stop to CD burn of any file from my system to CD.How to detect the event of CD burn and how can i stop CD burn.Basically i want to secure my file from CD burn. plz reply soon. regds vinay sheel vinays@aditi.com Vinay wrote: > HI, > How can i stop to CD burn of any file from my system to CD.How to detect the > event of CD burn and how can i stop CD burn.Basically i want to secure my > file from CD burn. You can restrict access to a file only to a certain users through NT/win200 access privileges. You can encrypt a file and therefore restrict access to a file on...

My Computer not detecting my external harddrive
I have a IDE hard drive with USB casing and connected to my USB port. The problem is the hard drive partitions are not shown up in My computer. But My Computer->Manage->Storage->Disk management shows the hard drive with 3 partitions and all the three are healthy.I know there are a few bad sectors. I am sure I have not made any changes in registry that prevents drives from being shown. Please help me. Do the partitions have drive letters assigned? karthikaravind wrote: > I have a IDE hard drive with USB casing and connected to my USB port. > The problem is the ha...

Scroll Bar Control
I need a way where I can control a macro to control some scroll bar. I'll have about 10 - 15 scroll bar. There will be a main scroll bar. When I move the main scroll bar the rest of the scroll bar should move according to the main one. If the main one is at 80, then the rest should be at 80. For the rest of the scroll bar, I should be able to adjust them different. For example, if I move the main scroll bar to 80, the rest will move to 80. Then I would probably amend scroll bar 2 to 75, scroll bar 5 to 85 and so on. Is there a way I can do that? Assuming your scroll ba...

unintended result from holding down control key
I held down the control key for a few seconds and a dialog box opened with an accessability feature. I unintentionally turned the feature on and now I must wait several seconds between repeated uses of any key. How can I turn this annoying feature off? Goto Control Panel and select Accessibility Options. Look under the keyboard tab to see which options are selected and turn them off. Probably Sticky Keys >-----Original Message----- >I held down the control key for a few seconds and a dialog >box opened with an accessability feature. I >unintentionally turned the feature ...

GUID is not detected by server .& cannot go offline...SFO.
why is the server not detecting the GUID attached to the subject line of email...what could be the problem... Also i am not able to go offline ..I get an error Domain canot be contacted or does not exist... Any sugestions... Thanks a million. ...

how can I capture the message when a CEdit control beep?
In a multi-line, want-return CEdit, if the input has too many lines, the CEdit will beep. I want to do something at that moment. So what message should I capture or by what criteria could I find there is too many lines? ...

Undo a Control Association
While trying to set up a label and control association, I inadvertantly connected the label to the wrong control. What is the way to undo that association? fs Select the label and cut it (from the Edit menu, or using Ctrl-X). Select the control to which it should be associated, and paste the label (from the Edit menu, or using Ctrl-V). -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "franks" <franks@discussions.microsoft.com> wrote in message news:C7A0B42E-9105-44A3-9E81-1750F3FD089C@microsoft.com... > While trying to set up a la...

Office System 2010: List of Controls IDs
Does anyone know when or where Microsoft will publish a list of control IDs for the Office System 2010? Does anyone know the idMso for the "Print" command located on the new "File" menu? -- Greg Maxey See my web site http://gregmaxey.mvps.org for an eclectic collection of Word Tips. Arrogance is a weed that grows mostly on a dunghill (Arabic proverb) This is a multi-part message in MIME format. ------=_NextPart_000_000B_01CAE7B4.9D78F540 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable...

Mic not detected
I upgraded from Vista to W7 when it first came out. I have just recently realized that it apparently cut off the mic and I cannot record anything. I can still hear cd's.etc. I did not discover this until I tried to send a video message to my son who just got deployed to Iraq. Dell customer support has been useless thus far. Thanks for any suggestions as to how to fix this problem. On May 17, 11:51=A0am, "andy jones" <jandy78...@aol.com> wrote: > I upgraded from Vista to W7 when it first came out. I have just recently > realized that it apparently cut...

Control Tool Box (Check Box + IF)
Hi, I'm newible in here, I wanna to using a check box plus if function, means "If ( "the check box tick", true, false)" Thx for help! If you're referring to one drawn from the Forms Toolbar (via View > Toolbars > Forms) (and not from the Control Toolbox) then try : http://tinyurl.com/vykc which has a previous response to a similar Q -- hth Max ----------------------------------------- Please reply in newsgroup Use xdemechanik <at>yahoo<dot>com for email ------------------------------------------- "Chris" <chakyin@hotmail.com> ...

Record is locked (deadlock was detected)
when trying to run a CM Transaction I get "A get/change next operation on table 'CM_Transaction' deadlock was detected. when I click on more details i am given the following. [microsoft][ODBC SQL Server Driver][SQL Server] Transaction (process ID 77) was deadlocked on thread | communication buffer resources with another process and has been chosen as the deadlock victim. Return the transaction. currently I have ensured that no one is logged in. I view the odb.dex_lock table in the tempDB and cleared it. At this point I can run a reconciliation with no errors where I ...

Control Objects
I have put some option button controls on a worksheet, the worksheet is quite large and I want the user to be able to pick options as they move around the sheet to look at the data. Is there a way to lock the position of the controls so the user can see and use them whilst looking at all parts of the sheet. This solution cannot use freezing panes for various reasons. I would really appreciate some help on this!!!!! Thank you in advance. Stewart MOS Excel Expert (not good enough though!!) Freezing panes is the obvious way to do this. If that's out some other choices that pop imm...

ActiveX Control #3
I have created an activeX in VC++ 6.0. Have done something terribly wrong and when I view the type library in OLE/COM Object Viewer , there are three copies of the activeX and two of them have wrong IDs for Methods and properties. Not sure how to delete these entries. I tried deleting it in the registry and that did not work. Any help would be greatly appreciated. M Fix the ODL file that VC++ generates for your project. I have found that sometimes that ODL file gets messed up. I have never figured out why, but backups are my best friend such situations. -Atul, Sky Software http://www...

detecting which control has focus
I have an application that I am writing and I need to be able to detect which control has focus (I am using edit controls). I figured out how to set the focus by creating a member control variable and using the setfocus() function, but how do detect which control has focus? There is a getfocus() in the control member variable, but I have been unsuccessful in using it? I am using the PreTranslateMessage(MSG* pMsg) function to detect when the Return key is pressed and then I automatically go the the next edit control, but I want to do different code depending on which Edit control has focus a...

Tab Control 09-15-07
I have forms that use tab controls to group related data. I want to be able to have the user tab from the last control on the 1st page of the tab control to the first control on the 2nd page of the tab control instead of having to click on the tab itself. I know there is a way to do this, but I haven't been able to find the answer. Please help! russr First they ignore you. Then they laugh at you. Then they fight you. Then you win....Mahatma Gandhi Russ Rollins wrote: > I have forms that use tab controls to group related data. I want to be > able to have the user tab from the last co...

RTF control in reports
I am using the Lebans RTF control (RTF2.ocx) in a form, and the attached report is also design with the ActiveX control like the Lebans' A2K RTF2Sample Release.mdb. The print out is deviding the lines in half on both sides (the last line on p1 and the first line on p2). Is the a way of controlling the print out from a report using then Active X control RTF2.ocx. I have tryed the A2K2ReportUtilities.mdb but the reports includes the testmemo and not the RTFcontrol. This issue is created/controlled by the Access Report engine. Third Party ActiveX controls have absolutely no control o...

Cannot detect previous login you need to run frontstep crm at least once
We have a user who was on extended leave for a few months and now when ever he opens up outlook 2000 sr-1 on his computer (Windows 98se) he gets a message that "Cannot detect previous login you need to run frontstep crm at least once. Front step outlook extension will be disabled for current outlook session." When I say OK you get another message that "The add-in "psExcExt.dll" could not be installed or loaded. This problem may be resolved by useing detect and repair in the help menu. Unable to load "psExcExt.dll" you may be out of memory or out ...