Problem with user control

Posted on 2005-04-06
Last Modified: 2010-04-24

I have created a library that has a user control.
The user control has some windows control such as button or linklabel.
I use this library as "my user controls" in another projects.

my question is how I can find out that specific button or linklabel
clicked when I want to write their handlers in another project (not the same project that I design the user control) ?

Thank you.
Question by:mr60
    LVL 3

    Expert Comment

    Trap the event handlers using the message map. The controls you created should have IDs assigned to them in the resource.h file. You must have done so when created the controls. Now, trap the events in the map such as:
    and so on...
    LVL 1

    Author Comment


    when users use library in another projects, they don't have Handler_Func; they should define their custom handlers and any one don't know their name previously.
    LVL 3

    Accepted Solution

    The name of the function is not important. What is important is that they use the same ID for the control and the proper event macro. So, for button clicked they would use
    ON_BN_CLICKED(ID_OF_CONTROL, Their_Handler Func)
    They will define their function based on the type of event they are trying to catch.
    For Button Clicked, they would prototype it to be something like:
    afx_msg void OnButtonClick(void);
    Once they write it and the event fires that matches the ID of the control, their event handler func will be invoked.

    Does this make sense?

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
    In Easy String Encryption Using CryptoAPI in C++ ( I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now