Solved

Getting Control ID in Message Handler

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
In this article you will learn how to create a free basic website on Bitbucket, a git service provider. Polymer creates dynamic HTML components, which allow more flexibility than static HTML. This tutorial uses Ubuntu Linux but can also be done on W…
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…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

713 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