CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    23

    MFC ListCtrl Declaration, Help!

    Ok, this is probably something simple, but I cannot get it to work.


    project_main_header.h
    Code:
    #include <afxwin.h>
    #ifndef _DIALOGASMAINWINDOW_H_
    #define _DIALOGASMAINWINDOW_H_
    
    
    class CMyApp : public CWinApp
    {
    public:
    	virtual BOOL InitInstance();
    };
    
    
    class CMainDialog : public CDialog
    {
    public:
    	CMainDialog();
    	void OnDialogExit();
    protected:
    	virtual BOOL OnInitDialog();
    	virtual void PostNcDestroy();
    	afx_msg void OnPaint();
    	DECLARE_MESSAGE_MAP()
    private:
    	CListCtrl *pListCtrl;
    };
    
    
    
    #endif
    I'm having errors on the line I bolded. I need to declare a CListCtrl type variable. How do I accomplish this?

    [Edit]
    I should've been more specific with the error. The actual error spitted out from Visual Studio 2007 is

    c:\ee4970_huh\ee4970_project\ee4970_project\project_main_header.h(27) : error C2143: syntax error : missing ';' before '*'
    c:\ee4970_huh\ee4970_project\ee4970_project\project_main_header.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    c:\ee4970_huh\ee4970_project\ee4970_project\project_main_header.h(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

    Which is ofcanother way of saying that CListCtrl class does not exist, when in FACT it does.

    If I were to declare CListBox for example, this code would work perfectly but not CListCtrl.
    Last edited by l46kok; April 29th, 2008 at 05:45 PM.

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: MFC ListCtrl Declaration, Help!

    You have to include afxcmn.h as well.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: MFC ListCtrl Declaration, Help!

    You'd probably have an easier time letting the wizards create apps and dialogs for you.

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