Ws_tabstop, Mfc

This is a discussion on Ws_tabstop, Mfc within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I have two CEdit's with WS_TABSTOP property, but tabing (moving between editboxes with TAB / SHIFT+TAB) is not working. ...

  1. #1
    Registered User
    Join Date
    Jun 2005
    Posts
    24

    Ws_tabstop, Mfc

    Hi,

    I have two CEdit's with WS_TABSTOP property, but tabing (moving between editboxes with TAB / SHIFT+TAB) is not working. As I understood I have to put IsDialogMessage(); function in message loop, but how? ... I'm using macro for messages:


    Code:
    class MainWin: public CFrameWnd
    {
    	public:
    	...
    
    	void OnCreate() 
    	{
    		CEdit* pEdit = new CEdit;
    		pEdit->Create ( WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_BORDER,  
    				CRect(x, y + b + s, xf, y + 2*b + s), this, id);
    
    	}
    
    	DECLARE_MESSAGE_MAP() 
    };
    
    
    
    BEGIN_MESSAGE_MAP( MainWin, CFrameWnd )
    
    ON_COMMAND(ID_MENU_SAVEDAT, OnSaveDat)
    ON_COMMAND(ID_MENU_ENDAPP, OnEndApp)
    ON_WM_CREATE ()
    ON_CONTROL_RANGE(BN_CLICKED, 8000, 8001, OnButtonClick)
    
    END_MESSAGE_MAP( )
    Last edited by fiff; 12-20-2005 at 05:19 PM.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,853
    Does the main window have the tab stop style?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    Quote Originally Posted by novacain
    Does the main window have the tab stop style?
    Yes, application class ->


    Code:
    class MyApp : public CWinApp
    {
    	public:
    
    	BOOL InitInstance()
    	{
    		
    		MainWin *mainWinL = new MainWin;
    		mainWinL->m_bAutoMenuEnable = FALSE; 
    
    		m_pMainWnd = mainWinL;
    
    		mainWinL->Create (AfxRegisterWndClass(0, LoadStandardCursor(IDC_ARROW), 
    				CreateSolidBrush(RGB(0,0,0)), 
    				LoadIcon(IDI_ICON1)), "App",  
    				WS_TABSTOP | WS_SYSMENU | WS_MINIMIZEBOX , CRect(0, 0, 620, 510), 
    				NULL, MAKEINTRESOURCE(IDR_MENU1));
    
    		mainWinL->ActivateFrame();
    
    		return TRUE ;
    	}
    
    
    };
    I don't have to call IsDialogMessage() in message loop?

    -
    Last edited by fiff; 12-23-2005 at 03:15 PM.

  4. #4
    Registered User
    Join Date
    Jun 2005
    Posts
    24
    I have'nt found any simple solution and any way I dont like this tab movement, so I made this (moving and selecting with arrows):

    Code:
    class MyEdit : public CEdit
    {
    	protected:
    
    	void OnMyKeyDown(UINT key, UINT repeatCnt, UINT flags)
    	{
    		bool mykey_pressed = false;
    		CEdit *editCtrl;
    
    		if(key == VK_DOWN)
    			{ editCtrl = (CEdit*)FocusEdit(FALSE); mykey_pressed = true; }
    		
    		if(key == VK_UP)
    			{ editCtrl = (CEdit*)FocusEdit(TRUE); mykey_pressed = true; }
    
    		OnKeyDown(key, repeatCnt, flags);
    		if(mykey_pressed == true){ editCtrl->SetSel(0,100); }
    	
    	}
    
    	CWnd* FocusEdit(BOOL di)
    	{
    		CWnd *d = this->GetOwner()->GetNextDlgTabItem(this, di);	
    		d->SetFocus();
    
    		return d;
    	}
    
    	DECLARE_MESSAGE_MAP() 
    
    };
    
    BEGIN_MESSAGE_MAP( MyEdit, CEdit )
    ON_MESSAGE( WM_KEYDOWN, OnMyKeyDown )
    END_MESSAGE_MAP( )

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    MFC auto-handles tab stops and input. Set the tab order in the dialog menu and it will work w/o any extra code from you.

    You are working against MFC and that is why the behavior is strange.

    Windows will notify your window when it is gaining the focus - so if your window is a control, then you know when someone has either clicked it, or tabbed through the controls and landed on yours.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WIndows programming?
    By hostensteffa in forum Windows Programming
    Replies: 7
    Last Post: 06-07-2002, 08:52 PM
  2. Release MFC Programs & Dynamic MFC DLL :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 05-18-2002, 06:42 PM
  3. Understanding The Future of MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-15-2002, 09:08 PM
  4. Beginning MFC (Prosise) Part III - Now What? :: C++
    By kuphryn in forum C++ Programming
    Replies: 5
    Last Post: 03-03-2002, 05:58 PM
  5. MFC is Challenging :: C++
    By kuphryn in forum C++ Programming
    Replies: 8
    Last Post: 02-05-2002, 12:33 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21