Click here to Skip to main content
15,910,773 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: multiline edit box with 10000 lines??? Pin
rocky_pulley15-Feb-05 1:47
rocky_pulley15-Feb-05 1:47 
AnswerRe: multiline edit box with 10000 lines??? Pin
David Crow15-Feb-05 4:15
David Crow15-Feb-05 4:15 
AnswerRe: multiline edit box with 10000 lines??? Pin
Ravi Bhavnani15-Feb-05 9:08
professionalRavi Bhavnani15-Feb-05 9:08 
GeneralCalling a C# dll from VC 7 Pin
CLermen15-Feb-05 0:59
CLermen15-Feb-05 0:59 
GeneralRe: Calling a C# dll from VC 7 Pin
Mike Dimmick15-Feb-05 1:15
Mike Dimmick15-Feb-05 1:15 
GeneralRe: Calling a C# dll from VC 7 Pin
CLermen15-Feb-05 2:01
CLermen15-Feb-05 2:01 
GeneralCreating child windows in PreSubclassWindow Pin
Garth Watkins15-Feb-05 0:43
Garth Watkins15-Feb-05 0:43 
GeneralRe: Creating child windows in PreSubclassWindow Pin
Garth Watkins15-Feb-05 9:22
Garth Watkins15-Feb-05 9:22 
Hi Garth

The question you pose is an interesting one. In fact all the questions you've asked are quite amazing. You're either incredibly clever or supremely (?) stupid as no one on this forum has ever answered you're questions. Anyway let me have a crack at it.
Create a method, call it say, Initialize() which creates all the child windows etc.
Override Create a method CMyControl::Create() which clients must call when creating your control dynamically. Add a BOOL property (member variable) to the control, call it say 'm_bIsDynCreate', and set it to FALSE in constructor of the control. Now in your custom Create() function, set this variable to TRUE, call the base Create method e.g. CWnd::Create(...) and then call your intialize method. In your Overriden PreSubclass method, test 'm_bIsDynCreate'. If it is FALSE, call Initialize(..), otherwise don't, as it will have already been called when creating the control dynamically. When called as part of the creating cycle of a dialog, it will be called in PreSubclass window.

Here is some source code for your perusal.
<br />
BOOL CGarthsCtrl::Create(const RECT & rect,CWnd* pParentWnd,UINT nID,DWORD dwStyle)<br />
{<br />
	m_bIsDynCreate=TRUE;<br />
	if(!CWnd::Create("GARTHSCTRL",NULL,dwStyle|CS_DBLCLKS | CS_HREDRAW |    CS_VREDRAW,rect,pParentWnd,nID))<br />
		return FALSE;<br />
	Initialize();<br />
	<br />
	return TRUE;<br />
<br />
}<br />


<br />
void CGarthsCtrl::PreSubclassWindow()<br />
{<br />
	CWnd::PreSubclassWindow();<br />
	if(m_bIsDynCreate==FALSE)<br />
        Initialize();<br />
<br />
}<br />


Funnily enough, Garth, I was experiencing just the same problem this afternoon. Talk about coincidences.

Anyway I hope this helps you somewhat.

Regards
Garth
GeneralRe: Creating child windows in PreSubclassWindow Pin
Garth Watkins15-Feb-05 9:26
Garth Watkins15-Feb-05 9:26 
GeneralRe: Creating child windows in PreSubclassWindow Pin
ThatsAlok16-Feb-05 19:07
ThatsAlok16-Feb-05 19:07 
GeneralMove a child window to an absolute position Pin
doctorpi14-Feb-05 22:32
doctorpi14-Feb-05 22:32 
GeneralRe: Move a child window to an absolute position Pin
Rajesh_Parameswaran15-Feb-05 0:14
Rajesh_Parameswaran15-Feb-05 0:14 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 0:20
doctorpi15-Feb-05 0:20 
GeneralRe: Move a child window to an absolute position Pin
User 665815-Feb-05 0:44
User 665815-Feb-05 0:44 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 0:50
doctorpi15-Feb-05 0:50 
GeneralRe: Move a child window to an absolute position Pin
Antony M Kancidrowski15-Feb-05 2:36
Antony M Kancidrowski15-Feb-05 2:36 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 2:39
doctorpi15-Feb-05 2:39 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 2:52
doctorpi15-Feb-05 2:52 
GeneralRe: Move a child window to an absolute position Pin
Antony M Kancidrowski15-Feb-05 13:46
Antony M Kancidrowski15-Feb-05 13:46 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 20:50
doctorpi15-Feb-05 20:50 
GeneralRe: Move a child window to an absolute position Pin
doctorpi15-Feb-05 21:04
doctorpi15-Feb-05 21:04 
Generalbeginner to the Visual C++ Pin
Munisamy14-Feb-05 21:59
Munisamy14-Feb-05 21:59 
GeneralRe: beginner to the Visual C++ Pin
rocky_pulley15-Feb-05 1:19
rocky_pulley15-Feb-05 1:19 
Generalhelp needed in shellexecute Pin
URagavSouth14-Feb-05 21:43
URagavSouth14-Feb-05 21:43 
GeneralRe: help needed in shellexecute Pin
22491714-Feb-05 22:32
22491714-Feb-05 22:32 

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.