Solved

Getting Control ID in Message Handler

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

856 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