<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OnCreate Message&#x2F;Funktion wird nich augerufen!!??]]></title><description><![CDATA[<p>habe ein eingen CWnd Element( CGraphic), welche ich in einem Dialog anzeigen will.. diese Element erzeuge ich im dialog so:</p>
<pre><code class="language-cpp">BOOL CDlgVisMachine::OnInitDialog(){

	CDialog::OnInitDialog();

	p= new CGraphic();

	p-&gt;Create(_T(&quot;System&quot;), &quot;Hi&quot;, WS_CHILD | WS_VISIBLE,
       CRect(0, 0, 500, 300), this, 1234);
	p-&gt;ShowWindow(SW_SHOW);
	p-&gt;UpdateWindow();
	return TRUE;
}
</code></pre>
<p>Nun sollte eigenlich die Funktion OnCreate der CGraphic aufgerufen werden:</p>
<pre><code class="language-cpp">//header
class CGraphic : public CWnd{

	DECLARE_DYNAMIC(CGraphic)
private:

	CDC *pDC;
	void VisSys();
public:
	CGraphic();
	virtual ~CGraphic();
	afx_msg int OnCreate(LPCREATESTRUCT lpCS);
	afx_msg void OnPaint();

protected:
	DECLARE_MESSAGE_MAP()
};

// CPP ///////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC(CGraphic, CWnd)

CGraphic::CGraphic(){

//pDC=NULL;
}

CGraphic::~CGraphic(){

}
int CGraphic::OnCreate(LPCREATESTRUCT lpCS){

	if (CWnd::OnCreate(lpCS) == -1)
		return -1;

	CDC *p = GetDC();

	pDC-&gt;CreateCompatibleDC(p);
	LPRECT lpRC;
	GetWindowRect(lpRC);
	pDC-&gt;SetWindowOrg(lpRC-&gt;left,lpRC-&gt;top);
	pDC-&gt;SetWindowExt(lpRC-&gt;right,lpRC-&gt;bottom);

	VisSys();

return 0;

}
void CGraphic::OnPaint(){

 PAINTSTRUCT ps;

 CDC* pReal = BeginPaint(&amp;ps);

 //if(pDC!=NULL) 
	pReal-&gt;BitBlt(0,0, 500, 300, pDC, 0, 0, SRCCOPY);

 EndPaint(&amp;ps);

 CWnd::OnPaint();
}
void CGraphic::VisSys(){

CBitmap *oldBitmap;
CDC *pTemp;
CBitmap *bitmap = new CBitmap();

pTemp-&gt;CreateCompatibleDC(pDC);
	//In Memory-DC zeichnen statt in &quot;echtem&quot; DeviceContext:
	//Bitmap von width*height Pixeln mit 32 Bit Farbtiefe erzeugen:
	//bitmap-&gt;LoadBitmap(&quot;test.bmp&quot;);

bitmap-&gt;LoadBitmap(IDB_BITMAP2);
	//bitmap-&gt;CreateBitmap ( intWidth, intHeight, 1, 32, NULL);
	//CSize o= bitmap-&gt;GetBitmapDimension();
	int intWidth= 300;//o.cx;
	int intHeight= 300;//o.cy;

	//Kopieren der Bitmap in Temporären Device-Context:
oldBitmap = pTemp-&gt;SelectObject (bitmap);

pDC-&gt;BitBlt(100,50, intWidth, intHeight, pTemp, 0, 0, SRCCOPY);
pDC-&gt;BitBlt(300,50, intWidth, intHeight, pTemp, 0, 0, SRCCOPY);

pTemp-&gt;SelectObject(oldBitmap);
pTemp-&gt;DeleteDC();
delete bitmap;
}
BEGIN_MESSAGE_MAP(CGraphic, CWnd)

	ON_WM_PAINT()
	ON_WM_CREATE()
END_MESSAGE_MAP()
</code></pre>
<p>er springt mir einfach nich in die OnCreate Funktion.. er stürtu bei &quot;ShowWindow&quot; siehe oben ab??</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/175328/oncreate-message-funktion-wird-nich-augerufen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Apr 2026 21:02:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/175328.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 09 Mar 2007 09:52:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OnCreate Message&#x2F;Funktion wird nich augerufen!!?? on Fri, 09 Mar 2007 09:52:26 GMT]]></title><description><![CDATA[<p>habe ein eingen CWnd Element( CGraphic), welche ich in einem Dialog anzeigen will.. diese Element erzeuge ich im dialog so:</p>
<pre><code class="language-cpp">BOOL CDlgVisMachine::OnInitDialog(){

	CDialog::OnInitDialog();

	p= new CGraphic();

	p-&gt;Create(_T(&quot;System&quot;), &quot;Hi&quot;, WS_CHILD | WS_VISIBLE,
       CRect(0, 0, 500, 300), this, 1234);
	p-&gt;ShowWindow(SW_SHOW);
	p-&gt;UpdateWindow();
	return TRUE;
}
</code></pre>
<p>Nun sollte eigenlich die Funktion OnCreate der CGraphic aufgerufen werden:</p>
<pre><code class="language-cpp">//header
class CGraphic : public CWnd{

	DECLARE_DYNAMIC(CGraphic)
private:

