📄 sdm.c
字号:
}
/* ??????? real sleazy way to put argument into cab */
RgbToCab(hcab, *hval, cwVal * 2, ptif->iagMain);
HeapFree(hval);
}
return TRUE;
}
STATIC VOID
FormatFromCabTif(hcab, ptif)
/*
-- format information into CAB
*/
HCAB hcab;
REGISTER PTIF ptif;
{
REGISTER PCABX pcabx;
WORD iag;
char sz[cwEditBuffer * sizeof (WORD)];
PWFN_CTL pfnCtl;
/* Item must have an parse proc */
/* Item must have an parse proc */
AssertExtension1(ptif);
pfnCtl = Ptm1OfTif(ptif)->pfnCtl;
Assert(pfnCtl != NULL);
pcabx = PcabxOfCab(hcab);
iag = ptif->iagMain;
if (iag < pcabx->cabh.cagHandle)
{
/* item with a handle */
(*pfnCtl)(tmmFormat, sz, (WORD) &pcabx->rgh[iag], ptif->tmc,
wParamLater, 0);
}
else
{
(*pfnCtl)(tmmFormat, sz, (WORD) hcab, ptif->tmc, wParamLater,
(WORD) &((CABX *) 0)->rgh[ptif->iagMain]);
}
SetDlgItemText(ptif->pwnd, sz, FALSE);
}
STATIC DWORD FARPUBLIC
SdmDialogProc(pwnd, message, tmc, lParam)
/*
-- Dialog procedure for SDM dialogs
*/
PWND pwnd;
WORD message;
TMC tmc; /* wParam = pwnd->id */
DWORD lParam;
{
REGISTER PTM ptm;
PTIF ptif;
BOOL fDismiss;
DLM dlm = dlmClick;
#ifdef DIALOG_NOSAVE
Assert(message == WM_PAINT || pwnd == sdsCur.pwndDialog);
#else // DIALOG_NOSAVE
Assert(pwnd == sdsCur.pwndDialog);
#endif // DIALOG_NOSAVE
switch (message)
{
default:
return FALSE;
case WM_DIALOG_SETFOCUS:
if (FExistsDialogProc())
FCallDialogProc(dlmSetFocus, tmc, 0, 0, 0);
return FALSE;
case WM_DIALOG_KILLFOCUS:
if (FExistsDialogProc())
FCallDialogProc(dlmKillFocus, tmc, 0, 0, 0);
return FALSE;
case WM_DIALOG:
#ifdef HELP_BUTTON
if (tmc == tmcHelp)
{
tmc = 0; /* No shift states for Help */
goto do_help;
}
#endif
break; /* fall through */
case WM_INITDIALOG:
{
/* Initializing dialog */
BOOL fRet;
fRet = FSetDialogFromCab();
if (FExistsDialogProc())
{
FCallDialogProc(dlmInit, tmcNull, 0, 0,
(WORD) sdsCur.hcab);
}
return(fRet);
}
/*break*/
case WM_HELP:
#ifdef HELP_BUTTON
do_help:
#endif
/* really the tmc contains the KK value */
Help(hemDialog, sdsCur.pdlg->hid, sdsCur.pdlg, tmc);
return FALSE;
/*break*/
case WM_CHAR:
dlm = dlmKey;
goto send_dlm;
case WM_IDLE:
#ifdef DUAL
/* for DOS 5, in idle return TRUE (=> dialog processor
* will put us to sleep
*/
if (fProtectMode && !FExistsDialogProc())
return TRUE; /* default idle */
#else /*!DUAL*/
#ifdef DOS5
/* for DOS 5, in idle return TRUE (=> dialog processor
* will put us to sleep
*/
if (!FExistsDialogProc())
return TRUE; /* default idle */
#endif
#endif /*!DUAL*/
dlm = dlmIdle;
send_dlm:
/* call the dialog proc -- if it returns FALSE, cancel dialog */
if (FExistsDialogProc() &&
!FCallDialogProc(dlm, tmc, tmc, 0, 0))
{
/* dismiss it */
ptif = PtifFromTmc(tmc = tmcCancel);
ptm = ptif->ptm;
goto DoOK;
}
return FALSE;
/* break */
}
/* else WM_DIALOG */
Assert(message == WM_DIALOG);
ptif = PtifFromTmc(tmc);
ptm = ptif->ptm;
fDismiss = ptm->fDismiss; /* clear if not acknowledged */
/* process regular tmc BEFORE calling dialog proc */
switch (ptm->tmtBase)
{
case tmtRadioButton:
/* check one button, clear rest */
CheckRadioButton(ptif->pwnd, 0, TRUE);
break;
case tmtListBox:
switch (HIWORD(lParam))
{
default:
Assert(FALSE);
break;
case LBN_SELECT_DONE:
dlm = dlmUnclick;
break;
case LBN_SELCHANGE:
/* ListBox selection changed */
if (ptm->fComboListBox)
{
if ((ptif+1)->ptm->tmtBase == tmtTrackingText &&
(ptif+2)->ptm->tmtBase == tmtListBox)
/* clear selection in dir/drive */
SendMessage((ptif+2)->pwnd,
LB_SETCURSEL, (WORD) -1, 0L);
SelChangeComboListBox(ptif);
}
else if (ptm->fDirListBox)
{
/* change in split dir/drives */
Assert((ptif-1)->ptm->tmtBase == tmtTrackingText);
Assert((ptif-2)->ptm->tmtBase == tmtListBox);
/* clear the file selection */
SendMessage((ptif-2)->pwnd, LB_SETCURSEL,
(WORD) -1, 0L);
SelChangeComboListBox(ptif-2);
}
break;
case LBN_DBLCLK: /* Double Click in listbox */
{
Assert(!fDismiss); /* not normal dismiss */
fDismiss = (FExistsDialogProc()) ?
FCallDialogProc(dlmDblClk, tmc, 0, 0, wParamLater) :
TRUE;
if (fDismiss)
{
/* Dismiss via double click */
PWND pwndT;
if ((pwndT =
PwndDefaultPushButton(pwnd)) != NULL)
{
/* Change item */
ptif = PtifFromTmc(tmc = pwndT->id);
ptm = ptif->ptm;
goto DoOK;
}
}
}
break;
} /*switch(LBN_)*/
} /*switch(tmt)*/
if (ptm->fProc)
{
/* call client's dialog procedure */
BOOL fAck;
AssertSz(FExistsDialogProc(),
"SdmDialogProc: missing dialog function");
if (ptm->tmtBase == tmtEdit)
{
/* Check for change message */
dlm = (HIWORD(lParam) == EN_CHANGE) ? dlmChange :
0;
}
fAck = (dlm == 0) ||
FCallDialogProc(dlm, tmc, LOWORD(lParam), HIWORD(lParam),
wParamLater);
#ifdef LATER
... do something with fAck
#endif
if (fDismiss)
fDismiss = fAck;
}
if (fDismiss)
{
/* dismiss dialog (maybe) */
HCAB hcabT;
DoOK:
hcabT = NULL; /* NULL => don't place changes in CAB */
if (!FEnabledTmc(tmc))
return TRUE; /* exit button not enabled */
/* NOTE : disabling a OK/CANCEL button is dangerous */
if (ptm->fCabDismiss && sdsCur.hcab != NULL)
{
/* try to fill in the CAB */
if ((hcabT = HcabFromDialog()) == NULL)
{
/* and error returned, cancel the dialog */
EndDialog(pwnd, tmcCancel);
return TRUE;
}
}
if (hcabT == (HCAB) -1)
return TRUE;
if (FExistsDialogProc() &&
!FCallDialogProc(dlmTerm, tmc, LOWORD(lParam), HIWORD(lParam), 0))
{
/* Dialog proc does not want us to dismiss */
if (hcabT != NULL)
FreeCab(hcabT);
return TRUE;
}
if (hcabT != NULL)
{
/* replace original cab's handles */
PCABX pcabxDest;
FreeCabData(sdsCur.hcab);
pcabxDest = PcabxOfCab(sdsCur.hcab);
bltbyte((char *) PcabxOfCab(hcabT)->rgh,
(char *) pcabxDest->rgh,
pcabxDest->cabh.cwData * sizeof(WORD));
HeapFree(hcabT);
}
EndDialog(pwnd, tmc);
}
return(TRUE);
}
PRIVATE PTIF
PtifFromTmc(tmc)
/*
-- return TM for a given TMC
-- read info about TIF's in header for special mapping
*/
TMC tmc;
{
REGISTER PTIF ptif;
WORD ctif;
if (tmc >= tmcSysMin && tmc < tmcSysMax)
{
/* in array if at all */
AssertSz(ItifOfTmc(tmc) < sdsCur.ctif, "invalid TMC");
ptif = &sdsCur.rgtif[ItifOfTmc(tmc)];
AssertSz(ptif->tmc == tmc, "invalid TMC");
return ptif;
}
ptif = sdsCur.rgtif;
ctif = sdsCur.ctif;
while (ctif--)
{
if (ptif->tmc == tmc)
return ptif;
ptif++;
}
AssertSz(FALSE, "invalid TMC");
}
/*****************************************************************************/
/* * ListBox Utilities */
STATIC char *
SzWildCard(sz)
/*
-- return pointer to wildcard at end of long path
-- return empty string (not NULL) if no wild cards
*/
REGISTER char *sz;
{
REGISTER char ch;
char *pchAfterSlash = sz;
BOOL fWild = FALSE;
while ((ch = *sz) != '\0')
{
sz++;
if (ch == '\\' || ch == '/' || ch == ':')
pchAfterSlash = sz;
else if (ch == '*' || ch == '?')
fWild = TRUE;
}
Assert(*sz == '\0'); /* sz => empty string */
return (fWild ? pchAfterSlash : sz);
}
#ifdef LISTBOX_DIR
STATIC BOOL
FFillComboDir(ptif, fInit)
/*
-- fill CAB arg with thing selected from directory
-- return TRUE if can exit, FALSE if wildcard (or directory)
(don't end dialog)
-- ptif-1 => TIF of edit item
-- ptif => TIF of a combo dir listbox
-- ptif+1 => TIF of a tracking text (optional)
-- if fInit set => always fill listbox / don't move focus
*/
REGISTER PTIF ptif;
BOOL fInit;
{
BOOL fCantExit;
char szBuffer[cwEditBuffer * sizeof (WORD)];
Debug(PTM ptmListBox = ptif->ptm);
Debug(PTM ptmEdit = (ptif-1)->ptm);
Assert(ptmListBox->tmtBase == tmtListBox && ptmListBox->fDirListBox);
if (!ptif->ptm->fComboListBox)
return TRUE; /* directory listbox */
/* get edit item (path name) */
GetDlgItemText((ptif-1)->pwnd, szBuffer, sizeof(szBuffer)-1);
if ((fCantExit = FMaybeDir(szBuffer)) || fInit)
{
/* re-fill */
PWND pwnd = ptif->fReal ? ptif->pwnd : NULL;
if ((ptif+1)->ptm->tmtBase != tmtTrackingText)
DlgDirList(pwnd, szBuffer, NULL, fRedrawItem, NULL);
else
{
DlgDirList(pwnd, szBuffer, (ptif+1)->pwnd,
fRedrawItem,
(ptif+2)->ptm->tmtBase == tmtListBox ?
(ptif+2)->pwnd : NULL);
}
if (!fInit)
SetFocus((ptif-1)->pwnd);
}
/* real path, no wild-cards */
SetDlgItemText((ptif-1)->pwnd, szBuffer, fRedrawItem);
return !fCantExit;
}
#endif /*LISTBOX_DIR*/
PRIVATE VOID
FillListBoxTif(ptif, iszInit)
/*
-- fill listbox from CAB info
*/
REGISTER PTIF ptif;
WORD iszInit; /* initial selection : if non-combo */
{
Assert(ptif->ptm->tmtBase == tmtListBox);
Assert(sdsCur.hcab != NULL);
Assert(ptif->pwnd != NULL);
#ifdef LISTBOX_DIR
if (ptif->ptm->fDirListBox)
{
/* Directory ListBox */
FFillComboDir(ptif, TRUE);
}
else
#else
Assert(!(ptif->ptm->fDirListBox));
#endif /*!LISTBOX_DIR*/
{
/* Non-directory ListBox */
WORD isz;
WORD csz;
PWFN_CTL pfnCtl;
char szBuffer[cchListTextMax];
AssertExtension1(ptif);
pfnCtl = Ptm1OfTif(ptif)->pfnCtl;
Assert(pfnCtl != NULL);
SendMessageShort(ptif->pwnd, LB_RESETCONTENT);
csz = (*pfnCtl)(tmmCount, NULL, NULL, ptif->tmc, wParamLater, 0);
isz = 0;
if (ptif->ptm->fSortedListBox || csz == cszUnknown)
{
/* we must fill in the listbox */
while (csz == cszUnknown || isz < csz)
{
if ((*pfnCtl)(tmmText, szBuffer, isz++, ptif->tmc,
wParamLater, 0))
{
/* we have a string */
SendMessage(ptif->pwnd, LB_ADDSTRING,
(WORD) szBuffer, 0L);
}
else if (csz == cszUnknown)
break; /* stop filling */
}
}
else
{
/* fill on demand (fill with empties) */
Assert(csz != cszUnknown);
while (csz--)
SendMessage(ptif->pwnd, LB_ADDSTRING, 0, 0L);
}
/* we assume the right val for SendMessage */
if (!ptif->ptm->fComboListBox && iszInit != iszNinchList)
SendMessage(ptif->pwnd, LB_SETCURSEL, iszInit, 0L);
}
}
STATIC VOID
SelChangeComboListBox(ptif)
/*
-- respond to combo listbox selection change
-- ptif-1 => Edit Item
-- ptif => Listbox
-- ptif+2 => second listbox (if ptif+1 => Tracking text)
*/
PTIF ptif;
{
char szBuffer[cchDirMax];
/* Combo listbox must be prefixed by edit item */
Assert(ptif > sdsCur.rgtif && (ptif-1)->ptm->tmtBase == tmtEdit);
Assert(ptif->ptm->tmtBase == tmtListBox);
#ifdef LISTBOX_DIR
if (ptif->ptm->fDirListBox)
{
char szBuffer2[cchDirMax];
/* select new item in directory */
if (DlgDirSelect(ptif->pwnd, szBuffer
,(ptif+2)->ptm->tmtBase == tmtListBox ?
(ptif+2)->pwnd : NULL))
{
GetDlgItemText((ptif-1)->pwnd, szBuffer2,
sizeof(szBuffer2)-1);
/* skip directory or drive info */
SzAppendSDM(szBuffer, SzWildCard(szBuffer2));
}
}
else
#endif /*LISTBOX_DIR*/
{
/* Non directory listbox */
WORD isz;
AssertExtension1(ptif);
isz = (WORD) SendMessageShort(ptif->pwnd, LB_GETCURSEL);
/* call listbox proc to get the proper text */
if (isz != iszNinchList)
{
if (!(*Ptm1OfTif(ptif)->pfnCtl)(tmmEditText, szBuffer,
isz, ptif->tmc, wParamLater, 0))
{
/* get string from listbox */
GetListText(ptif->pwnd, szBuffer, sizeof(szBuffer));
}
}
else
szBuffer[0] = '\0';
}
Assert(fRedrawItem);
SetEditText((ptif - 1)->pwnd, szBuffer, TRUE);
}
/**************************/
/* button utilities */
PRIVATE VOID
KillDefaultButton()
{
PWND pwnd = sdsCur.pwndDialog;
PWND pwndT;
AssertSz((pwnd != NULL),"SetDefaultTmc : no dialog");
while ((pwndT = PwndDefaultPushButton(pwnd)) != NULL)
{
pwndT->style = (pwndT->style & WS_TYPE) | BS_PUSHBUTTON;
DrawWindow(pwndT);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -