This is the code I'm trying to get to work right now:
#pragma once
#include "stdafx.h"
#include "resource.h"
class MusicPlayerDialog : public CDialogImpl<MusicPlayerDialog>, public CWinDataExchange<MusicPlayerDialog>
{
public:
MusicPlayerDialog();
~MusicPlayerDialog();
enum { IDD = IDD_MAINDIALOG };
BEGIN_MSG_MAP_EX(MusicPlayerDialog)
MESSAGE_HANDLER(WM_CLOSE, OnClose)
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
MESSAGE_HANDLER(WM_INITDIALOG, OnInit)
COMMAND_ID_HANDLER_EX(IDC_CLOSE, OnExitButtonClick)
END_MSG_MAP()
BEGIN_DDX_MAP(MusicPlayerDialog)
DDX_CONTROL(IDC_TRACKSLIDER, m_trackSlider)
END_DDX_MAP()
LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnInit(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
private:
CTrackBarCtrl m_trackSlider;
void OnExitButtonClick(UINT uCode, int nCtrlID, HWND hwndCtrl);
};
As you can see, it's mostly basic initializing, with a Message map etc. However, I now want to hook up my CTrackBarCtrl with a DDX_MAP.
The important part is this:
BEGIN_DDX_MAP(MusicPlayerDialog)
DDX_CONTROL(IDC_TRACKSLIDER, m_trackSlider)
END_DDX_MAP()
What should happen here is that m_trackSlider is hooked up to the control with the Id of IDC_TRACKSLIDER, so I can control it by manipulating the variable.
However, right now I am facing this error:
error C2039: 'SubclassWindow': Is No Element Of 'WTL::CTrackBarCtrlT<ATL::CWindow>'
Due to WTLs missing documentation I can't really find out what the problem would be. I read up on subclassing, but in the end I don't quite see another way to do it than the way I am trying to. I also don't think CTrackBarCtrl is wrong, as it seems to be the WTL wrapper for sliders.
Any advice?
Try using "DDX_CONTROL_HANDLE" instead. Seems like this macro does not need the "SubclassWindow" method.
See this thread's last answer and the explanation from a codeproject article:
WTL for MFC Programmers, Part IV - Dialogs and Controls