Click here to Skip to main content
15,902,905 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Read in .pdf files Pin
Rajesh R Subramanian3-Dec-10 1:34
professionalRajesh R Subramanian3-Dec-10 1:34 
AnswerRe: Read in .pdf files Pin
«_Superman_»3-Dec-10 8:30
professional«_Superman_»3-Dec-10 8:30 
GeneralRe: Read in .pdf files Pin
mesajflaviu3-Dec-10 20:10
mesajflaviu3-Dec-10 20:10 
QuestionGif in listctrl? Pin
Tcpip20052-Dec-10 16:45
Tcpip20052-Dec-10 16:45 
AnswerRe: Gif in listctrl? Pin
David Crow2-Dec-10 17:10
David Crow2-Dec-10 17:10 
AnswerRe: Gif in listctrl? Pin
Niklas L2-Dec-10 20:48
Niklas L2-Dec-10 20:48 
GeneralRe: Gif in listctrl? Pin
Tcpip20053-Dec-10 20:09
Tcpip20053-Dec-10 20:09 
QuestionVS 2010 - SubClass - FromHandlePermanent Assert Pin
Tony Teveris2-Dec-10 15:55
Tony Teveris2-Dec-10 15:55 
Trying to subclass a combobox i order to have the entries have a tab stop. When I perform the subclass I get an assert. This code use to work in the early days of MFC but with 2010 it fails. I did not try it with any VS version in between.
Is it something very simple I'm missing?

Thanks

class CTabCBox : public CComboBox
{
public:
	CTabCBox()	{icTab=0; lpiTab=NULL;}
	~CTabCBox()	{if (lpiTab) free(lpiTab);}

	// subclassed construction
	BOOL SubclassCBox(UINT nID,CWnd* pParent,int icTabs,LPINT lpiTabs);

protected:
	int icTab;		// count of tab stops
	LPINT lpiTab;	// tab stops in logical units

	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMis);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDis);
};



// CtestDlg dialog
class CtestDlg : public CDialogEx
{
// Construction
public:
	CtestDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	enum { IDD = IDD_TEST_DIALOG };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support


// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	DECLARE_MESSAGE_MAP()
public:
	CTabCBox m_ctrlFontsX;
	CComboBox m_ctrlFonts;
};

// from INITDIALOG
// TODO: Add extra initialization here
	TEXTMETRIC tm;
	int iTab;

	// compute tab stop
	if (m_ctrlFonts.GetDC()->GetTextMetrics(&tm))
		iTab = (33+8) * tm.tmAveCharWidth;

	m_ctrlFontsX.SubclassCBox(IDC_COMBO1,this,1,&iTab);

	CString csS("Font title string\tnnnnnnnn");

	m_ctrlFontsX.AddString(csS);



BOOL CTabCBox::SubclassCBox(UINT nID, CWnd* pParent, int icTabs, LPINT lpiTabs)	
{
	DWORD dwcb;
	int iRc = 0;

	// make very sure all tab members are free and clear
	if (lpiTab)
		free(lpiTab);
	lpiTab = NULL;
	icTab = 0;

	if (icTabs>0)
		{
		// make copy of tab info
		dwcb = icTabs*sizeof(int);
		if (!(lpiTab = (LPINT)malloc(dwcb)))
			return(FALSE);
		memcpy(lpiTab,lpiTabs,(size_t)dwcb);
		icTab = icTabs;
		}
	iRc = SubclassDlgItem(nID, pParent); // THIS CAUSES THE ASSERT
	return(iRc);
} // end of SubclassCBox

It always fails on the second assert (FromHandle....) from wincore.cpp
BOOL CWnd::Attach(HWND hWndNew)
{
	ASSERT(m_hWnd == NULL);     // only attach once, detach on destroy
	ASSERT(FromHandlePermanent(hWndNew) == NULL);
		// must not already be in permanent map

Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074

AnswerRe: VS 2010 - SubClass - FromHandlePermanent Assert Pin
Randor 2-Dec-10 19:20
professional Randor 2-Dec-10 19:20 
QuestionExcel automation: SetValue() function throws exception when user changes sheets Pin
garyflet2-Dec-10 9:14
garyflet2-Dec-10 9:14 
QuestionMy own written DLL not accessible in dialog based app; [modified] Pin
AmbiguousName2-Dec-10 8:41
AmbiguousName2-Dec-10 8:41 
AnswerRe: My own written DLL not accessible in dialog based app; Pin
Aescleal2-Dec-10 9:39
Aescleal2-Dec-10 9:39 
AnswerRe: My own written DLL not accessible in dialog based app; Pin
Sauro Viti2-Dec-10 9:39
professionalSauro Viti2-Dec-10 9:39 
GeneralRe: My own written DLL not accessible in dialog based app; Pin
AmbiguousName2-Dec-10 22:31
AmbiguousName2-Dec-10 22:31 
GeneralRe: My own written DLL not accessible in dialog based app; Pin
Sauro Viti3-Dec-10 1:36
professionalSauro Viti3-Dec-10 1:36 
Question[C++] First Order Logic (FOL) Parsing and Compiling Pin
erotavlas_turbo2-Dec-10 3:23
erotavlas_turbo2-Dec-10 3:23 
AnswerRe: [C++] First Order Logic (FOL) Parsing and Compiling Pin
Alain Rist2-Dec-10 6:43
Alain Rist2-Dec-10 6:43 
Questionhow to define 'window.myapp' instead of 'window.external' in IE Control with js? Pin
Jun Jin Pyo2-Dec-10 0:19
Jun Jin Pyo2-Dec-10 0:19 
Questiondisabling alt+space Pin
learningvisualc1-Dec-10 23:32
learningvisualc1-Dec-10 23:32 
AnswerRe: disabling alt+space Pin
Rajesh R Subramanian2-Dec-10 0:08
professionalRajesh R Subramanian2-Dec-10 0:08 
GeneralRe: disabling alt+space Pin
pasztorpisti2-Dec-10 3:30
pasztorpisti2-Dec-10 3:30 
AnswerRe: disabling alt+space Pin
Emilio Garavaglia2-Dec-10 22:30
Emilio Garavaglia2-Dec-10 22:30 
GeneralRe: disabling alt+space Pin
pasztorpisti2-Dec-10 23:00
pasztorpisti2-Dec-10 23:00 
GeneralRe: disabling alt+space Pin
Rajesh R Subramanian2-Dec-10 23:38
professionalRajesh R Subramanian2-Dec-10 23:38 
GeneralRe: disabling alt+space Pin
pasztorpisti3-Dec-10 0:13
pasztorpisti3-Dec-10 0:13 

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.