none
What #include do i need in order to use things like an edit control or a combo box

    Question

  • I'm using win32 API

     

    When I try to use CEdit or CComboBox i get the error "undeclared identifier". What do I need to include so I can use those? (individual includes for each would be fine as well)

     

    Thanks

    Wednesday, June 09, 2010 6:45 PM

Answers

  • hurtin_m wrote:
    > I am not using MFC. I don't want to use MFC. Can I do this without using MFC?
     
    CEdit and CComboBox are MFC classes. Naturally, you can't use MFC classes without using MFC.
    --
    Igor Tandetnik
     
     
    Wednesday, June 09, 2010 7:19 PM

All replies

  • Did you create a MFC solution from the wizard? If you did, then including the "stdafx.h" should have the correct includes. Nonetheless, below is an example of the stdafx.h file which includes the MFC items needed.

     

    // stdafx.h : include file for standard system include files,
    // or project specific include files that are used frequently,
    // but are changed infrequently
    
    #pragma once
    
    #ifndef _SECURE_ATL
    #define _SECURE_ATL 1
    #endif
    
    #ifndef VC_EXTRALEAN
    #define VC_EXTRALEAN      // Exclude rarely-used stuff from Windows headers
    #endif
    
    #include "targetver.h"
    
    #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS   // some CString constructors will be explicit
    
    // turns off MFC's hiding of some common and often safely ignored warning messages
    #define _AFX_ALL_WARNINGS
    
    #include <afxwin.h>     // MFC core and standard components
    #include <afxext.h>     // MFC extensions
    
    
    #include <afxdisp.h>    // MFC Automation classes
    
    
    
    #ifndef _AFX_NO_OLE_SUPPORT
    #include <afxdtctl.h>      // MFC support for Internet Explorer 4 Common Controls
    #endif
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h>       // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT
    
    #include <afxcontrolbars.h>   // MFC support for ribbons and control bars
    
    #ifdef _UNICODE
    #if defined _M_IX86
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_IA64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #elif defined _M_X64
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #else
    #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    #endif
    #endif
    

    Cheers,

    Monte--

    Wednesday, June 09, 2010 7:12 PM
  • I am not using MFC. I don't want to use MFC. Can I do this without using MFC?

     

    Thanks for the response

    Wednesday, June 09, 2010 7:16 PM
  • hurtin_m wrote:
    > I am not using MFC. I don't want to use MFC. Can I do this without using MFC?
     
    CEdit and CComboBox are MFC classes. Naturally, you can't use MFC classes without using MFC.
    --
    Igor Tandetnik
     
     
    Wednesday, June 09, 2010 7:19 PM
  • Thanks for the response. How then other than sending messages to those items directly can I use the control box and edit control that I've placed on a dialog box?

    Wednesday, June 09, 2010 7:25 PM
  • Yes, you can still program at the SDK level. MFC just make the work easier.

    The following is signature, not part of post
    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Visual C++ MVP
    Wednesday, June 09, 2010 7:30 PM
  • hurtin_m wrote:
    > Thanks for the response. How then other than sending messages to those items directly can I use the control box and edit control
    > that I've placed on a dialog box?
     
    Well, if you insist on using Win32 API and nothing else, then you send messages. If you don't like that, then you would need to use
    (or write) some wrapper library, such as MFC or WTL.
    --
    Igor Tandetnik
     
     
    Wednesday, June 09, 2010 7:30 PM
  • It sounds like WTL might be suitable for what you want to do. Personally I use WTL whenever possible and MFC only when forced to.

    http://wtl.sourceforge.net/

    Wednesday, June 09, 2010 7:30 PM
  • If you are using MFC Controls (for ctrl box and edit ctrl) then you need to include the MFC libraries. Else you will not be able to compile at the first place.

    If you do not want to use MFC use the windows api controls. For e.g drawing an edit control

    CreateWindow( "edit", "",
    WS_VISIBLE|WS_CHILD|WS_BORDER|ES_AUTOHSCROLL|ES_AUTOVSCROLL,
    0, 0, nClientWidth, nClientHeight, hwnd, (HMENU)nEditID, hInstance, NULL);
    You can also process the notification messages for these control manually in the WndProc
    if (HIWORD(wParam) == EN_CHANGE && LOWORD(wParam) == nEditID)
    {
             Do something .....
    }

    A for apple, B for boy, C for c++
    Wednesday, June 09, 2010 7:34 PM
  • Well I am using list box (originally had been using combo boxes but realized that list box is what I actually want) and edit control objects in my program but I never initiated MFC and when I tried to use a header file needed for CEdit (as I'd looked up in google that someone had posted for their code) I got an error message stating something about not having MFC or something (I really don't know anything about it). In any case, such far with the program that I am currently working on I have been able to do what is needed using messages.

     

    Thanks for the info regarding MFC and WTL though. It's good to know. Thanks for all the responses.

    Wednesday, June 09, 2010 11:14 PM