BOOL CALLBACK DlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: ((MFDWindow*)lParam)->Initialise (hDlg); return TRUE; case WM_SIZE: ((MFDWindow*)oapiGetDialogContext(hDlg))->Resize (true); return TRUE; case WM_COMMAND: switch (LOWORD (wParam)) { case IDCANCEL: oapiUnregisterExternMFD ((MFDWindow*)oapiGetDialogContext (hDlg)); return TRUE; case IDHELP: ((MFDWindow*)oapiGetDialogContext(hDlg))->OpenModeHelp (); return TRUE; case IDSTICK: ((MFDWindow*)oapiGetDialogContext(hDlg))->StickToVessel (HIWORD(wParam) != 0); return TRUE; } break; } return oapiDefDialogProc (hDlg, uMsg, wParam, lParam); }
static BOOL CALLBACK DlgProcHook (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_INITDIALOG) { SetWindowLong (hWnd, GWL_USERDATA, (LONG)lParam); // store class pointer with window ((TabbedDialog*)lParam)->hDlg = hWnd; // store window handle here so it's available in OnInitDialog } TabbedDialog *dlg = (TabbedDialog*)GetWindowLong (hWnd, GWL_USERDATA); if (dlg) return dlg->DlgProc (hWnd, uMsg, wParam, lParam); else return oapiDefDialogProc (hWnd, uMsg, wParam, lParam); }
BOOL TabbedDialog::DlgProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: return OnInitDialog (wParam); case WM_NOTIFY: { LPNMHDR pnmh = (LPNMHDR)lParam; if (pnmh->idFrom == tabId) { if (pnmh->code == TCN_SELCHANGE) SwitchTab (); return TRUE; } } return -1; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: return OnClose (); } break; } return oapiDefDialogProc (hWnd, uMsg, wParam, lParam); }
BOOL CALLBACK MsgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { VOBJ * v = g_UFA.GetFocus(); if (v==NULL) return FALSE; switch (uMsg) { case WM_INITDIALOG: { SendDlgItemMessage(hDlg,IDC_COMBO_AGE,CB_RESETCONTENT, 0, 0); SendDlgItemMessage(hDlg,IDC_COMBO_WEIGHT,CB_RESETCONTENT, 0, 0); char cbuf[255]; for (int i = 0; i < 300; i++) { sprintf(cbuf,"%d",i+1); SendDlgItemMessage(hDlg, IDC_COMBO_AGE, CB_ADDSTRING, 0, (LPARAM)cbuf); SendDlgItemMessage(hDlg, IDC_COMBO_WEIGHT, CB_ADDSTRING, 0, (LPARAM)cbuf); } for (int i = 0; i < NUMBER_OF_MMU_TYPE; i++) { strcpy(cbuf,UmmuMiscID[i]); SendDlgItemMessage(hDlg, IDC_COMBO_ID, CB_ADDSTRING, 0, (LPARAM)cbuf); } return TRUE; } case WM_DESTROY: { return TRUE; } case WM_COMMAND: { switch (LOWORD (wParam)) { case IDCANCEL: { oapiCloseDialog(hDlg); return TRUE; } case IDC_BUTTON_ADD: { // hack, but that's the only way v->crew.SetMaxSeatAvailableInShip(v->crew.GetCrewTotalNumber()+1); char name[255]; char cbuf[255]; int len = GetDlgItemText(hDlg, IDC_EDIT_NAME, name,255); if (len < 1) return FALSE; len = GetDlgItemText(hDlg, IDC_COMBO_AGE, cbuf, 255); if (len < 1) return FALSE; int age = atoi(cbuf); len = GetDlgItemText(hDlg, IDC_COMBO_WEIGHT, cbuf, 255); if (len < 1) return FALSE; int weight = atoi(cbuf); len = GetDlgItemText(hDlg, IDC_COMBO_ID, cbuf, 255); if (len > 4) return FALSE; v->crew.AddCrewMember(name, age, 70, weight, cbuf); char mess[255]; sprintf(mess,"%s %s aged %d added",cbuf,name, age); v->hudprint.insert(mess); return TRUE; } case IDC_BUTTON_SAVE: { char scn[255]; char cfg[255]; char cbuf[255]; int len = GetDlgItemText(hDlg, IDC_EDIT_FILENAME, cbuf, 255); if (len < 1) return FALSE; sprintf(scn,"%s",cbuf); sprintf(cfg,"Scenarios/UMMUFA/%s.cfg",RidSpaces(cbuf)); g_UFA.SpecialSave=TRUE; sprintf(g_UFA.SpecialSaveBuffer,"%s",cfg); sprintf(cbuf,"UMMUFA Save at %.2f seconds from %s",oapiGetSimTime(),VESSEL(v->hook).GetName()); oapiSaveScenario(scn, cbuf); sprintf(cbuf,"%s scenario saved",scn); v->hudprint.insert(cbuf); return TRUE; } } return TRUE; } } return oapiDefDialogProc (hDlg, uMsg, wParam, lParam); }
int MGAFinder::MsgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: InitDialog(hDlg); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDCANCEL: CloseDialog(); return TRUE; case IDC_RESET_SOL: g_optimizer->plan()->ResetSolutions(); break; case ID_OPT: { UIToParam(); if (g_optimizer->computing()) { g_optimizer->Cancel(); SetDlgItemText(hDlg, ID_OPT, "Find Optimum"); } else { g_optimizer->RunOptimization(hDlg); SetDlgItemText(hDlg, ID_OPT, "Cancel"); } break; } case ID_PARETO: { UIToParam(); if (!g_optimizer->computing()) { g_optimizer->RunPareto(hDlg); } break; } case IDC_PLUS: { int idx = SendDlgItemMessage(hDlg, IDC_LST_PLANETS, LB_GETCURSEL, 0, 0); int cnt = SendDlgItemMessage(hDlg, IDC_LST_PLANETS, LB_GETCOUNT, 0, 0); if (idx >= 0 && idx < cnt - 1) { PlanetList_ExchangeItemsAtIndex(idx, idx + 1); } } break; case IDC_MINUS: { int idx = SendDlgItemMessage(hDlg, IDC_LST_PLANETS, LB_GETCURSEL, 0, 0); int cnt = SendDlgItemMessage(hDlg, IDC_LST_PLANETS, LB_GETCOUNT, 0, 0); if (idx >= 1) { PlanetList_ExchangeItemsAtIndex(idx, idx - 1); } } break; case IDC_PLANET_ADD: { char str[200]; int sel = SendDlgItemMessage(hDlg, IDC_PLANET_SELECT, CB_GETCURSEL, 0, 0); if (sel != CB_ERR) { SendDlgItemMessage(hDlg, IDC_PLANET_SELECT, CB_GETLBTEXT, sel, (LPARAM)str); PlanetList_AddItem(str); } } break; case IDC_PLANET_DEL: { int sel = SendDlgItemMessage(hDlg, IDC_LST_PLANETS, LB_GETCURSEL, 0, 0); if (sel != LB_ERR) { PlanetList_RemoveItemAtIndex(sel); } } break; case IDC_SAVE_PLAN: { UIToParam(); char buf[1000] = "test"; GetDlgItemText(hDlg, IDC_PLANS, buf, 999); g_optimizer->disk_store().SavePlan(buf, g_optimizer->plan()); char msg[200]; sprintf_s(msg, "The plan '%s' was saved to disk", buf); int msgBoxID = MessageBox(hDlg, msg, "Plan saved", MB_OK); } break; case IDC_LOAD_PLAN: { char buf[1000] = "test"; GetDlgItemText(hDlg, IDC_PLANS, buf, 999); auto plan = g_optimizer->disk_store().LoadPlan(buf); g_optimizer->update_parameters(plan, false); char msg[200]; sprintf_s(msg, "The plan '%s' was loaded from disk", buf); int msgBoxID = MessageBox(hDlg, msg, "Plan loaded", MB_OK); if (plan) { ParamToUI(*plan); } } break; case IDHELP: return TRUE; } break; case WM_LBUTTONUP: break; case WM_LBUTTONDOWN: break; case WM_OPTIMIZATION_READY: auto plan = g_optimizer->plan(); if (plan) { SolutionToUI(*plan); ParamToUI(*plan); g_optimizer->disk_store().SavePlan(plan); } break; } return oapiDefDialogProc(hDlg, uMsg, wParam, lParam); }