	CDC *pDC;
	void VisSys();
public:
	CGraphic();
	virtual ~CGraphic();
	afx_msg int OnCreate(LPCREATESTRUCT lpCS);
	afx_msg void OnPaint();

protected:
	DECLARE_MESSAGE_MAP()
};

// CPP ///////////////////////////////////////////////////////

IMPLEMENT_DYNAMIC(CGraphic, CWnd)

CGraphic::CGraphic(){

//pDC=NULL;
}

CGraphic::~CGraphic(){

}
int CGraphic::OnCreate(LPCREATESTRUCT lpCS){

	if (CWnd::OnCreate(lpCS) == -1)
		return -1;

	CDC *p = GetDC();

	pDC-&gt;CreateCompatibleDC(p);
	LPRECT lpRC;
	GetWindowRect(lpRC);
	pDC-&gt;SetWindowOrg(lpRC-&gt;left,lpRC-&gt;top);
	pDC-&gt;SetWindowExt(lpRC-&gt;right,lpRC-&gt;bottom);

	VisSys();

return 0;

}
void CGraphic::OnPaint(){

 PAINTSTRUCT ps;

 CDC* pReal = BeginPaint(&amp;ps);

 //if(pDC!=NULL) 
	pReal-&gt;BitBlt(0,0, 500, 300, pDC, 0, 0, SRCCOPY);

 EndPaint(&amp;ps);

 CWnd::OnPaint();
}
void CGraphic::VisSys(){

CBitmap *oldBitmap;
CDC *pTemp;
CBitmap *bitmap = new CBitmap();

pTemp-&gt;CreateCompatibleDC(pDC);
	//In Memory-DC zeichnen statt in &quot;echtem&quot; DeviceContext:
	//Bitmap von width*height Pixeln mit 32 Bit Farbtiefe erzeugen:
	//bitmap-&gt;LoadBitmap(&quot;test.bmp&quot;);

bitmap-&gt;LoadBitmap(IDB_BITMAP2);
	//bitmap-&gt;CreateBitmap ( intWidth, intHeight, 1, 32, NULL);
	//CSize o= bitmap-&gt;GetBitmapDimension();
	int intWidth= 300;//o.cx;
	int intHeight= 300;//o.cy;

	//Kopieren der Bitmap in Temporären Device-Context:
oldBitmap = pTemp-&gt;SelectObject (bitmap);

pDC-&gt;BitBlt(100,50, intWidth, intHeight, pTemp, 0, 0, SRCCOPY);
pDC-&gt;BitBlt(300,50, intWidth, intHeight, pTemp, 0, 0, SRCCOPY);

pTemp-&gt;SelectObject(oldBitmap);
pTemp-&gt;DeleteDC();
delete bitmap;
}
BEGIN_MESSAGE_MAP(CGraphic, CWnd)

	ON_WM_PAINT()
	ON_WM_CREATE()
END_MESSAGE_MAP()
</code></pre>
<p>er springt mir einfach nich in die OnCreate Funktion.. er stürtu bei &quot;ShowWindow&quot; siehe oben ab??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1242156</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1242156</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Fri, 09 Mar 2007 09:52:26 GMT</pubDate></item><item><title><![CDATA[Reply to OnCreate Message&#x2F;Funktion wird nich augerufen!!?? on Fri, 09 Mar 2007 12:21:56 GMT]]></title><description><![CDATA[<p>Dein Fenster wird gar nicht erzeugt.<br />
Ich würde mal ein wenig Fehlerprüfung einbauen p-&gt;Create(_T(&quot;System&quot;),...) returniert mit Sicherheit FALSE!</p>
<p>Deine Fensterklasse heißt ja auch nicht System, oder?<br />
Verpass Deinem Fenster erstmal einen korrekten Klassenamen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1242251</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1242251</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 09 Mar 2007 12:21:56 GMT</pubDate></item><item><title><![CDATA[Reply to OnCreate Message&#x2F;Funktion wird nich augerufen!!?? on Fri, 09 Mar 2007 12:35:30 GMT]]></title><description><![CDATA[<p>ist diese String nich willkürlich drinierbar??? oder ist damit der name der Parent Fenster gemeint??</p>
<p>Muss ich das din dann &quot;CGraphis&quot; nennen oder wie?</p>
<p>ja die create funktion liefert fehler HWND ist = NULL!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1242257</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1242257</guid><dc:creator><![CDATA[BorisDieKlinge]]></dc:creator><pubDate>Fri, 09 Mar 2007 12:35:30 GMT</pubDate></item><item><title><![CDATA[Reply to OnCreate Message&#x2F;Funktion wird nich augerufen!!?? on Fri, 09 Mar 2007 16:36:35 GMT]]></title><description><![CDATA[<p>Nein! Dieser String ist nicht frei definierbar. Bitte registriere eine entsprechende Klasse. AfxRegisterClass heißt das Stichwort. Technisch gesehen solltest Du Deine eigene Create Funktion schreiben und PreCreateClass auch überschreiben um die entsprechende Klasse zu registrieren.</p>
<p>Wenn Du Dir das sparen willst musst Du den Klassennamen als NULL übergeben. In diesem Fall erzeugt die MFC eine passende Klasse.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1242428</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1242428</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Fri, 09 Mar 2007 16:36:35 GMT</pubDate></item></channel></rss>