Solved

Getting Control ID in Message Handler

Posted on 2008-06-25
5
332 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
  • 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

832 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