Click here to Skip to main content
15,923,789 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
zeus_master9-May-06 23:17
zeus_master9-May-06 23:17 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen9-May-06 23:44
Cedric Moonen9-May-06 23:44 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
zeus_master10-May-06 20:38
zeus_master10-May-06 20:38 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen10-May-06 20:42
Cedric Moonen10-May-06 20:42 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen10-May-06 20:48
Cedric Moonen10-May-06 20:48 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
zeus_master10-May-06 21:15
zeus_master10-May-06 21:15 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen10-May-06 21:24
Cedric Moonen10-May-06 21:24 
GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
zeus_master10-May-06 21:38
zeus_master10-May-06 21:38 
I didn't do anything.

I just creat a new dialog based project named stl.

and according your mean,add the code in the place your said:

stldlg.h
<code>// stlDlg.h : header file
//

#if !defined(AFX_STLDLG_H__0E3FD69C_3BD2_48E1_B6A9_3C850CD124FA__INCLUDED_)
#define AFX_STLDLG_H__0E3FD69C_3BD2_48E1_B6A9_3C850CD124FA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#include <vector>
/////////////////////////////////////////////////////////////////////////////
// CStlDlg dialog

class CStlDlg : public CDialog
{
// Construction
public:
CStlDlg(CWnd* pParent = NULL); // standard constructor

// Dialog Data
//{{AFX_DATA(CStlDlg)
enum { IDD = IDD_STL_DIALOG };
// NOTE: the ClassWizard will add data members here
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CStlDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
private:
std::vector<CButton> m_MyButtons;
// Implementation
protected:
HICON m_hIcon;

// Generated message map functions
//{{AFX_MSG(CStlDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STLDLG_H__0E3FD69C_3BD2_48E1_B6A9_3C850CD124FA__INCLUDED_)
</code>


then add the initialization in BOOL CStlDlg::OnInitDialog()

<code>
// TODO: Add extra initialization here

CString str="stlbtn";

for (int i=0;i<10;i++)
{
CButton NewButton;
NewButton.Create(str,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,CRect(10,20+30*i,80,40+30*i),this,104+i);
m_MyButtons.push_back(NewButton);
}
</code>


GeneralRe: create a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen10-May-06 21:51
Cedric Moonen10-May-06 21:51 
AnswerRe: creat a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
Cedric Moonen9-May-06 21:17
Cedric Moonen9-May-06 21:17 
GeneralRe: creat a batch of button in code, and the BN_CLICKED messages map to one function onButtonClick()? Pin
zeus_master9-May-06 23:36
zeus_master9-May-06 23:36 
Questionhelp Pin
subikchya9-May-06 21:09
subikchya9-May-06 21:09 
AnswerRe: help Pin
VinayCool9-May-06 21:28
VinayCool9-May-06 21:28 
AnswerRe: help Pin
Hamid_RT9-May-06 21:37
Hamid_RT9-May-06 21:37 
GeneralRe: help Pin
subikchya19-May-06 6:43
subikchya19-May-06 6:43 
GeneralRe: help Pin
Hamid_RT19-May-06 19:04
Hamid_RT19-May-06 19:04 
AnswerRe: help Pin
_AnsHUMAN_ 9-May-06 21:57
_AnsHUMAN_ 9-May-06 21:57 
AnswerRe: help Pin
LittleYellowBird9-May-06 22:00
LittleYellowBird9-May-06 22:00 
GeneralRe: help Pin
subikchya19-May-06 6:47
subikchya19-May-06 6:47 
AnswerRe: help Pin
Aqueel9-May-06 22:34
Aqueel9-May-06 22:34 
AnswerRe: help Pin
Maxwell Chen9-May-06 22:51
Maxwell Chen9-May-06 22:51 
GeneralRe: help Pin
Hamid_RT9-May-06 23:54
Hamid_RT9-May-06 23:54 
GeneralRe: help Pin
Maxwell Chen10-May-06 0:13
Maxwell Chen10-May-06 0:13 
QuestionSymbol Already defined... Pin
Polite Programmer9-May-06 20:50
Polite Programmer9-May-06 20:50 
AnswerRe: Symbol Already defined... Pin
Nibu babu thomas9-May-06 20:56
Nibu babu thomas9-May-06 20:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.