CEdit on toolbar problem

Hi,

In my project, I added an CEdit control on toolbar. And I want to make it do 
something when "Enter" is pressed. But it can't receive the WM_KEYDOWN 
message. Can anybody tell me why?

Here is my code:
//SearchEdit.h
class CSearchEdit : public CEdit
{
//some code ommitted
protected:
 afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
 DECLARE_MESSAGE_MAP()
};

//WzdToolbar.cpp
BOOL CWzdToolBar::LoadToolBarEx(UINT id)
{
BOOL bRet;
 bRet = CToolBar::LoadToolBar(id) ;
RECT rect;
int pos=CommandToIndex (ID_FINDTEXT) ;
 SetButtonInfo ( pos , ID_FINDTEXT , TBBS_SEPARATOR , 100) ;
 GetItemRect ( pos , & rect ) ;
 rect.bottom-=5;
//m_CtrlWzdEdit is a CSearchEdit
 m_CtrlWzdEdit.Create ( WS_CHILD | WS_VISIBLE , rect, this,
  ID_FINDTEXT ) ;
}

//mainframe.cpp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (  !m_WndSubToolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
  | CBRS_TOOLTIPS ) ||
  !m_WndSubToolbar.LoadToolBarEx(IDR_SUBTOOLBAR))
 {
  TRACE0("Failed to create toolbar\n");
  return -1;      // fail to create
 }
}

Thanks in advanced.
 


0
bucher1 (14)
5/25/2007 5:43:04 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
440 Views

Similar Articles

[PageSpeed] 48

Do this(checking for keydown) in PreTranslateMessage of your edit control.

--
Ajay Kalra [MVP - VC++]
ajaykalra@yahoo.com


"bucher" <bucher@xxxx.com> wrote in message
news:uoBzT#onHHA.3460@TK2MSFTNGP04.phx.gbl...
> Hi,
>
> In my project, I added an CEdit control on toolbar. And I want to make it
do
> something when "Enter" is pressed. But it can't receive the WM_KEYDOWN
> message. Can anybody tell me why?
>
> Here is my code:
> //SearchEdit.h
> class CSearchEdit : public CEdit
> {
> //some code ommitted
> protected:
>  afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
>  DECLARE_MESSAGE_MAP()
> };
>
> //WzdToolbar.cpp
> BOOL CWzdToolBar::LoadToolBarEx(UINT id)
> {
> BOOL bRet;
>  bRet = CToolBar::LoadToolBar(id) ;
> RECT rect;
> int pos=CommandToIndex (ID_FINDTEXT) ;
>  SetButtonInfo ( pos , ID_FINDTEXT , TBBS_SEPARATOR , 100) ;
>  GetItemRect ( pos , & rect ) ;
>  rect.bottom-=5;
> //m_CtrlWzdEdit is a CSearchEdit
>  m_CtrlWzdEdit.Create ( WS_CHILD | WS_VISIBLE , rect, this,
>   ID_FINDTEXT ) ;
> }
>
> //mainframe.cpp
> int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
> {
> if (  !m_WndSubToolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
>   | CBRS_TOOLTIPS ) ||
>   !m_WndSubToolbar.LoadToolBarEx(IDR_SUBTOOLBAR))
>  {
>   TRACE0("Failed to create toolbar\n");
>   return -1;      // fail to create
>  }
> }
>
> Thanks in advanced.
>
>
>


0
ajaykalra (6842)
5/25/2007 11:37:19 AM
Generally, you will not see the <enter> key in WM_KEYDOWN because it will not be sent. One
quick solution is to simply create the edit control as a multiline edit control.  Then the
<enter> key will be sent to it (and to avoid multiline effects, you have to not call the
superclass)
					joe

On Fri, 25 May 2007 13:43:04 +0800, "bucher" <bucher@xxxx.com> wrote:

