//=========================================================================== // Process notification messages. // Parameters -------------------------------------------------------------- // HWND hwnd : window handle // ULONG id : control ID // ULONG ulNotify : notify code // HWND hCtrl : control handle // Return value ------------------------------------------------------------ // VOID //=========================================================================== static VOID onCtrlNotify(HWND hwnd, ULONG id, ULONG ulNotify, HWND hCtrl) { SHORT iitem; CHAR buf[360]; switch (id) { case LBOX_CLASS: if (ulNotify == LN_SELECT) { iitem = WinQueryLboxSelectedItem(hCtrl); ulNotify = (iitem >= 0) && !bEditMode; WinEnableControl(hwnd, BTN_EDIT, ulNotify); WinEnableControl(hwnd, BTN_DEREG, ulNotify); WinEnableControl(hwnd, BTN_REMOVE, ulNotify); } else if (ulNotify == LN_ENTER) { WinPostMsg(hwnd, WM_COMMAND, (MPARAM)BTN_EDIT, MPVOID); // onCommand(hwnd, BTN_EDIT); } /* endif */ break; case EF_CLASSNAME: case EF_MODULENAME: if (ulNotify == EN_CHANGE) { ulNotify = DlgItemTextLength(hwnd, EF_CLASSNAME) && DlgItemTextLength(hwnd, EF_MODULENAME) && !bEditMode; DlgItemEnable(hwnd, BTN_ADD, ulNotify); } /* endif */ break; } /* endswitch */ }
static void NewFilter(HWND hwnd) { const HWND ebox = WinWindowFromID(hwnd, DID_FFILTER_CB); const HWND name = WinWindowFromID(hwnd, DID_FILENAME_ED); // // Get new selection // const int item = WinQueryLboxSelectedItem(ebox); const int len = WinQueryLboxItemTextLength(ebox, item) + 1; // // set corresponding text in entry field // char *txt = malloc(len); WinQueryLboxItemText(ebox, item, txt, len); WinSetWindowText(name, strrchr(txt, '>') + 2); lib_free(txt); // // set focus to entry field and simulate an Apply // WinSetFocus(HWND_DESKTOP, name); WinDefFileDlgProc(hwnd, WM_COMMAND, (MPARAM)DID_OK, MPFROM2SHORT(CMDSRC_PUSHBUTTON, TRUE)); }
static MRESULT EXPENTRY pm_emulator(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { // FIXME: Speed=0 'No Limit' is missing static int first = TRUE; const char psz[11][6] = { " Auto", " 1/1", " 1/2", " 1/3", " 1/4", " 1/5", " 1/6", " 1/7", " 1/8", " 1/9", " 1/10" }; switch (msg) { case WM_INITDLG: { int val=0; for (val = 0; val < 11; val++) { WinDlgLboxInsertItem(hwnd, CBS_REFRATE, psz[val]); } resources_get_int("Speed", &val); WinSetDlgSpinVal(hwnd, SPB_SPEED, val); WinEnableControl(hwnd, PB_SPEED100, (val!=100)); resources_get_int("RefreshRate", &val); WinDlgLboxSelectItem(hwnd, CBS_REFRATE, val); } break; case WM_COMMAND: switch (LONGFROMMP(mp1)) { case PB_SPEED100: WinSetDlgSpinVal(hwnd, SPB_SPEED, 100); vsync_suspend_speed_eval(); resources_set_int("Speed", 100); WinEnableControl(hwnd, PB_SPEED100, FALSE); return FALSE; } break; case WM_DISPLAY: { char txt1[8] = "---%"; char txt2[8] = "--fps"; if ((int)mp1 < 100000) { sprintf(txt1, "%5d%%", mp1); } if ((int)mp2 < 10000) { sprintf(txt2, "%4dfps", mp2); } WinSetDlgItemText(hwnd, ID_SPEEDDISP, txt1); WinSetDlgItemText(hwnd, ID_REFRATEDISP, txt2); } return FALSE; case WM_CONTROL: { const int ctrl = SHORT1FROMMP(mp1); switch (ctrl) { case SPB_SPEED: if (SHORT2FROMMP(mp1) == SPBN_ENDSPIN) { const ULONG val = WinGetSpinVal((HWND)mp2); vsync_suspend_speed_eval(); resources_set_int("Speed", val); WinEnableControl(hwnd, PB_SPEED100, (val != 100)); } break; case CBS_REFRATE: if (SHORT2FROMMP(mp1) == LN_SELECT) { const int val = WinQueryLboxSelectedItem((HWND)mp2); resources_set_int("RefreshRate", val); } break; } break; } break; } return WinDefDlgProc (hwnd, msg, mp1, mp2); }
static MRESULT EXPENTRY pm_drive(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { static int drive = 0; switch (msg) { case WM_INITDLG: { int val, i = 0; HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE); while (i < 10 && ui_status.imageHist[i][0]) { WinLboxInsertItem(ihwnd, ui_status.imageHist[i++]); } WinLboxInsertItem(ihwnd, ""); resources_get_int("DriveTrueEmulation", &val); WinCheckButton(hwnd, CB_TRUEDRIVE, val); WinCheckButton(hwnd, RB_DRIVE8|drive, 1); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); WinSendMsg(hwnd, WM_DRIVESTATE, (void*)ui_status.lastDriveState, NULL); for (i = 0; i < 3; i++) { WinSendMsg(hwnd, WM_TRACK, (void*)i, (void*)(int)(ui_status.lastTrack[i] * 2)); } } break; case WM_COMMAND: switch (LONGFROMMP(mp1)) { case PB_CREATE: create_dialog(hwnd); return FALSE; case PB_ATTACH: ViceFileDialog(hwnd, 0x0100 | (drive + 1), FDS_OPEN_DIALOG); return FALSE; case PB_DETACH: file_system_detach_disk(drive + 8); return FALSE; case PB_FLIPADD: fliplist_add_image(drive + 8); return FALSE; case PB_FLIPREMOVE: fliplist_remove(drive + 8, NULL); return FALSE; case PB_FLIP: fliplist_attach_head(drive + 8, FLIP_NEXT); return FALSE; } break; case WM_CONTROL: { switch (SHORT1FROMMP(mp1)) { case RB_DRIVE8: case RB_DRIVE9: case RB_DRIVE10: case RB_DRIVE11: WinSendMsg(hwnd, WM_SWITCH, (void*)(SHORT1FROMMP(mp1) & 0x3), 0); break; case CB_TRUEDRIVE: toggle("DriveTrueEmulation"); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_CONVERTP00: toggle_drive_res("FSDevice%dConvertP00", drive);//); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_SAVEP00: toggle_drive_res("FileDevice%dSaveP00", drive); break; case CB_ALLOWACCESS: toggle_drive_res("FileSystemDevice%d", drive); WinSendMsg(hwnd, WM_SWITCH, (void*)drive, 0); break; case CB_HIDENONP00: toggle_drive_res("FSDevice%dHideCBMFiles", drive); break; case CB_MEM2000: toggle_drive_res("Drive%dRAM2000", drive); break; case CB_MEM4000: toggle_drive_res("Drive%dRAM4000", drive); break; case CB_MEM6000: toggle_drive_res("Drive%dRAM6000", drive); break; case CB_MEM8000: toggle_drive_res("Drive%dRAM8000", drive); break; case CB_MEMA000: toggle_drive_res("Drive%dRAMA000", drive); break; case CB_READONLY: toggle_drive_res("AttachDevice%dReadonly", drive); break; case CB_PARALLEL: if (drive == 0 || drive == 1) { toggle_drive_res("Drive%dParallelCable", drive); } break; case RB_NEVER: case RB_ASK: case RB_ALWAYS: if (drive == 0 || drive == 1) { resources_set_int_sprintf("Drive%dExtendImagePolicy", (SHORT1FROMMP(mp1) & 0x3), drive + 8); } break; case RB_NONE: case RB_TRAP: case RB_SKIP: if (drive == 0 || drive == 1) { resources_set_int_sprintf("Drive%dIdleMethod", (SHORT1FROMMP(mp1) & 0x3), drive + 8); } break; case CBS_IMAGE: if (SHORT2FROMMP(mp1) == CBN_ENTER) { char psz[CCHMAXPATH]; WinLboxQuerySelectedItemText(hwnd, CBS_IMAGE, psz, CCHMAXPATH); if (!strlen(psz)) { file_system_detach_disk(drive + 8); return FALSE; } if (file_system_attach_disk(drive + 8, psz)) { WinMessageBox(HWND_DESKTOP, hwnd, "Cannot attach specified file.", "VICE/2 Error", 0, MB_OK); } } return FALSE; case CBS_PATH: switch (SHORT2FROMMP(mp1)) { case SPBN_CHANGE: { char path[255]; WinSendDlgMsg(hwnd, CBS_PATH, SPBM_QUERYVALUE, &path, 255); if (!chdir(path)) { resources_set_string_sprintf("FSDevice%dDir", path, drive + 8); } } break; case SPBN_KILLFOCUS: { const char *path; resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8); WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1); WinSetDlgSpinVal(hwnd, CBS_PATH, 0); } break; } return FALSE; case CBS_TYPE: if (SHORT2FROMMP(mp1) == CBN_ENTER && (drive == 0 || drive == 1)) { const int nr = WinQueryLboxSelectedItem((HWND)mp2); const int val = WinLboxItemHandle((HWND)mp2, nr); resources_set_int_sprintf("Drive%dType", val, drive + 8); } return FALSE; } } break; case WM_DRIVEIMAGE: { HWND ihwnd = WinWindowFromID(hwnd, CBS_IMAGE); const char *name = (char *)mp1; int pos; for (pos = 0; pos < 9; pos++) { WinDeleteLboxItem(ihwnd, 0); } pos = 0; while (pos < 10 && ui_status.imageHist[pos][0]) { WinLboxInsertItem(ihwnd, ui_status.imageHist[pos++]); } WinLboxInsertItem(ihwnd, ""); if (drive == (int)mp2) { WinLboxSelectItem(ihwnd, name[0] ? 0 : pos); } } return FALSE; case WM_TRACK: if (!(ui_status.lastDriveState & (1 << (int)mp1))) { break; } WinSetDlgSpinVal(hwnd, SPB_TRACK8+(int)mp1, (int)((int)mp2 / 2)); WinShowDlg(hwnd, SS_HALFTRACK8 + (int)mp1, ((int)mp2 % 2)); break; case WM_DRIVELEDS: WinShowDlg(hwnd, SS_LED8+(int)mp1, (int)mp2); break; case WM_DRIVESTATE: WinShowDlg(hwnd, SPB_TRACK8, (int)mp1 & 1 == 1); WinShowDlg(hwnd, SS_HALFTRACK8, (int)mp1 & 1 == 1); WinShowDlg(hwnd, SPB_TRACK9, (int)mp1 & 2 == 1); WinShowDlg(hwnd, SS_HALFTRACK9, (int)mp1 & 2 == 1); WinShowDlg(hwnd, SS_LED8, 0); WinShowDlg(hwnd, SS_LED9, 0); break; case WM_SWITCH: drive = (int)mp1; { const HWND lbox = WinWindowFromID(hwnd, CBS_TYPE); int type = 0; int val; int res; int drive89 = (drive == 0 || drive == 1); resources_get_int("DriveTrueEmulation", &val); WinLboxEmpty(lbox); if (drive89) { int i, nr; WinCheckButton(hwnd, RB_NEVER | get_drive_res("Drive%dExtendImagePolicy", drive), 1); WinCheckButton(hwnd, RB_NONE | get_drive_res("Drive%dIdleMethod", drive), 1); nr = 0; res = get_drive_res("Drive%dType", drive); for (i = 0; i < nDRIVES; i++) { if (!drive_check_type(driveRes[i], drive)) { continue; } WinLboxInsertItem(lbox, driveName[i]); WinLboxSetItemHandle(lbox, nr, driveRes[i]); if (res == driveRes[i]) { type = nr; } nr++; } } else { WinCheckButton(hwnd, RB_NEVER, 0); WinCheckButton(hwnd, RB_ASK, 0); WinCheckButton(hwnd, RB_ALWAYS, 0); WinCheckButton(hwnd, RB_NONE, 0); WinCheckButton(hwnd, RB_SKIP, 0); WinCheckButton(hwnd, RB_TRAP, 0); } WinLboxSelectItem(lbox, type); WinCheckButton(hwnd, CB_PARALLEL, drive89 && get_drive_res("Drive%dParallelCable", drive) != 0); WinCheckButton(hwnd, CB_MEM2000, drive89 && get_drive_res("Drive%dRAM2000", drive) != 0); WinCheckButton(hwnd, CB_MEM4000, drive89 && get_drive_res("Drive%dRAM4000", drive) != 0); WinCheckButton(hwnd, CB_MEM6000, drive89 && get_drive_res("Drive%dRAM6000", drive) != 0); WinCheckButton(hwnd, CB_MEM8000, drive89 && get_drive_res("Drive%dRAM8000", drive) != 0); WinCheckButton(hwnd, CB_MEMA000, drive89 && get_drive_res("Drive%dRAMA000", drive) != 0); WinEnableControl(hwnd, CB_PARALLEL, drive89 && val); WinEnableControl(hwnd, RB_NEVER, drive89 && val); WinEnableControl(hwnd, RB_ASK, drive89 && val); WinEnableControl(hwnd, RB_ALWAYS, drive89 && val); WinEnableControl(hwnd, RB_NONE, drive89 && val); WinEnableControl(hwnd, RB_SKIP, drive89 && val); WinEnableControl(hwnd, RB_TRAP, drive89 && val); WinEnableControl(hwnd, CBS_TYPE, drive89 && val); WinEnableControl(hwnd, CB_MEM2000, drive89 && val); WinEnableControl(hwnd, CB_MEM4000, drive89 && val); WinEnableControl(hwnd, CB_MEM6000, drive89 && val); WinEnableControl(hwnd, CB_MEM8000, drive89 && val); WinEnableControl(hwnd, CB_MEMA000, drive89 && val); { int acc = get_drive_res("FileSystemDevice%d", drive) != 0; int conv = get_drive_res("FSDevice%dConvertP00", drive) != 0; if (!conv) { resources_set_int_sprintf("FSDevice%dHideCBMFiles", 0, drive + 8); } WinCheckButton(hwnd, CB_ALLOWACCESS, acc); WinCheckButton(hwnd, CB_CONVERTP00, conv); WinCheckButton(hwnd, CB_SAVEP00, get_drive_res("FSDevice%dSaveP00", drive) != 0); WinCheckButton(hwnd, CB_HIDENONP00, get_drive_res("FSDevice%dHideCBMFiles", drive) != 0); WinEnableControl(hwnd, CB_ALLOWACCESS, !(drive89 && val)); WinEnableControl(hwnd, CB_SAVEP00, !(drive89 && val) && acc); WinEnableControl(hwnd, CB_CONVERTP00, !(drive89 && val) && acc); WinEnableControl(hwnd, CBS_PATH, !(drive89 && val) && acc); WinEnableControl(hwnd, CB_HIDENONP00, !(drive89 && val) && acc && conv); WinCheckButton(hwnd, CB_READONLY, get_drive_res("AttachDevice%dReadonly", drive) != 0); } { char tmp[CCHMAXPATH]; int max = WinDlgLboxQueryCount(hwnd, CBS_IMAGE); int pos = -1; do { WinLboxQueryItem(hwnd, CBS_IMAGE, ++pos, tmp, CCHMAXPATH); } while (pos < max && strcmp(ui_status.lastImage[drive], tmp)); WinDlgLboxSelectItem(hwnd, CBS_IMAGE, pos); } { const char *path; resources_get_string_sprintf("FSDevice%dDir", &path, drive + 8); WinSendDlgMsg(hwnd, CBS_PATH, SPBM_SETARRAY, &path, 1); WinSetDlgSpinVal(hwnd, CBS_PATH, 0); } } return FALSE; } return WinDefDlgProc (hwnd, msg, mp1, mp2); }
MRESULT CreInstDlg::wmCommand(HM12){ USE_HM12; USHORT command; char typename[MAXNAMELENGTH]=""; char propname[MAXNAMELENGTH]=""; char newvalue[MAXNAMELENGTH]=""; int index,dbtype,oktype,i; ODB_INT intval; ODB_REAL realval; ODB_SET coll; object *obj,*o; command=SHORT1FROMMP( mp1 ) ; switch(command) { case DID_OK: //ok button pressed. Create object index=WinQueryLboxSelectedItem(hwndlbtypes); WinQueryLboxItemText(hwndlbtypes,index,typename,MAXNAMELENGTH); if (strlen(typename)<1) { //type not specified WinMessageBox(HWND_DESKTOP,hwndOwner,(PCH) "A type must be spec.", (PCH)"Alert",0,MB_NOICON|MB_OK); break; } else { obj=odb.create_instance(typename); if (obj==NULL) { //object could not be created, possibly because //extentless type selectd WinMessageBox(HWND_DESKTOP,hwndOwner,(PCH) "Could not create object", (PCH)"Alert",0,MB_NOICON|MB_OK); break; }; i=WinQueryLboxCount(hwndassignedprop); i--; while(i>=0){ //check that the data for each prop is ok //and set the properies for the object WinQueryLboxItemText(hwndassignedprop,i,propname,MAXNAMELENGTH); WinQueryLboxItemText(hwndassignedprop,i,propname,MAXNAMELENGTH); WinQueryLboxItemText(hwndpropval,i,newvalue,MAXNAMELENGTH); dbtype=odb.getpropertytype(typename,propname); if (dbtype==_INT_) { validate_integer(newvalue,intval); (*obj).setproperty_value(propname,intval); }; if (dbtype==_OTHER_) { validate_integer(newvalue,intval); o=odb.getobjectwithoid("Usertypes",intval); (*obj).setproperty_value(propname,o); }; if (dbtype==_REAL_) { validate_real(newvalue,realval); (*obj).setproperty_value(propname,realval); }; if (dbtype==_COLLECTION_){ coll=new collection(_OTHER_); if (validate_set(newvalue,&odb,coll)<0) (*coll).~collection(); (*obj).setproperty_value(propname,coll); }; if (dbtype==_INT_COLLECTION_){ coll=new collection(_INT_); if (validate_set(newvalue,&odb,coll)<0) (*coll).~collection(); (*obj).setproperty_value(propname,coll); }; if (dbtype==_REAL_COLLECTION_){ coll=new collection(_REAL_); if (validate_set(newvalue,&odb,coll)<0) (*coll).~collection(); (*obj).setproperty_value(propname,coll); }; if (dbtype==_CHAR_COLLECTION_){ coll=new collection(_CHAR_); if (validate_set(newvalue,&odb,coll)<0) (*coll).~collection(); (*obj).setproperty_value(propname,coll); }; if (dbtype==_CHAR_) (*obj).setproperty_value(propname,newvalue); i--; }; //end while all properties set. //deleta all unassigned praps (*this).clearlbox(hwndassignedprop); clearlbox(hwndpropval); clearlbox(hwndlbprops); WinSetWindowText(hwndviewval,(PSZ)""); populate_props(hwndlbprops,typename, odb); noassignedprops=0; //no assigned properties anymore WinMessageBox(HWND_DESKTOP,hwndOwner,(PCH) "Instance created.", (PCH)"Success",0,MB_NOICON|MB_OK); }; //else //create the object and set properties return (MRESULT) FALSE; //break; case DID_CANCEL: //quit this window if(WinMessageBox(HWND_DESKTOP,hwndOwner,(PCH) "Quit this window?", (PCH)"Sanity Check",0, MB_NOICON|MB_OKCANCEL)==MBID_OK) WinDismissDlg( hwnd, TRUE ); // Removes the dialog box return (MRESULT) FALSE; case PB_SET: //assign property a value. The prop is moved to assignedprops //and value is validated and moved to hidden listbox index=WinQueryLboxSelectedItem(hwndlbtypes); //typename WinQueryLboxItemText(hwndlbtypes,index,typename,MAXNAMELENGTH); index=WinQueryLboxSelectedItem(hwndlbprops); //propname WinQueryLboxItemText(hwndlbprops,index,propname,MAXNAMELENGTH); WinQueryWindowText(hwndnewvalue,MAXNAMELENGTH,newvalue); dbtype=odb.getpropertytype(typename,propname); if (dbtype==_INT_) oktype=validate_integer(newvalue,intval); if (dbtype==_OTHER_){ oktype=validate_integer(newvalue,intval); if (oktype!=0) { //check that there is an object with the oid obj=odb.getobjectwithoid("Usertypes",intval); if (obj==NULL) oktype=0; } }; if (dbtype==_REAL_) oktype=validate_real(newvalue,realval); if (dbtype==_CHAR_) oktype=1; if ((strlen(newvalue)>0)&&(strlen(propname)>0)&&(oktype!=0)){ //move assigned prop from prop cmb box to assigned props WinInsertLboxItem(hwndassignedprop,noassignedprops,(PSZ)propname); WinInsertLboxItem(hwndpropval,noassignedprops,(PSZ)newvalue); noassignedprops++; WinDeleteLboxItem(hwndlbprops,index); WinSetWindowText(hwnddatatype,(PSZ)""); WinSetWindowText(hwndnewvalue,(PSZ)""); } else WinMessageBox(HWND_DESKTOP,hwndOwner,(PCH) "Missing or erroneous data", (PCH)"Alert",0,MB_OKCANCEL); break; default: return WinDefDlgProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY ViceFileDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { switch (msg) { case WM_INITDLG: { FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); int i; char *szpath; const int action = fdlg->ulUser; const int nact = (action >> 8) & 0xff; const int nsact = (action) & 0xff; FillABox(hwnd, action ? nact - 1 : 0); FillSBox(hwnd, action ? nsact - 1 : 0); FillFBox(hwnd); NewFilter(hwnd); for (i = 0; i < numfonts; i++) { WinDlgLboxInsertItem(hwnd, DID_FONTNAME_LB, fnames[i]); } WinDlgLboxSelectItem(hwnd, DID_FONTNAME_LB, 0); if (action) { WinEnableControl(hwnd, DID_ACTION_CB, FALSE); WinEnableControl(hwnd, DID_SUBACTION_CB, FALSE); } if (action || fdlg->fl & FDS_SAVEAS_DIALOG) { WinEnableControl(hwnd, DID_AUTOSTART_PB, FALSE); } szpath = util_concat(fdlg->pszIDrive, fdlg->szFullFile, NULL); *(strrchr(szpath, '\\') + 1) = '\0'; WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); lib_free(szpath); szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL); if (!GpiLoadFonts(WinQueryAnchorBlock(hwnd), szpath)) { log_debug("dlg-fileio.c: GpiLoadFonts('%s') failed.", szpath); WinEnableControl(hwnd, DID_FONTNAME_LB, FALSE); } lib_free(szpath); } return FALSE; case WM_DESTROY: { char *szpath = util_concat(archdep_boot_path(), "\\vice2.dll", NULL); LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB)); if (!GpiUnloadFonts(WinQueryAnchorBlock(hwnd), szpath)) { log_debug("dlg-fileio.c: GpiUnloadFonts('%s') failed.", szpath); } lib_free (szpath); } break; case WM_CONTROL: switch (SHORT1FROMMP(mp1)) { case DID_ACTION_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { FillSBox(hwnd, 0); } case DID_SUBACTION_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { FillFBox(hwnd); } case DID_FFILTER_CB: if (SHORT2FROMMP(mp1) == CBN_ENTER) { NewFilter(hwnd); } return FALSE; case DID_DIRECTORY_LB: WinDefFileDlgProc(hwnd, msg, mp1, mp2); if (SHORT2FROMMP(mp1) == LN_SELECT || SHORT2FROMMP(mp1) == LN_ENTER) { char szpath[CCHMAXPATH]; const int nr = WinQueryLboxSelectedItem((HWND)mp2); if (nr < 0) { return FALSE; } if (SHORT2FROMMP(mp1) == LN_SELECT && WinQueryFocus(HWND_DESKTOP) == (HWND)mp2) { return FALSE; } if (!GetLboxPath((HWND)mp2, nr, szpath)) { return FALSE; } WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); } return FALSE; case DID_FILENAME_ED: if (WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB) && SHORT2FROMMP(mp1) == EN_CHANGE) { char szpath[CCHMAXPATH]; if (GetFullFile(hwnd, szpath)) { ShowContents(hwnd, szpath); } } break; case DID_CONTENTS_CB: { const int state = WinQueryButtonCheckstate(hwnd, DID_CONTENTS_CB); WinEnableControl(hwnd, DID_CONTENTS_LB, state); WinEnableControl(hwnd, DID_FONTNAME_LB, state); if (state) { ContentsUpdate(hwnd); } else { LboxFreeContents(WinWindowFromID(hwnd, DID_CONTENTS_LB)); } } return FALSE; case DID_FONTNAME_LB: if (SHORT2FROMMP(mp1) != CBN_ENTER) { break; } ContentsUpdate(hwnd); return FALSE; } break; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case DID_DIRUP: { const HWND name = WinWindowFromID(hwnd, DID_FILENAME_ED); const int pos = WinDlgLboxSelectedItem(hwnd, DID_DIRECTORY_LB); char szpath[CCHMAXPATH]; char *cpos; int len; if (!pos) { return FALSE; } WinQueryDlgItemText(hwnd, DID_DIR_SELECTED, CCHMAXPATH - 1, szpath); if (strlen(szpath) < 4) { return FALSE; } *strrchr(szpath, '\\') = '\0'; cpos = strrchr(szpath,'\\') + 1; len = cpos - szpath + 2; if (len == CCHMAXPATH - 1) { return FALSE; } WinQueryDlgItemText(hwnd, DID_FILENAME_ED, CCHMAXPATH - len - 1, cpos); WinSetWindowText(name, szpath); *cpos = '\0'; WinSetDlgItemText(hwnd, DID_DIR_SELECTED, szpath); // // set focus to entry field and simulate an Apply // WinSetFocus(HWND_DESKTOP, name); WinDefFileDlgProc(hwnd, WM_COMMAND, (MPARAM)DID_OK, MPFROM2SHORT(CMDSRC_PUSHBUTTON, TRUE)); } return FALSE; case DID_AUTOSTART_PB: { const int pos = WinDlgLboxSelectedItem(hwnd, DID_CONTENTS_LB); FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); size_t length; char szpath[CCHMAXPATH]; if (!GetFullFile(hwnd, szpath)) { return FALSE; } if (autostart_autodetect(szpath, NULL, pos < 0 ? 0 : pos, AUTOSTART_MODE_RUN)) { return FALSE; } length = strrchr(szpath, '\\') - szpath; fdlg->lReturn = DID_OK; if (length > 0) { fdlg->szFullFile[length] = 0; } } break; } break; case WM_MEASUREITEM: if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) { return MRFROM2SHORT(9, 9); } break; case WM_DRAWITEM: if (SHORT1FROMMP(mp1) == DID_CONTENTS_LB) { OWNERITEM *item = (OWNERITEM*)mp2; RECTL *rcl = &(item->rclItem); if (rcl->yTop-rcl->yBottom == 9) { image_contents_screencode_t *line = (image_contents_screencode_t *)WinLboxItemHandle(item->hwnd, item->idItem); if (line) { LboxDrawLine(hwnd, item, rcl, line); } item->fsState = item->fsStateOld = 0; } return (MRESULT)TRUE; } break; case FDM_VALIDATE: // mp1 = PSZ pszPathName // mp2 = USHORT Field name id // mr = TRUE -> Valid name { const int sact = WinDlgLboxSelectedItem(hwnd, DID_SUBACTION_CB); const int act = WinDlgLboxSelectedItem(hwnd, DID_ACTION_CB); const FILEDLG *fdlg = (FILEDLG*)WinQueryWindowPtr(hwnd, QWL_USER); char *szpath = (char*)mp1; int rc; char *slash; if (fdlg->fl & FDS_OPEN_DIALOG) { rc = FdmDoLoadAction(hwnd, szpath, act, sact); } else { rc = FdmDoSaveAction(hwnd, szpath, act, sact); } if (rc < 0) { const action_t *action = fdlg->fl & FDS_OPEN_DIALOG ? LoadAction : SaveAction; char *txt = util_concat("The following action couldn't be performed:\n", action[act].type, " ", action[act].subact[sact].action, NULL); HPOINTER hpt = WinLoadPointer(HWND_DESKTOP, NULLHANDLE, 0x101); #ifdef WATCOM_COMPILE struct _MB2D mbtemp; struct _MB2INFO mb; mb.cb = sizeof(MB2INFO); mb.hIcon = hpt; mb.cButtons = 1; mb.flStyle = MB_CUSTOMICON|WS_VISIBLE; mb.hwndNotify = NULLHANDLE; sprintf(mbtemp.achText," OK "); mbtemp.idButton = 0; mbtemp.flStyle = BS_DEFAULT; mb.mb2d[0] = mbtemp; #else MB2INFO mb = { sizeof(MB2INFO), hpt, 1, MB_CUSTOMICON | WS_VISIBLE, NULLHANDLE, " OK ", 0, BS_DEFAULT}; #endif WinMessageBox2(HWND_DESKTOP, hwnd, txt, "VICE/2 Error", 0, &mb); lib_free(txt); return FALSE; } // // FIXME! Better solution? // slash = strrchr(szpath, '\\'); if (slash) { *slash = '\0'; } chdir(szpath); } return (MRESULT)TRUE; } return WinDefFileDlgProc(hwnd, msg, mp1, mp2); }