Newbie code question (and maybe I need a 1hr tutorial for some $)

S

Stone

Hello,

I am a competent vb6 programmer and understand a bit of C structures.
However the C++ system is mystifying me..I simply will have to learn it
to now.... I have 2 questions.

1> Can anyone tell me how code "Program 4. Microphone Select"
at http://www.codeproject.com/audio/ADMixer.asp can be changed to simply
self close by clicking the IDOK button routine programmatically? This is the
simple effort that triggered my current angst.! (I 'think' need to set a
state
in BOOL CSelectDlg::OnInitDialog" to fake the IDOK event or trigger to
the OnDestroy routine). Frankly I know this is simple, but I am guessing!

2> Can someone spare 30 minutes or a hour to walk me through this example to
explain this in more detail. I have VC6++ and would be happy to pay for the
consulting. Let me know and I'll get you an email to contact me directly

Thanks... -stone



SNIPPET FROM LINK MENTIONED ABOVE

////////////////////////////////////////////////////////////////////////////
/
// CSelectDlg dialog

CSelectDlg::CSelectDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSelectDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSelectDlg)
m_bSelect = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

m_hMixer = NULL;
}

void CSelectDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectDlg)
DDX_Check(pDX, IDC_CHECK, m_bSelect);
DDX_Text(pDX, IDC_EDIT1, m_strStat1);
DDX_Text(pDX, IDC_EDIT2, m_strStat2);
DDX_Text(pDX, IDC_EDIT3, m_strStat3);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSelectDlg, CDialog)
//{{AFX_MSG_MAP(CSelectDlg)
ON_WM_DESTROY()
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_CHECK, OnSelect)
ON_MESSAGE(MM_MIXM_CONTROL_CHANGE, OnMixerCtrlChange)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

////////////////////////////////////////////////////////////////////////////
/
// CSelectDlg message handlers

BOOL CSelectDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

if (this->amdInitialize())
{
// display the number of mixer devices present in the system
m_strStat1.Format(IDS_FMTNUMMIXERS, m_nNumMixers);

// display the information about the first mixer
m_strStat2.Format(IDS_FMTCAPS,
m_mxcaps.szPname, m_mxcaps.cDestinations);

// get the Control ID, index and the names
if (this->amdGetMicSelectControl())
{
// display the line and control name
m_strStat3.Format(IDS_FMTNAMES,
m_strDstLineName, m_strSelectControlName);

// display the Microphone Select item name
this->SetDlgItemText(IDC_CHECK, m_strMicName);

// get the initial value of the Microphone Select control
LONG lVal = 0;
if (this->amdGetMicSelectValue(lVal))
{
// lVal may be zero or nonzero.
// m_bSelect needs to be 0 or 1 in order for DDX_Check to work.
m_bSelect = (lVal != 0);
}
else
{
ASSERT(FALSE);
}
}
else
{
VERIFY(m_strStat3.LoadString(IDS_NOCONTROL));

// disable the checkbox
CWnd *const pWndCheck = this->GetDlgItem(IDC_CHECK);
if (pWndCheck != NULL)
{
pWndCheck->EnableWindow(FALSE);
}
else
{
ASSERT(FALSE);
}
}

VERIFY(this->UpdateData(FALSE));
}
else
{
ASSERT(FALSE);
}

return TRUE; // return TRUE unless you set the focus to a control
}

void CSelectDlg::OnDestroy()
{
VERIFY(this->amdUninitialize());

CDialog::OnDestroy();
}

void CSelectDlg::OnSysCommand(UINT nID, LPARAM lParam)
{

CDialog::OnSysCommand(nID, lParam);

}
 
P

Peter van Merkerk

I am a competent vb6 programmer and understand a bit of C structures.
However the C++ system is mystifying me..I simply will have to learn it
to now.... I have 2 questions.

1> Can anyone tell me how code "Program 4. Microphone Select"
at http://www.codeproject.com/audio/ADMixer.asp can be changed to simply
self close by clicking the IDOK button routine programmatically? This is the
simple effort that triggered my current angst.! (I 'think' need to set a
state
in BOOL CSelectDlg::OnInitDialog" to fake the IDOK event or trigger to
the OnDestroy routine). Frankly I know this is simple, but I am
guessing!

That question has nothing to do with C++, and everything with Windows
and MFC. You are more likely to get a good peer reviewed anwser if you
post this question to a Windows or MFC newsgroup such as
or
To learn what is topical here or not and
which newsgroup is the best place to ask a particular question, read
this http://home.wanadoo.nl/efx/c++-faq/ and this
http://www.slack.net/~shiva/welcome.txt
2> Can someone spare 30 minutes or a hour to walk me through this example to
explain this in more detail. I have VC6++ and would be happy to pay for the
consulting. Let me know and I'll get you an email to contact me
directly

You are probably better of with a couple of good books, at least one
about the C++ language itself (without OS specific stuff) and one about
Windows/MFC programming. This is cheaper and more effective than
consulting; C++ is not the kind of language you can learn in a day or
even a month. Book reviews can be found here:
http://www.accu.org/bookreviews/public/index.htm.

Good luck with your study!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top