CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Location
    100m below sea level
    Posts
    189

    OnIdleUpdate problem...

    Hi guys,

    I have a fromview sdi application, and there are 3 radio button (left,center and right) and a richedit control, I used the WM_IDLEUPDATECMDUI to make the buttonst updated each time there is the change in the rich edit control, and here I post the codes I used. The 3 buttons correspont to the text alignment in the richedit control, left center and right. The problem is, It does not seems right, when I clicked on left or right button, the center also get checked. and when I clicked on the center button, both left and right fet clicked, why is it like this???

    Code:
    //in CRichEditDemoView.h 
    afx_msg void OnIdleUpdateCmdUI();
    afx_msg void OnUpdateLeft(CCmdUI* pCmdUI);
    afx_msg void OnUpdateCenter(CCmdUI* pCmdUI);
    afx_msg void OnUpdateRight(CCmdUI* pCmdUI);
    Code:
    //in CRichEditDemoView.cpp
    BEGIN_MESSAGE_MAP(CRichEditDemoView, CFormView)
    	//{{AFX_MSG_MAP(CRichEditDemoView)
    ON_MESSAGE_VOID(WM_IDLEUPDATECMDUI,OnIdleUpdateCmdUI)
    ON_UPDATE_COMMAND_UI(IDC_RPLEFT,OnUpdateLeft)
    ON_UPDATE_COMMAND_UI(IDC_RPCENTER,OnUpdateCenter)
    ON_UPDATE_COMMAND_UI(IDC_RPRIGHT,OnUpdateRight)
    	//}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    void CRichEditDemoView::OnIdleUpdateCmdUI()
    {
    	UpdateDialogControls(this,FALSE);	
    }
    
    void CRichEditDemoView::OnUpdateLeft(CCmdUI* pCmdUI) 
    {
    	pCmdUI->SetCheck (m_ctlRichEdit->IsParaLeft ());
    }
    
    void CRichEditDemoView::OnUpdateCenter(CCmdUI* pCmdUI) 
    {
    	pCmdUI->SetCheck (m_ctlRichEdit->IsParaCenter ());
    }
    
    void CRichEditDemoView::OnUpdateRight(CCmdUI* pCmdUI) 
    {
    	pCmdUI->SetCheck (m_ctlRichEdit->IsParaRight ());
    }
    Code:
    //this is in CMyRichEditCtrl.cpp where IsParaLeft,IsParaCenter 
    //andIsParaRight declared
    BOOL CMyRichEditCtrl::IsParaLeft()
    {
    	PARAFORMAT temppf= { 0 };
    
    	GetParaFormat(temppf);
    	BOOL curPara;
    	if(temppf.wAlignment & PFA_LEFT)
    	{
    		curPara=TRUE;
    		temppf.wAlignment |= PFA_LEFT;
    	}
    	else
    	{
    		curPara=FALSE;
    		temppf.wAlignment &= ~PFA_LEFT;
    	}
    	return curPara;
    }
    BOOL CMyRichEditCtrl::IsParaCenter()
    {
    	PARAFORMAT temppf= { 0 };
    	
    	GetParaFormat(temppf);
    	BOOL curPara;
    	if(temppf.wAlignment  & PFA_CENTER)
    	{
    		curPara=TRUE;
    		temppf.wAlignment |= PFA_CENTER;
    	}
    	else
    	{
    		curPara=FALSE;
    		temppf.wAlignment &= ~PFA_CENTER;
    	}
    	return curPara;
    }
    BOOL CMyRichEditCtrl::IsParaRight()
    {
    	PARAFORMAT temppf= { 0 };
    
    	GetParaFormat(temppf);
    	BOOL curPara;
    	if(temppf.wAlignment  & PFA_RIGHT)
    	{
    		curPara=TRUE;
    		temppf.wAlignment |= PFA_RIGHT;
    	}
    	else
    	{
    		curPara=FALSE;
    		temppf.wAlignment &= ~PFA_RIGHT;
    	}
    	return curPara;
    }
    Can anyone help me out here????thanks in advance.
    Come Join This Poll Where are we from? (Ultimate)

    Knowing is not enough; we must apply. Willing is not enough; we must do. - Johann Wolfgang
    An idle brain is the devil's workshop. - unknown

  2. #2
    Join Date
    Mar 2004
    Location
    100m below sea level
    Posts
    189
    No one ??? Am I not clear enough??
    Come Join This Poll Where are we from? (Ultimate)

    Knowing is not enough; we must apply. Willing is not enough; we must do. - Johann Wolfgang
    An idle brain is the devil's workshop. - unknown

  3. #3
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    I think that your radio buttons aren't set up properly. The first one should have the 'group' button checked in the resource editor and the others should not have this checked.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  4. #4
    Join Date
    Mar 2004
    Location
    100m below sea level
    Posts
    189
    Thanks for your reply darwen,

    I double checked the radio button properties and the first is set to group and the other buttons is not, but the result is the same??? This thing is making me really frustrated!!!!

    When I removed the Update function, it works fine!! why???

    THanks for your reply again! Hope some gurus who had done this kind of things before could help me out here...
    Come Join This Poll Where are we from? (Ultimate)

    Knowing is not enough; we must apply. Willing is not enough; we must do. - Johann Wolfgang
    An idle brain is the devil's workshop. - unknown

  5. #5
    Join Date
    Mar 2004
    Location
    100m below sea level
    Posts
    189
    still looking for an answer...........
    anybody...?????
    Come Join This Poll Where are we from? (Ultimate)

    Knowing is not enough; we must apply. Willing is not enough; we must do. - Johann Wolfgang
    An idle brain is the devil's workshop. - unknown

  6. #6
    Join Date
    Nov 2002
    Posts
    110
    Try replace

    if(temppf.wAlignment & PFA_LEFT)

    with

    if(temppf.wAlignment == PFA_LEFT)


    Also for the CENTER and RIGHT portion


    If you open Richedit.h, you will notice that these value is defined as

    /* PARAFORMAT alignment options */
    #define PFA_LEFT 0x0001
    #define PFA_RIGHT 0x0002
    #define PFA_CENTER 0x0003

    they are not flags/mask.. they are values.

  7. #7
    Join Date
    Mar 2004
    Location
    100m below sea level
    Posts
    189
    ohhh thanks man! THAT really solve my problem....I thought PFA_LEFT is the same as CFE_ITALIC or CFE_BOLD where i need to use the ' & ' instead of '=='.

    Phew, at last, somebody noticed...

    Thanks Again Man.
    Come Join This Poll Where are we from? (Ultimate)

    Knowing is not enough; we must apply. Willing is not enough; we must do. - Johann Wolfgang
    An idle brain is the devil's workshop. - unknown

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured