Click here to Skip to main content
15,881,413 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Assigning Pointer To Object (Both of Same Class) Pin
Stefan_Lang25-Oct-12 3:30
Stefan_Lang25-Oct-12 3:30 
AnswerRe: Assigning Pointer To Object (Both of Same Class) Pin
Chris Meech25-Oct-12 2:14
Chris Meech25-Oct-12 2:14 
QuestionRe: Assigning Pointer To Object (Both of Same Class) Pin
David Crow25-Oct-12 2:40
David Crow25-Oct-12 2:40 
AnswerRe: Assigning Pointer To Object (Both of Same Class) Pin
CPallini25-Oct-12 10:37
mveCPallini25-Oct-12 10:37 
GeneralRe: Assigning Pointer To Object (Both of Same Class) Pin
Chris Meech26-Oct-12 2:44
Chris Meech26-Oct-12 2:44 
QuestionMenuItems' Icons are not Displaying properly in MFC Pin
002comp24-Oct-12 18:56
002comp24-Oct-12 18:56 
AnswerRe: MenuItems' Icons are not Displaying properly in MFC Pin
Richard MacCutchan24-Oct-12 21:58
mveRichard MacCutchan24-Oct-12 21:58 
GeneralRe: MenuItems' Icons are not Displaying properly in MFC Pin
002comp24-Oct-12 22:22
002comp24-Oct-12 22:22 
Hello

I found something interesting tht icons and text of menuItem is coming fine Except the menuList. As i click on any menu,menuList pops up and that list is coming wider,covering almost full screen.

I checked that OnMeasureItem which calculates ItemWidth and height is Having some Prob.As I Converted this from VC6 to VS2010.

C++
BOOL CCoolMenuManager::OnMeasureItem(LPMEASUREITEMSTRUCT lpms)
{
	ASSERT(lpms);
	CMyItemData* pmd = (CMyItemData*)lpms->itemData;
	ASSERT(pmd);
	if (lpms->CtlType != ODT_MENU || !pmd->IsMyItemData())
		return FALSE; // not handled by me

	if (pmd->fType & MFT_SEPARATOR) {
		// separator: use half system height and zero width
		lpms->itemHeight = GetSystemMetrics(SM_CYMENU)>>1;
		lpms->itemWidth  = 0;

	} else {

		// compute size of text: use DrawText with DT_CALCRECT

		CWindowDC dc(NULL);	// screen DC--I won't actually draw on it
		CRect rcText(0,0,0,0);
		CFont* pOldFont = dc.SelectObject(GetMenuFont());
		dc.DrawText(pmd->text, rcText, DT_MYSTANDARD|DT_CALCRECT);
		dc.SelectObject(pOldFont);

		// height of item is just height of a standard menu item
		lpms->itemHeight= max(GetSystemMetrics(SM_CYMENU), rcText.Height());

		// width is width of text plus a bunch of stuff
		int cx = rcText.Width();	// text width 
		cx += CXTEXTMARGIN<<1;		// L/R margin for readability
		cx += CXGAP;					// space between button and menu text
		cx += m_szButton.cx<<1;		// button width (L=button; R=empty margin)

		// whatever value I return in lpms->itemWidth, Windows will add the
		// width of a menu checkmark, so I must subtract to defeat Windows. Argh.
		//
		cx -= GetSystemMetrics(SM_CXMENUCHECK)-1;
		lpms->itemWidth = cx;		// done deal

		CMTRACE(_T("OnMeasureItem for '%s':\tw=%d h=%d\n"), (LPCTSTR)pmd->text,
			lpms->itemWidth, lpms->itemHeight);
	}
	return TRUE; // handled
}


or u can refer to this link
http://www.codeforge.com/read/89577/coolmenu.cpp__html[^]

Regards
Yogesh
GeneralRe: MenuItems' Icons are not Displaying properly in MFC Pin
002comp25-Oct-12 0:43
002comp25-Oct-12 0:43 
GeneralRe: MenuItems' Icons are not Displaying properly in MFC Pin
Richard MacCutchan25-Oct-12 6:19
mveRichard MacCutchan25-Oct-12 6:19 
AnswerRe: MenuItems' Icons are not Displaying properly in MFC Pin
Gary Qiu25-Oct-12 5:42
Gary Qiu25-Oct-12 5:42 
QuestionChartFX Compatiability Pin
Andrew Hoole24-Oct-12 5:50
Andrew Hoole24-Oct-12 5:50 
QuestionRe: ChartFX Compatiability Pin
David Crow24-Oct-12 6:05
David Crow24-Oct-12 6:05 
AnswerRe: ChartFX Compatiability Pin
Andrew Hoole24-Oct-12 6:24
Andrew Hoole24-Oct-12 6:24 
GeneralRe: ChartFX Compatiability Pin
Andrew Hoole24-Oct-12 22:00
Andrew Hoole24-Oct-12 22:00 
AnswerRe: ChartFX Compatiability Pin
krmed24-Oct-12 7:12
krmed24-Oct-12 7:12 
AnswerRe: ChartFX Compatiability Pin
Gary Qiu25-Oct-12 5:46
Gary Qiu25-Oct-12 5:46 
Questionthe program exit after creating process in the solaris Pin
jonesliu24-Oct-12 0:51
jonesliu24-Oct-12 0:51 
AnswerRe: the program exit after creating process in the solaris Pin
Richard MacCutchan24-Oct-12 1:06
mveRichard MacCutchan24-Oct-12 1:06 
QuestionFinding Min and Max of array Pin
Mikerush723-Oct-12 6:50
Mikerush723-Oct-12 6:50 
AnswerRe: Finding Min and Max of array Pin
jeron123-Oct-12 7:36
jeron123-Oct-12 7:36 
AnswerRe: Finding Min and Max of array Pin
Chris Losinger23-Oct-12 8:31
professionalChris Losinger23-Oct-12 8:31 
AnswerRe: Finding Min and Max of array Pin
CPallini23-Oct-12 10:47
mveCPallini23-Oct-12 10:47 
AnswerRe: Finding Min and Max of array Pin
«_Superman_»23-Oct-12 19:34
professional«_Superman_»23-Oct-12 19:34 
AnswerRe: Finding Min and Max of array Pin
Sajeesh Payolam23-Oct-12 20:10
Sajeesh Payolam23-Oct-12 20:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.