f



Check/Unchek in PopUp Menu -- Tick mark is not toggleing

Hi 

I am displaying a Pop Up menu on right click of List Control's
Header(CListCtrl).

This popup menu is having Check/Tick marks. But they are not toggleing
on subsequent clicks. I am using CMenu's CheckMenuItem( ) function.


Can anybody please help me?
Thanx in Advance...


My Code looks like.... The first Function is displaying popup menu. 
                       The second funtion is handling the click on
menuitems.
                       The code for Toggleing Check/Tick mark is in
second one.



BOOL CWitPlayerDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT*
pResult)
{
	LPNMHDR pNH = (LPNMHDR) lParam; 
	if( wParam == 0 && pNH->code == NM_RCLICK )
	{
		// Right button was clicked on header
		CPoint pt(GetMessagePos());
		CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
		pHeader->ScreenToClient(&pt);
		
		// Determine the column index
		int index;
		CRect rcCol;
		for( int i=0; Header_GetItemRect(pHeader->m_hWnd, i, &rcCol); i++ )
		{
			if( rcCol.PtInRect( pt ) )
			{
				index = i;
				break;
			}
		}

                // Pop up menu is displayed through this code.
		CMenu zooMenu;
		POINT *lpPoint;
		lpPoint = (POINT * )malloc(1 * sizeof(POINT ));
		GetCursorPos(lpPoint);	
		zooMenu.LoadMenu( IDR_HEADER_MENU );
		CMenu* pPopup = zooMenu.GetSubMenu( 0 );

		pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,
								lpPoint->x,lpPoint->y,this );
	}
	
	return CDialog::OnNotify(wParam, lParam, pResult);
}




/*****************************************************************************
*																			 *
*Function: OnHeaderModifiedDateTime											 *
*																			 *
*Date of Creation: 14/09/2004												 *
*																			 *
*Version Number:															 *
*																			 *
*Parameters:                                                        		
*
*																			 *
*Return: void																 *
*																			 *
*Description: Toggles Show/Hide Modification Date/Time column				 *
*			                       											 *
*																			 *
*Revision History:															 *
*																			 *
******************************************************************************/
void CWitPlayerDlg::OnHeaderModifiedDateTime() 
{
	static int bChecked = 0;
	UINT nChecked; 
	if (bChecked) 
	{
		nChecked = MF_CHECKED;
	}
	else
	{
		nChecked = MF_UNCHECKED;
	}

	CMenu zooMenu;
	zooMenu.LoadMenu(IDR_HEADER_MENU);
	CMenu* pPopup = zooMenu.GetSubMenu(0);
	
	nChecked = pPopup->CheckMenuItem (ID_HEADER_MODIFIED_DATE_TIME,
nChecked );

	
	if (bChecked)
	{
		m_nVisibleColumns |= 4;
	}
	else
	{
		m_nVisibleColumns &= 0xFB;
	}
	
	RedrawWindow ();

	DefineColumn();
	FillRecordList();
	m_Record.SetVisibleColumns(m_nVisibleColumns);
	bChecked = !bChecked;
}


Regards 
Kushal
0
kushal
10/7/2004 11:10:11 AM
comp.os.programmer.win32 14522 articles. 0 followers. Post Follow

0 Replies
203 Views

Similar Articles

[PageSpeed] 18

Reply: