MinnisotaFreezing
Programmer
Hey all, I'm sure most peoples minds are still half focused on the east cost, so hopefully it will only take half your attention to solve my problem.
In a dialog box I have 10 buttons IDC_SHIP_DETAIL1 to IDC_SHIP_DETAIL10. I then have 10 Message Maps
ON_BN_CLICKED(IDC_SHIP_DETAIL1, OnShipDetail1)
..
ON_BN_CLICKED(IDC_SHIP_DETAIL10, OnShipDetail10)
so far so good. Now I have 10 functions:
void OnShipDetail1()
{
LoadInfo(1);
}
void OnShipDetail2()
{
LoadInfo(2);
}
..
void OnShipDetail10()
{
LoadInfo(10);
}
I feel those 10 functions are redundant. I would like 1 function
void OnShipDetail(int i)
{
LoadInfo(i);
}
Where the i is the index of the button that called it. I could then even call LoadInfo directly.
I tried changing my message map to
ON_BN_CLICKED(IDC_SHIP_DETAIL1, OnShipDetail(1))
and the appropriate OnShipDetail prototypes and functions. but I got an "illegal call of non-static member function" error on the ON_BN_CLICKED line.
Does anyone know how I can pass info to a message map function, or know of any other way I can identifiy which button was pushed other than having 10 seperate functions?
Any help would, of course, be greatly appriciated.
CJB
In a dialog box I have 10 buttons IDC_SHIP_DETAIL1 to IDC_SHIP_DETAIL10. I then have 10 Message Maps
ON_BN_CLICKED(IDC_SHIP_DETAIL1, OnShipDetail1)
..
ON_BN_CLICKED(IDC_SHIP_DETAIL10, OnShipDetail10)
so far so good. Now I have 10 functions:
void OnShipDetail1()
{
LoadInfo(1);
}
void OnShipDetail2()
{
LoadInfo(2);
}
..
void OnShipDetail10()
{
LoadInfo(10);
}
I feel those 10 functions are redundant. I would like 1 function
void OnShipDetail(int i)
{
LoadInfo(i);
}
Where the i is the index of the button that called it. I could then even call LoadInfo directly.
I tried changing my message map to
ON_BN_CLICKED(IDC_SHIP_DETAIL1, OnShipDetail(1))
and the appropriate OnShipDetail prototypes and functions. but I got an "illegal call of non-static member function" error on the ON_BN_CLICKED line.
Does anyone know how I can pass info to a message map function, or know of any other way I can identifiy which button was pushed other than having 10 seperate functions?
Any help would, of course, be greatly appriciated.
CJB