-
May 24th, 2004, 11:39 PM
#1
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
-
May 25th, 2004, 02:45 AM
#2
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
-
May 25th, 2004, 03:14 AM
#3
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.
-
May 25th, 2004, 03:32 AM
#4
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
-
May 25th, 2004, 09:01 PM
#5
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
-
May 25th, 2004, 10:25 PM
#6
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.
-
May 25th, 2004, 11:07 PM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|