Click here to Skip to main content
15,867,453 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionI had this interview question Pin
Software200718-Jun-11 4:26
Software200718-Jun-11 4:26 
AnswerRe: I had this interview question Pin
Philippe Mori18-Jun-11 5:14
Philippe Mori18-Jun-11 5:14 
GeneralRe: I had this interview question Pin
Software200718-Jun-11 15:17
Software200718-Jun-11 15:17 
AnswerRe: I had this interview question Pin
Chuck O'Toole18-Jun-11 15:59
Chuck O'Toole18-Jun-11 15:59 
GeneralRe: I had this interview question Pin
Software200719-Jun-11 13:53
Software200719-Jun-11 13:53 
AnswerRe: I had this interview question Pin
Stefan_Lang19-Jun-11 23:23
Stefan_Lang19-Jun-11 23:23 
GeneralRe: I had this interview question Pin
Software200720-Jun-11 3:17
Software200720-Jun-11 3:17 
Question__debugbreak(); [modified] Pin
Mohibur Rashid17-Jun-11 18:07
professionalMohibur Rashid17-Jun-11 18:07 
I am in learning process:

here I am trying to create a custom control in mfc
file 1:
InserEdit.h
#pragma once
#include <afxwin.h>
#define INSERTWINDOWCLASS L"INSERTWINDOWCLASS"
class CInsertEdit :
	public CWnd
{
DECLARE_DYNAMIC(CInsertEdit)
protected:
	CEdit *cid,*UserName,*PhoneNumber,*DateOfBirth,*Nationalities;
	//int OnCreate(LPCREATESTRUCT lpCreateStruct);
	BOOL PreCreateWindow(CREATESTRUCT& cs);
	void PreSubclassWindow();
public:
	CInsertEdit();
	~CInsertEdit(void);
	BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle);
	
	DECLARE_MESSAGE_MAP()

private:
  //bool	m_bIsDynCreate;
  BOOL RegisterWindowClass();
};

InsertEdit.cpp
#include "InsertEdit.h"
BEGIN_MESSAGE_MAP( CInsertEdit, CWnd)
    
END_MESSAGE_MAP()
IMPLEMENT_DYNAMIC(CInsertEdit, CWnd)
CInsertEdit::CInsertEdit()
{
	RegisterWindowClass();
	return;
}

BOOL CInsertEdit::RegisterWindowClass()
{
	 WNDCLASS wndcls;
    HINSTANCE hInst = AfxGetInstanceHandle();

     if (!(::GetClassInfo(hInst, INSERTWINDOWCLASS, &wndcls)))
    {
		memset(&wndcls, 0, sizeof(WNDCLASS));
        wndcls.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndcls.lpfnWndProc      = ::DefWindowProc;
        wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;
        wndcls.hInstance        = hInst;
        wndcls.hIcon            = NULL;
        wndcls.hCursor          = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
        wndcls.hbrBackground    = (HBRUSH) (COLOR_WINDOW);//(HBRUSH) RGB(255,255,255);
        wndcls.lpszMenuName     = NULL;
        wndcls.lpszClassName    = INSERTWINDOWCLASS;
		wndcls.cbWndExtra		= NULL;

        if (!AfxRegisterClass(&wndcls))
        {
            AfxThrowResourceException();
            return FALSE;
        }
    }

    return TRUE;
}
CInsertEdit::~CInsertEdit(void)
{
}
BOOL CInsertEdit::PreCreateWindow(CREATESTRUCT& cs)
{
	/*cid=new CEdit();
	BOOL what=cid->Create(WS_VISIBLE|WS_CHILD|WS_BORDER,CRect(0,0,100,24),this,1);*/
	
	return CWnd::PreCreateWindow(cs);
}
void CInsertEdit::PreSubclassWindow()
{
	CWnd::PreSubclassWindow();
	cid=new CEdit();
	BOOL what=cid->Create(WS_VISIBLE|WS_CHILD|WS_BORDER,CRect(0,0,100,24),this,1);
	
}
//INSERTWINDOWCLASS
BOOL CInsertEdit::Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle)
{
	//m_bIsDynCreate=TRUE;
	
	/*{
	
	}*/
	return CWnd::Create(INSERTWINDOWCLASS,L"",dwStyle,rect,pParentWnd,nID);
}


The problem is when i run the program it triggers to debug break point. it is created in PreSubclassWindow class. on line 3 with cig->Create calling. can anyone point out what I am doing wrong?

modified on Saturday, June 18, 2011 4:57 AM

AnswerRe: __debugbreak(); Pin
Richard MacCutchan17-Jun-11 22:48
mveRichard MacCutchan17-Jun-11 22:48 
AnswerRe: __debugbreak(); Pin
Mohibur Rashid17-Jun-11 23:04
professionalMohibur Rashid17-Jun-11 23:04 
GeneralRe: __debugbreak(); Pin
Philippe Mori18-Jun-11 5:17
Philippe Mori18-Jun-11 5:17 
Question[Win32]Set Dialog Bitmap Background Pin
Member 296547117-Jun-11 13:20
Member 296547117-Jun-11 13:20 
AnswerRe: [Win32]Set Dialog Bitmap Background Pin
Cheongwadae17-Jun-11 14:34
Cheongwadae17-Jun-11 14:34 
GeneralRe: [Win32]Set Dialog Bitmap Background Pin
Ram Shelke17-Jun-11 22:09
Ram Shelke17-Jun-11 22:09 
AnswerRe: [Win32]Set Dialog Bitmap Background Pin
enhzflep18-Jun-11 3:05
enhzflep18-Jun-11 3:05 
QuestionError 2248: cannot access protected member declared in CWinapp Pin
eastman7517-Jun-11 8:23
eastman7517-Jun-11 8:23 
QuestionRe: Error 2248: cannot access protected member declared in CWinapp Pin
Abhi Lahare17-Jun-11 8:36
Abhi Lahare17-Jun-11 8:36 
AnswerRe: Error 2248: cannot access protected member declared in CWinapp Pin
eastman7521-Jun-11 19:23
eastman7521-Jun-11 19:23 
AnswerRe: Error 2248: cannot access protected member declared in CWinapp Pin
Albert Holguin17-Jun-11 8:44
professionalAlbert Holguin17-Jun-11 8:44 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
eastman7517-Jun-11 22:10
eastman7517-Jun-11 22:10 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
Richard MacCutchan17-Jun-11 22:52
mveRichard MacCutchan17-Jun-11 22:52 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
Albert Holguin18-Jun-11 6:38
professionalAlbert Holguin18-Jun-11 6:38 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
eastman7519-Jun-11 5:01
eastman7519-Jun-11 5:01 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
eastman7520-Jun-11 5:39
eastman7520-Jun-11 5:39 
GeneralRe: Error 2248: cannot access protected member declared in CWinapp Pin
Albert Holguin20-Jun-11 7:25
professionalAlbert Holguin20-Jun-11 7:25 

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.