End Google Ads 201810 - BS.net 01 -->
I am in learning process:
here I am trying to create a custom control in mfc
file 1:
InserEdit.h
#pragma once
#include
#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?
مواقع النشر (المفضلة)