Solved

Getting Control ID in Message Handler

Posted on 2008-06-25
5
335 Views
Last Modified: 2013-11-18
I'm writing a plugin for windows media player in visual c++. I'm trying to work within the framework created by the wizard. I have a PropertyDialog that I wanted to add spin controls to but I'm having a difficult time trying to figure out how to work with the message and change the associated edit box controls.

So I have been able to catch messages from the spin control via the following message map:

MESSAGE_HANDLER( WM_VSCROLL, OnVScroll )


However, I have multiple spin controls and need to take different actions depending on which control the event is coming from.  So far I have the following function for the handler.

LRESULT CPropertyDialog::OnVScroll(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& fHandled)
      {
      
            int nScrollCode = (int)LOWORD(wParam);
            int nPos = (short int)HIWORD(wParam);
            SCROLLINFO si = {sizeof(SCROLLINFO),
                                    SIF_PAGE|SIF_POS|SIF_RANGE|SIF_TRACKPOS, 0, 0, 0, 0,
                                    0};

            if (nScrollCode == SB_ENDSCROLL) {
                  return 0; // Reject spurious messages
            }

}

I would like to add something like this to get the control id:

if (lParam->GetDlogCtrlID() == IDC_SPIN1)

suggestions?


Thanks,

Jason
0
Comment
Question by:cristo1701
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 17

Accepted Solution

by:
rstaveley earned 125 total points
ID: 21873420
This should do it:

GetDlgCtrlID((HWND)lParam)
0
 

Author Comment

by:cristo1701
ID: 21875054
Thanks rstaveley,

I tired this out earlier but on compilation a get the following error:
error C2660: 'ATL::CWindow::GetDlgCtrlID' : function does not take 1 arguments

It seems that this vc project setup by the Windows Media Player plugin wizard dosn't have access to many normal functions included in a standard MFC project. I think the project is setup toward producing a dll and working with COM interfaces. Do you know of a work around to or an alternative method that might be possible in my kind of vc project.

Thanks,

Jason
 
0
 

Author Comment

by:cristo1701
ID: 21875083
I spoke too soon,

It appears that i just needed to let the compiler know a little more about the symbol

The following works,

::GetDlgCtrlID((HWND)lParam)

Thanks,

Jason
0
 
LVL 17

Expert Comment

by:rstaveley
ID: 21875425
If you were wondering, the leading '::' gets it to use the global namespace, which is what you need in this case. Thanks for the points!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 21880008
Just to add a thought:
The normal way to do this is to have the ClassWizard create a control-type variable for the Spin control.  And when you look at the "Object IDs" list, you will see that control.  When you click on it, you can see notification messages that it sends.  Click on UDN_DELETAPOS and select "Add Function" and you will end up with a nice tidy little function that gets called whenever the user cspins the control.
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQUD PROXY SERVER, UNIX, SLL/HTTPS 5 135
unix example issues 18 113
need help ...get stuck at middle of coding ...need to submit by Sunday C++ 1 52
Need some help with mailto 16 42
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

734 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