>Hi,
>
>In my project, I added an CEdit control on toolbar. And I want to make it do 
>something when "Enter" is pressed. But it can't receive the WM_KEYDOWN 
>message. Can anybody tell me why?
>
>Here is my code:
>//SearchEdit.h
>class CSearchEdit : public CEdit
>{
>//some code ommitted
>protected:
> afx_msg void OnKeyDown( UINT nChar, UINT nRepCnt, UINT nFlags );
> DECLARE_MESSAGE_MAP()
>};
>
>//WzdToolbar.cpp
>BOOL CWzdToolBar::LoadToolBarEx(UINT id)
>{
>BOOL bRet;
> bRet = CToolBar::LoadToolBar(id) ;
>RECT rect;
>int pos=CommandToIndex (ID_FINDTEXT) ;
> SetButtonInfo ( pos , ID_FINDTEXT , TBBS_SEPARATOR , 100) ;
> GetItemRect ( pos , & rect ) ;
> rect.bottom-=5;
>//m_CtrlWzdEdit is a CSearchEdit
> m_CtrlWzdEdit.Create ( WS_CHILD | WS_VISIBLE , rect, this,
>  ID_FINDTEXT ) ;
>}
>
>//mainframe.cpp
>int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
>{
>if (  !m_WndSubToolbar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_TOP
>  | CBRS_TOOLTIPS ) ||
>  !m_WndSubToolbar.LoadToolBarEx(IDR_SUBTOOLBAR))
> {
>  TRACE0("Failed to create toolbar\n");
>  return -1;      // fail to create
> }
>}
>
>Thanks in advanced.
> 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15974)
5/25/2007 1:06:51 PM
Reply:

Similar Artilces:

Weird problem
Client bought three new computers and I installed them this week. Old ones were 98 machines with office 97. New ones are XP Pro with Office XP. Server is Win2000 SBS but using more as a workgroup setup, i.e., the workstations are using workgroup not domain. All the new computers are identical and all the users have local admin rights and user rights on the server. One user is not experiencing this problem, but two of the users go to the data folder on the server, open up an existing spreadsheet, make changes, save it and close it. The next time they try to open it, it tells them they can ...

My product key is incorrect how do I resolve this problem?
My laptop came with Microsoft word 2007. Microsoft word tells me to put in my product key. So i put in the product key that is located on the bottom of my laptop but for some reason it says it's incorrect how do i resolve this? The product key on the bottom of your laptop is undoubtedly for Windows and not Word. Laptops often come with a trial version of Office 2007. Unless you paid extra for a retail version of the Office software it may be that your trial has now expired. -- <>>< ><<> ><<> <>>< ><<> <>>...

problem with multiple SMTP domains in Exchange Server 2003
Hi there I have added a second SMTP domain to the Email Addresses (Policy) as follows: Recipients > Recipient Policies > Default Policy > Email Addresses (Policy) > New ... > SMTP Address > @xyz.com > (checked) This Exchange Organization is responsible for all mail delivery > to this address > Apply. When I do so, I no longer receive external emails on the first SMTP domain (@abc.com). Is this related to relay settings, or perhaps something else? Best regards Loane ...

Problem cut-n-paste function
I'm having a bizarre problem cut-n-pasting a very simple calculation (ie = A1 � B1) in C1 down the column (ie C2 to Cn). When I cut-n-paste the function in C1, value that displays is the same as the source cell. If I click on the target cell, the correct cells are highlighted and if I hit the enter button, the formula calculates as expected. What is going on? What do I have to do to force the formula to auto calculate? Turn on Automatic Calculation <g>. You do that at Tools/Options/Calculation. On 27 Sep 2004 18:56:34 -0700, jsausten@hotmail.com (Stephen Miller) wrote: >I'm...

CRM 4.0: WebSite deployment problem
CRM 4.0: I cannot deploy my WebSite in the CRM WebSite, below is the error: 'Microsoft.Crm.WebServices.Crm2007.MultipleOrganizationSoapHeaderAuthentica­tionProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' doesn't exist. Parameter name: Microsoft.Crm.WebServices.Crm2007.MultipleOrganizationSoapHeaderAuthenticat­ionProvider, Microsoft.Crm.WebServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Description: An unhandled exception occurred during the execution of the current web request....

Toolbar at top of IE
I have Windows XP, IE version 8. This question is about the toolbars showing at the top of IE. The upper one that (normally) shows the words: File - Edit - View - Favorites - Tools - Help, and the lower one that (again, normally) shows (among others) the important word: Home. Recently, periodically, the background for those two toolbars turns totally black, so the words cannot be read. Fortunately Home has an icon, which DOES show up. As for the upper one, if I click on where I think the word is (i.e. Favorites, which I use very frequently) the drop-down menu appears, s...

Masking out characters in CEdit
Hi, I need to make a CEdit mask out some characters. Those characters should be deleted. I got a simple solution by creating a CMyEdit, catching WM_CHAR and ignoring those unwanted chars there. Works ok, but there are two problems: It does not work for characters that are not typed, but inserted. And, I have to create a CMyEdit variable for every Edit Control. Are there any simple solutions for that? Thanks for ideas! Christian Wirth In article <cc95755a.0409160531.15c24e80@posting.google.com>, wirthi@gmx.at says... > Hi, > > I need to make a CEdit mask out some characte...

