Event handler using a control variable and not using message map 
Author Message
 Event handler using a control variable and not using message map

Hello -

   I have used the resource editor to add a static text
control on a dialog and have assiged a control variable
(m_ctrlvar1) to a control ID (ID_CTRL1) that I created for
this control.  In my code I can reference the object using
this variable.  I have also successfully mapped the mouse
click using the wizard.  What I really want to do is
redefine the control's OnLButtonDown() member function so
that the code I put in the OnLButtonDown() function will
be executed with a call to  m_ctrlvar1.OnLButtonDown()  or
when the used depressed the left mouse button.  Can this
be done?

       Thanks,

               Kev

                  Z++ Technologies



Sun, 22 Feb 2004 01:09:01 GMT  
 Event handler using a control variable and not using message map
Kevin,

I think you can do something like
::PostMessage(m_ctrlvar1.m_hWnd, WM_LBUTTONDOWN, 0, 0);

--
Bjarne Nielsen



Quote:
> Hello -

>    I have used the resource editor to add a static text
> control on a dialog and have assiged a control variable
> (m_ctrlvar1) to a control ID (ID_CTRL1) that I created for
> this control.  In my code I can reference the object using
> this variable.  I have also successfully mapped the mouse
> click using the wizard.  What I really want to do is
> redefine the control's OnLButtonDown() member function so
> that the code I put in the OnLButtonDown() function will
> be executed with a call to  m_ctrlvar1.OnLButtonDown()  or
> when the used depressed the left mouse button.  Can this
> be done?

>        Thanks,

>                Kev

>                   Z++ Technologies



Sun, 22 Feb 2004 02:53:30 GMT  
 Event handler using a control variable and not using message map
It looks like subclassing is what I need.  Thanks.

Quote:
>-----Original Message-----
>Kevin,

>I think you can do something like
>::PostMessage(m_ctrlvar1.m_hWnd, WM_LBUTTONDOWN, 0, 0);

>--
>Bjarne Nielsen


i en meddelelse

>> Hello -

>>    I have used the resource editor to add a static text
>> control on a dialog and have assiged a control variable
>> (m_ctrlvar1) to a control ID (ID_CTRL1) that I created
for
>> this control.  In my code I can reference the object
using
>> this variable.  I have also successfully mapped the
mouse
>> click using the wizard.  What I really want to do is
>> redefine the control's OnLButtonDown() member function
so
>> that the code I put in the OnLButtonDown() function will
>> be executed with a call to  m_ctrlvar1.OnLButtonDown()  
or
>> when the used depressed the left mouse button.  Can this
>> be done?

>>        Thanks,

>>                Kev

>>                   Z++ Technologies

>.



Sun, 22 Feb 2004 04:19:46 GMT  
 Event handler using a control variable and not using message map
If I understand You correctly You have to make Your own control class
based on the CStatic class and associate this with Your control
variable (m_ctrlvar). When You have done this You can use class wizard
to add message handlers for whatever event You want to handle.

First create a new class with class wizard. Select MFC type and chose
CStatic as Your base class. Name it CMyStatic (or whatever You want).
To associate Your m_ctrlvar with CMyStatic open the header file for
Your dialog and change the type of m_ctrlvar from CStatic to CMyStatic
(alternatively, chose CMyStatic as the control type when creating
control variables with class wizard). You can now select almost any
message to create a handler for in the CMyStatic class with class
wizard.

Now You have created Your own control and the best of all - You don't
even have to write a single line of code in Your dialog class, the
control handles everything itself.

Ruben

On Tue, 4 Sep 2001 10:09:01 -0700, "Kevin Zielinski"

Quote:

>Hello -

>   I have used the resource editor to add a static text
>control on a dialog and have assiged a control variable
>(m_ctrlvar1) to a control ID (ID_CTRL1) that I created for
>this control.  In my code I can reference the object using
>this variable.  I have also successfully mapped the mouse
>click using the wizard.  What I really want to do is
>redefine the control's OnLButtonDown() member function so
>that the code I put in the OnLButtonDown() function will
>be executed with a call to  m_ctrlvar1.OnLButtonDown()  or
>when the used depressed the left mouse button.  Can this
>be done?

>       Thanks,

>               Kev

>                  Z++ Technologies



Sun, 22 Feb 2004 14:06:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to add custom window message handler to MESSAGE MAP

2. Using GetMenuItemInfo for Dynamic Menu Event Handler

3. sample project using 'message handler'

4. CListBox: assertion failed error when functions are used in message handler of View-Class (SDI)

5. Using types in a different assembly given that the type may be used or not used

6. Error handler not called using __hook

7. ImageButton Click Event Handler Not Getting Fired, why not

8. Using ClassWizard to map messages in a DLL?

9. How to get MM_WIM_DATA using the message map?

10. warning messages using multi level map templates

11. mapping multiple messages to one handler

12. Write to Event Log without using the Message Compiler

 

 
Powered by phpBB® Forum Software