Some progress and set back.
For some reason I get 2 out of 3 MFD to work.
All 3 mfd display the key data for mfd1. If I turn it off all the button display is gone.
Still can't turn on/off, change the displays
It nevers hit the vcmouseevent.
void SPS::clbkMFDMode(int mfd, int mode)
{
oapiVCTriggerRedrawArea(-1, ALL_MFD_BUTTONS);
}
//-------------------------------------------------------------------------
bool SPS::clbkLoadVC(int id)
{
SetCameraOffset(_V(0, .595, 0));
SetCameraDefaultDirection(_V(0, -0.1908, 0.9816));
DefineMFDButtons();
oapiVCRegisterMFD(MFD_LEFT, &cdr1_mfd);
oapiVCRegisterMFD(MFD_RIGHT, &plt1_mfd);
oapiVCRegisterMFD(MFD_USER1, &cntr1_mfd);
check_mfds = true;
return true;
}
//-------------------------------------------------------------------------
bool SPS::clbkVCMouseEvent(int id, int event, VECTOR3& p)
{
sprintf(oapiDebugString(), "Mouse position: X %f Y %f Z %f bt%d", p.x, p.y, p.z, id);
if (id == CDR1_PWR) {
if (fail_mfd[0] == 0) {
oapiSendMFDKey(MFD_LEFT, OAPI_KEY_ESCAPE);
}
return true;
}
bool SPS::clbkVCRedrawEvent(int id, int event, SURFHANDLE surf)
{
bool return_value = false;
if (id == ALL_MFD_BUTTONS) {
PaintMFDButtons(surf);
return_value = true;
}
return return_value;
}
void SPS::PaintMFDButtons(SURFHANDLE surf)
{
HDC hDC = oapiGetDC(surf);
for (int mfd = 0; mfd < 3; mfd++) {
// D. Beachy: BUGFIX: if MFD powered off, do not paint buttons
if (oapiGetMFDMode(mfd) == MFD_NONE) {
}
else
{ // MFD powered on
sprintf(oapiDebugString(), "MFD MODE %d MFD %d ", oapiGetMFDMode(mfd), mfd);
HFONT pFont = (HFONT)SelectObject(hDC, g_Param.font[0]);
SetTextColor(hDC, RGB(255, 255, 255));
SetTextAlign(hDC, TA_CENTER);
SetBkMode(hDC, TRANSPARENT);
const char* label;
int y = 16;
for (int bt = 0; bt < 6; bt++) {
if (label = oapiMFDButtonLabel(mfd, bt)) {
TextOut(hDC, mfd_buttons_ypos[mfd], y, label, strlen(label));
y += 64;
}
else break;
}
int y2 = 16;
for (int bt = 6; bt < 12; bt++) {
if (label = oapiMFDButtonLabel(mfd, bt)) {
TextOut(hDC, mfd_buttons_ypos[mfd] + 128, y2, label, strlen(label));
y2 += 64;
}
else break;
}
//TextOut (hDC, 234, 1, "PG", 2);
SelectObject(hDC, pFont);
}
}
oapiReleaseDC(surf, hDC);
}