ActiveX Browser Problem
Hi, I am using an Activex browser control in my application. I have also implemented the IDocHostUiHandler interface for customizing it. The problem is that when i press Ctrl+N, a new internet explorer window comes up. How should i avoid it....? Thanks, gshetty ...

STATEMENT DOWNLOAD PROBLEMS #2
Hi, I am trying to download statements and keep coming up with an error which says that "A communication error has occurred. Please try or call again." I have tried deleting and recreating the OFX file extension but this hasn't helped. Does anyone have any ideas? Thanks Caz In microsoft.public.money, Cazzy123 wrote: >I am trying to download statements and keep coming up with an error which >says that "A communication error has occurred. Please try or call again." I >have tried deleting and recreating the OFX file extension but this hasn't >he...

Attachment problems #2
When someone in our office sends an e-mail from their Mac with an attachment(e.g. a jpeg file) those of us with PC's can't open it. However, if one of us with a PC can access the file, we can attach the file and send to everyone (and they can open it). What's going on? ...

Wacky migration wizard problems
Hello all, We have two separate domains with the following configuration: Single NT4 PDC running Exchange 5.5 Single W2003 DC running Exchange 2003 There is a two way trust between the domains. I ran the Migration Wizard and moved over one user account. I logged into the new domain as the user, setup Outlook with the proper settings, and got an error that the user account did not have permissions to the mailbox. I checked in system manager and Self has all the necessary rights to the mailbox. The weird thing is that we did another test migration a month ago with the same domains...

#Name? problem that has been stumping Everyone
I have been posting this message for about 5 days now and no one has been able to help. I have a macro that fills down the formula =IF(AT2 = 500,MROUND(AI2,500),IF(AT2 = 5,MROUND(AI2,5),IF(AT2 = 10,MROUND(AI2,10),IF(AT2 = 25,MROUND(AI2,25),IF(AT2 = 100,MROUND(AI2,100),IF(AT2 = 200,MROUND(AI2,200),IF(AT2 = 364,MROUND(AI2,364),ROUNDDOWN(AI2,0)))))))) Each time I fill down the range using the macro I get a #name? error. As I have posted before there is no error in the function because when I go into the status bar at the end of the formula and MANUALLY hit enter the formula calculates correctl...

I have a problem with getting a total Sum of numbers (URGENT)
I'd really appreciate if someone could help me here. I am using Microsoft Excel 2002 on a Microsoft Office XP system. I a trying to develop a minor league baseball schedule, but am having som problems. I have attached a copy of my spreadsheet to give everyone some idea o what I'm doing here. I have where the fans list the "RUNS, HITS & ERRORS) of both teams an for each game of the series. I then have it set up in the TOTA WON/LOST column where if the T-Bones RUNS are more than the SALTDOG runs, a "1" appears in the WON column. If the SALTDOGS have a highe numbe...

Outlook 2003 Add-in: Personal Folders Backup uninstall problem
Hello techie nerds out there Help! I am trying to uninstall this utility to reinstall it on another desktop on the same machine. It seems you can only run this utility on one desktop? Running windows XP pro and Outlook 2002 The programme does not show up in the Add/Remove programme window in the Control Panel. Many, many thanks Paul Paul Allen <ict@wandsworthvb.org.uk> wrote: > I am trying to uninstall this utility to reinstall it on > another desktop on the same machine. It seems you can only > run this utility on one desktop? Doesn't seem to be the case here. ...

Serious problem with Money Plus Deluxe
I have about 17 years worth of investment data in my Money file along with several years of credit card and checking account data. All of the investment transactions have been entered manually; the credit card and checking account data is downloaded online. Stock prices have been updated daily over at least the last dozen years. On Friday, after entering a bunch of new transactions which were accepted normally and shutting Money down, I tried to open my file again. After I entered my login info, Money gave me the memo that it had "encountered a problem and was shutting down.&qu...

Rows and Columns Settings Problem
How do you set rows and columns in a way that when you scrol down/column you can always see a certain row(s)/column(s) -- Message posted from http://www.ExcelForum.com Check out XL Help for "Freeze Panes" In article <JMorgan.1ad5vf@excelforum-nospam.com>, JMorgan <<JMorgan.1ad5vf@excelforum-nospam.com>> wrote: > How do you set rows and columns in a way that when you scroll > down/column you can always see a certain row(s)/column(s). Thank -- Message posted from http://www.ExcelForum.com ...

