<?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[Mouse Event wird nicht angenommen]]></title><description><![CDATA[<p>Hallo</p>
<p>Habe eine eigene Klasse von CButton abgeleitet und möchte gerne das mouse Event &quot;Linke Taste gedrückt&quot; auswerten. Habe dazu auch die Message überschrieben. Leider reagiert der Dialog in dem der Button eingefügt wurde nie auf dieses Event. Habe auch einen Haltepunkt eingefügt (Zeile 57) und es wird nie angehalten. Müsste ich irgendwas anders machen?</p>
<p>CMyButton.h</p>
<pre><code class="language-cpp">#pragma once
#include &quot;ProfilPoint.h&quot;
// CMyButton

class CMyButton : public CButton
{
	DECLARE_DYNAMIC(CMyButton)
public:
	CMyButton();
	CMyButton(CList&lt;ProfilPoint&gt; &amp;pointList);
	virtual ~CMyButton();
	CList&lt;ProfilPoint&gt; *m_PointList;
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

protected:
	DECLARE_MESSAGE_MAP()

private:
	int x,y,zeile,spalte;
};
</code></pre>
<p>CMyButton.cpp</p>
<pre><code class="language-cpp">// MyButton.cpp : implementation file
//

#include &quot;stdafx.h&quot;
#include &quot;WingCut.h&quot;
#include &quot;MyButton.h&quot;
#include &quot;ExtendedEdit.h&quot;
#include &quot;ProfilPoint.h&quot;

// CMyButton

IMPLEMENT_DYNAMIC(CMyButton, CButton)

CMyButton::CMyButton()
{

}

CMyButton::CMyButton(CList&lt;ProfilPoint&gt; &amp;pointList)
{
	m_PointList = &amp;pointList;
	zeile=spalte=1;
}

CMyButton::~CMyButton()
{
}

BEGIN_MESSAGE_MAP(CMyButton, CButton)
		ON_WM_PAINT()
		ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

// CMyButton message handlers

void CMyButton::OnPaint()
{
	CButton::OnPaint();
	Invalidate(TRUE);
	CPaintDC dc(this);
	RECT frameRect;
	GetWindowRect(&amp;frameRect);
	x=frameRect.right-frameRect.left;
	y=frameRect.top-frameRect.bottom;
	dc.TextOutA(spalte*x/2,zeile*20,&quot;2&quot;);
}

void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
    Invalidate(TRUE);
	if (point.y &lt;= m_PointList-&gt;GetCount()*20)
	{
		zeile = point.y/20;
		spalte = 2*point.x/x;
	}
	CButton::OnLButtonDown(nFlags, point);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/199271/mouse-event-wird-nicht-angenommen</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Apr 2026 16:52:03 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/199271.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 30 Nov 2007 16:07:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Mouse Event wird nicht angenommen on Fri, 30 Nov 2007 16:07:07 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Habe eine eigene Klasse von CButton abgeleitet und möchte gerne das mouse Event &quot;Linke Taste gedrückt&quot; auswerten. Habe dazu auch die Message überschrieben. Leider reagiert der Dialog in dem der Button eingefügt wurde nie auf dieses Event. Habe auch einen Haltepunkt eingefügt (Zeile 57) und es wird nie angehalten. Müsste ich irgendwas anders machen?</p>
<p>CMyButton.h</p>
<pre><code class="language-cpp">#pragma once
#include &quot;ProfilPoint.h&quot;
// CMyButton

class CMyButton : public CButton
{
	DECLARE_DYNAMIC(CMyButton)
public:
	CMyButton();
	CMyButton(CList&lt;ProfilPoint&gt; &amp;pointList);
	virtual ~CMyButton();
	CList&lt;ProfilPoint&gt; *m_PointList;
	afx_msg void OnPaint();
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);

protected:
	DECLARE_MESSAGE_MAP()

private:
	int x,y,zeile,spalte;
};
</code></pre>
<p>CMyButton.cpp</p>
<pre><code class="language-cpp">// MyButton.cpp : implementation file
//

#include &quot;stdafx.h&quot;
#include &quot;WingCut.h&quot;
#include &quot;MyButton.h&quot;
#include &quot;ExtendedEdit.h&quot;
#include &quot;ProfilPoint.h&quot;

// CMyButton

IMPLEMENT_DYNAMIC(CMyButton, CButton)

CMyButton::CMyButton()
{

}

CMyButton::CMyButton(CList&lt;ProfilPoint&gt; &amp;pointList)
{
	m_PointList = &amp;pointList;
	zeile=spalte=1;
}

CMyButton::~CMyButton()
{
}

BEGIN_MESSAGE_MAP(CMyButton, CButton)
		ON_WM_PAINT()
		ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()

// CMyButton message handlers

void CMyButton::OnPaint()
{
	CButton::OnPaint();
	Invalidate(TRUE);
	CPaintDC dc(this);
	RECT frameRect;
	GetWindowRect(&amp;frameRect);
	x=frameRect.right-frameRect.left;
	y=frameRect.top-frameRect.bottom;
	dc.TextOutA(spalte*x/2,zeile*20,&quot;2&quot;);
}

void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
	// TODO: Add your message handler code here and/or call default
    Invalidate(TRUE);
	if (point.y &lt;= m_PointList-&gt;GetCount()*20)
	{
		zeile = point.y/20;
		spalte = 2*point.x/x;
	}
	CButton::OnLButtonDown(nFlags, point);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1413044</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1413044</guid><dc:creator><![CDATA[schmek]]></dc:creator><pubDate>Fri, 30 Nov 2007 16:07:07 GMT</pubDate></item></channel></rss>