Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CStatic and Mouse clicks

369 views
Skip to first unread message

Mario Vogel

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
I wrote a class derived from CStatic.
Now I want to catch mouse clicks in the static control. Generally
CStatic objects don't catch these messages.
In the MSDN-Library I found an article in the periodicals of december
1997. They created the control with the
SS_NOTIFY flag and added the
ON_CONTROL_REFLECT(STN_CLICKED, OnClicked) message handler in the
cpp-file.
I did the same but nothing happens when i click in the static control.

what could be the reason?
is there another possibility to get the mouse clicks?

bye and thank you mario

Matt Slaughter

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
Is your static control created dynamically or is it in a resource? What code
is in your 'OnClicked' function? Maybe you should post some.

Matt


"Mario Vogel" <m.v...@ringwald.de> wrote in message
news:3A24FCBA...@ringwald.de...

Mario Vogel

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
thank you for your response,

my CStatic derived control is dynamically created without the ressource editor.
it has also a CFrameWnd as parent.
I think my problem is, that the control is not a child of a CDialog?

mario

Matt Slaughter wrote:

--
Dipl. Inf. Mario Vogel
Software-Entwicklung
Ringwald Mikroelektronik GmbH
Elberfelder Str. 18
10555 Berlin
-----------------------------
Tel.: ++49 (30) 390 479 24
Fax: ++49 (30) 390 479 29
E-Mail: m.v...@ringwald.de
Web: http://www.ringwald.de

Matt Slaughter

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
I don't think that is the problem. Post your derived static class and I'll
see if I can help. I used the example you are talking about with no
problems.

Matt

"Mario Vogel" <m.v...@ringwald.de> wrote in message

news:3A252F49...@ringwald.de...

Mario Vogel

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
ok, here are some parts of my programm;
the CStatic object is visible (I overloaded
the OnPaint() Message-Handler), but it doesn't
catch the mouse-event:


StaticInfo.h
--------------

class CStaticInfo : public CStatic
{
...

protected:

//{{AFX_MSG(CStaticInfo)
afx_msg void OnPaint();
//}}AFX_MSG
afx_msg void OnClicked();

...
}

StaticInfo.cpp
---------------

...

BEGIN_MESSAGE_MAP(CStaticInfo, CStatic)
//{{AFX_MSG_MAP(CStaticInfo)
ON_WM_PAINT()
//}}AFX_MSG_MAP
ON_CONTROL_REFLECT(STN_CLICKED, OnClicked)
END_MESSAGE_MAP()

...

void CStaticInfo::OnClicked()
{
AfxMessageBox("Text");
}


Declaration in CMainFrm.cpp
----------------------------

class CMainFrame : public CFrameWnd
{
...

protected:
CStaticInfo m_InfoRelaisA;

...
}

Calling function in CMainFrm.cpp
-----------------------------

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...


m_InfoRelaisA.Create(NULL,WS_VISIBLE|WS_CHILD|SS_NOTIFY,CRect(10,100,50,200),
this, 50);
m_InfoRelaisA.ShowWindow(SW_SHOWNORMAL);

...
}

Matt Slaughter

unread,
Nov 29, 2000, 3:00:00 AM11/29/00
to
This is kind of a guess, but it seems you want the control on the toolbar.
Am I right. If so, use the toolbar window as the parent to this static.

for ex.

m_InfoRelaisA.Create(NULL,WS_VISIBLE|WS_CHILD|SS_NOTIFY,CRect(10,100,50,200)
, &m_wndToolBar, 50);

and see if it works. I've done this with button controls and it works fine.


Matt


"Mario Vogel" <m.v...@ringwald.de> wrote in message

news:3A2535F8...@ringwald.de...


> ok, here are some parts of my programm;
> the CStatic object is visible (I overloaded
> the OnPaint() Message-Handler), but it doesn't
> catch the mouse-event:
>
>
> StaticInfo.h
> --------------
>
> class CStaticInfo : public CStatic
> {
> ...
>
> protected:
>

> file://{{AFX_MSG(CStaticInfo)
> afx_msg void OnPaint();
> file://}}AFX_MSG


> afx_msg void OnClicked();
>
> ...
> }
>
> StaticInfo.cpp
> ---------------
>
> ...
>
> BEGIN_MESSAGE_MAP(CStaticInfo, CStatic)

> file://{{AFX_MSG_MAP(CStaticInfo)
> ON_WM_PAINT()
> file://}}AFX_MSG_MAP

Mario Vogel

unread,
Nov 30, 2000, 3:00:00 AM11/30/00
to
no, I don't want the control on the toolbar.
it really has to be on the main window!
I think that's the problem.

I tried to put it on a CDialogbar object (it is the
only graphicel object where I could place the control except for the main
window).
But all controls of the dialog bar are created by the ressource editor. if I
create the
static control dynamically with the dialog bar as parent window, it will not be
visible!

by mario

Matt Slaughter wrote:

--

Matt Slaughter

unread,
Nov 30, 2000, 3:00:00 AM11/30/00
to
Where is this static located in your program. It looks as if it is in the
client area of the view window. I'm sure your problem is in the parent of
the control. The mouse clicks are going to another window in your program
other than the main frame window so the static control doesn't recieve them.
It seems that the control is somewhere in the area of where the main view
would be in and SDI app. If so make that view the parent of the control.

Matt

"Mario Vogel" <m.v...@ringwald.de> wrote in message

news:3A260CE3...@ringwald.de...

Sam Hobbs

unread,
Dec 2, 2000, 3:00:00 AM12/2/00
to
If the static control is being created in in the WM_CREATE message handler
and you are executing it using NT and if your program is not a UNICODE
program, then the problem is probably a bug in NT's UNICODE processing. If
all three of these requirements exist, then I can provide more information.
Also, if all three requirements exist, then try building a release version
that you can run using Windows 9X.


"Mario Vogel" <m.v...@ringwald.de> wrote in message

0 new messages