Problem opening up current Excel wksht to mail merge in Word
Hi, I have Microsoft 2007. I created a list in Excel with clients' name, address, city, state, zip. Then, in Word I go to Select Recipients, locate the Excel file and click open. Here's the problem: a Select Table box appears with Sheet1$, Sheet2$, and Sheet3$ as options. clicking on any of the three results in NOTHING. Nothing at all appears! I'm not sure what the problem might be. Thank you for the help! Rachelle ...

"Find a contact box" problem
Hi. I�m having problems with the �Find a contact� box on the Standard toolbar. Previously, I would type in a name and the search would pull up name/s from the Outlook Contacts folder first then, if the name is not in the Contacts folder, it would pull up name/s from the Global Address List if any. Now, when I type in a name, the search only pulls up name/s from the Global Address List. The search does not include the Contacts folder although there are entries in the Contacts folder. The problem started after I transferred a couple of Contacts subfolders to another pst file. How do I fix the p...

access 2007 and custom toolbars in earlier version
Is there a way in Access 2007 (Enterprise) to modify a custom toolbar created in say Access 2002? In the help there are only topics about the quick access toolbar. I want to modify the action of a button, but right clicking and choosing customize, like used to be so easy (once you get used to it), is no longer possible. Does that mean no more custom toolbars and no backward compatibilty here? Help would be very welcome as the user friendliness of my user's experience is at stake here. ...

Excel 2007. How do I get un-installed add-ins off the toolbar?
I have 2 Large Icons on the ribbon/toolbar of Excel 2007. These are Omnipage and s-force. Both of these have been uninstalled and I have de-activated both add-ins. How do I get these off the toolbar forever? thanks ...

Exchange 2000 problems
Since the HD failed I have been trying to put my domain backup. The PDC, W2k, had IIS and Exchange on it. I have reloaded W2k with SP's and installed Exchange 2000. None of my virtural stores Protocols are running and when I open the properties of each the "Start, Stop, Pause" choices are grayed out. The First Storage Group/Mailbox Store is also down. When I try to Mount it I get this error: "An internal processing error has occured. Try restarting the Exchange System Manager or the Microsoft Exchange Information Store service or both." ID c1041724 Help...I'm...

Exchange 2003 ADC problems
Hi, I have the following situation.... We have multiple Exchange 5.5 sites being migrated to one Exchange 2K3 organisation (called Localmail). The first server in the 2K3 org (which had the CA Config agreement) and also the connection agreement to the EX5.5 server (in Localmail) has died and there is no suitable backup for recovery. I need to remove the connections from this dead server. I cannot remove the CA Config agreement - there is no delete option for this connection. If I try to modify the Config CA connection to run on another Exchange 2003 box in the Localmail org I get the c103a...

Problems with CTabCtrl
I derived a new class from CTabCtrl. I created four dialogs for each tab. The tab controls is displayed fine and all the controls for each tab are also displayed. The problem is that I cannot initialize the edit controls in OnInitDialog for each tab dialog. m_cNameEdit.SetWindowText( m_sName ); IDD_NAME_EDIT has 'm_cNameEdit' and 'm_sName' as member variables. Variables are defined in the CTab1Dlg class. When the tab appears there is nothing in the edit control. Thanks. "Mark F." <replytogroup@news.com> wrote in message news:21TFd.3196$Z%.402@fe1.tex...

Data Entry Problem
I am designing a database to manage staff absences. I have a number of forms (one for each manager) feeding one table for company reports etc. I have a 'member of staff' field that is a comby on each form to restrict entry for managers to their team members only. My problem is that i set the data entry property to 'Yes'. This clears the form on open but prevents me from finding records (obviously because the form is empty). If i set the data entry to 'No', all records from other managers are showing on all managers forms also. Due to data protection i need to ov...

Problem creating 2003 PST file
Hi, I am currently running Outlook 2003 (Client). I am trying to create a new PST file. However when I try to add a new file (file\new\outlook data file\) I can only select: Outlook 97-2002 Personal Folder File. On the microsoft website it says I should see something like "Office Outlook Personal Folders File (.pst)" but it is not listed. Is there any way to correct this?? I am running Outlook 2003 SP1. Thanks for any help, Wouter Hi, Kan iemand mij helpen? Het moet mogelijk zijn om bij het verzenden van een emailtje de afzender te veranderen. Ooit wist ik het, maar ik ben...