Thread: My class doesn't create an edit box.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User Dante Shamest's Avatar
    Join Date
    Apr 2003
    Posts
    970
    Quote Originally Posted by Ken Fitlike
    You can but it's not pretty - well this isn't anyway:
    Thanks. Guess I've learnt something new today!

    I always thought GetDesktopHandle() returned NULL, and so I always used NULL for hWndParent when creating a child window, which of course never worked.

    Edit:
    @sethjackson

    I believe your problem is you have 2 different CWindow objects.

    One is a global object defined at the top of main.cpp

    Code:
    #include <windows.h>
    #include "editcontrol.h"
    #include "window.h"
    #include "main.h"
    
    CEditControl EditControl;
    CWindow Window;
    Another is a local object defined in CEditControl's Create() method.

    Code:
    int CEditControl::Create()
    {
    	CWindow Window;
        
    	m_hEdit = CreateWindowEx(
    	          WS_EX_CLIENTEDGE,
    	          "EDIT",
    	          NULL,
    	          WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | 
                      ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | 
                      ES_WANTRETURN,
    	          CW_USEDEFAULT,
    	          CW_USEDEFAULT,
    	          CW_USEDEFAULT,
    	          CW_USEDEFAULT,
    	          Window.g_hMainWindow,
    	          (HMENU)ID_TEXT,
    	          Window.g_hThisInstance,
    	          NULL
    	          );

    So you're trying to create the edit control using a local CWindow object that didn't call CWindow::Create.

    Another possible issue: Your CWindow and CEditControl contructors don't initialize their data members to meaningful values.
    Last edited by Dante Shamest; 09-02-2005 at 01:36 PM.

  2. #2
    Registered User
    Join Date
    Aug 2005
    Posts
    96
    So how do I fix it? Make CEditControl a subclass of CWindow?
    Also what should my constructors be initializing?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. edit box
    By beene in forum Windows Programming
    Replies: 3
    Last Post: 11-11-2006, 04:40 AM
  2. WS_HSCROLL in ES_READONLY edit box error
    By Homunculus in forum Windows Programming
    Replies: 4
    Last Post: 02-13-2006, 08:46 AM
  3. Multiline Edit Box Parser
    By The Brain in forum Windows Programming
    Replies: 6
    Last Post: 11-01-2005, 07:15 PM
  4. setting fixed floats in edit box
    By WaterNut in forum Windows Programming
    Replies: 4
    Last Post: 08-13-2004, 09:13 AM
  5. Limiting Characters in Edit Box :: MFC
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 06-02-2002, 10:21 AM