Solved

Getting Control ID in Message Handler

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

708 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

20 Experts available now in Live!

Get 1:1 Help Now