?? dialog.c
字號:
*/
int FAR OpenBoxProc( PDLGHEADER pDlgHeader, UINT uAction, WORD wID, LONG lParam )
{
char filename[_MAX_PATH + 1];
int iIndex, drive;
PCTRLDATA pCtrlData;
static LPOPENFILEBOX lpOpenFileBox;
switch(uAction)
{
case INITDIALOG:
lpOpenFileBox = (LPOPENFILEBOX)lParam;
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
SetEditBoxText(pDlgHeader, IDC_FILENAME, lpOpenFileBox->lpExt);
_fstrcpy(filename, lpOpenFileBox->lpExt);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
FillDirListBox(pDlgHeader, IDC_DIR);
return DEFAULT;
case FOCUSCOMMAND:
if(wID == IDC_FILE)
{
iIndex = GetSelectedItem(pDlgHeader, IDC_FILE);
GetListBoxItem(pDlgHeader, IDC_FILE, filename, iIndex);
SetEditBoxText(pDlgHeader, IDC_FILENAME, filename);
pCtrlData = GetControlData(pDlgHeader, IDC_FILENAME);
OutFieldEditText(pCtrlData, FALSE);
return DEFAULT;
}
break;
case COMMAND:
switch(wID)
{
case IDOK:
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
GetEditBoxText(pDlgHeader, IDC_FILENAME, filename, 13);
if(strchr(filename, '*') != NULL
|| strchr(filename, '?') != NULL)
{
pCtrlData = GetControlData(pDlgHeader, IDC_FILE);
ReleaseListBoxBuff(pCtrlData);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
SetFocus(NULL);
FillListBox(pCtrlData);
return DEFAULT;
}
else if(!CheckFileName(lpOpenFileBox->fOpen, filename))
return DEFAULT;
// get path name
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDCANCEL:
// set directory to the default directory.
*(lpOpenFileBox->lpFileName) = '\0';
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDC_FILENAME:
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
GetEditBoxText(pDlgHeader, IDC_FILENAME, filename, 13);
if(strchr(filename, '*') != NULL
|| strchr(filename, '?') != NULL)
{
pCtrlData = GetControlData(pDlgHeader, IDC_FILE);
ReleaseListBoxBuff(pCtrlData);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
SetFocus(NULL);
FillListBox(pCtrlData);
return DEFAULT;
}
else if(!CheckFileName(lpOpenFileBox->fOpen, filename))
return DEFAULT;
// get path name
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDC_FILE:
if(GetListItemNum(pDlgHeader, IDC_FILE) < 1)
return DEFAULT;
// get path name
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
iIndex = GetSelectedItem(pDlgHeader, IDC_FILE);
GetListBoxItem(pDlgHeader, IDC_FILE, filename, iIndex);
if(!lpOpenFileBox->fOpen)
{
if(MessageBox(NULL, "給定的文件已存在,是否替換?", "文件另存為",
MB_YESNO | MB_ICONQUESTION) == IDNO)
return DEFAULT;
}
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
break;
case IDC_DIR:
iIndex = GetSelectedItem(pDlgHeader, IDC_DIR);
drive = GetListItemNum(pDlgHeader, IDC_DIR) - iIndex;
if(drive < 3)
{
drive += 2;
_chdrive(drive);
}
else
{
GetListBoxItem(pDlgHeader, IDC_DIR, filename, iIndex);
_chdir(filename);
}
_getdcwd(_getdrive(), filename, _MAX_PATH);
DrawTextInStaticItem(pDlgHeader, IDC_DIRECTORY, filename );
pCtrlData = GetControlData(pDlgHeader, IDC_DIR);
ReleaseListBoxBuff(pCtrlData);
FillDirListBox(pDlgHeader, IDC_DIR);
SetFocus(NULL);
FillListBox(pCtrlData);
GetEditBoxText(pDlgHeader, IDC_FILENAME, filename, 13);
pCtrlData = GetControlData(pDlgHeader, IDC_FILE);
ReleaseListBoxBuff(pCtrlData);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
SetFocus(NULL);
FillListBox(pCtrlData);
break;
default:
break;
}
break;
case DRAWTEXT:
if( wID == IDC_DIRECTORY)
{
_getdcwd(_getdrive(), filename, _MAX_PATH);
cc_wt16(filename, ((PCTRLDATA)lParam)->lx, ((PCTRLDATA)lParam)->ty);
return OWNER;
}
return DEFAULT;
default:
return DEFAULT;
}
return DEFAULT;
}
/*
* Function: int FAR SimpleOpenBoxProc( PDLGHEADER pDlgHeader, UINT uAction, PCTRLDATA pCtrlData, LONG lParam ).
* This function Process the simple open file dialog box.
* Parameters:
* pDlgHeader: the pointer to DLGHEADER structure.
* uAction: the Message given by DialogBoxParam function;
* pCtrlData: the control that have input focus;
* lParam: the LONG type parameter.
* Return:
*/
int FAR SimpleOpenBoxProc( PDLGHEADER pDlgHeader, UINT uAction, WORD wID, LONG lParam )
{
char filename[_MAX_PATH + 1];
PCTRLDATA pCtrlData;
static LPOPENFILEBOX lpOpenFileBox;
int iIndex;
switch(uAction)
{
case INITDIALOG:
lpOpenFileBox = (LPOPENFILEBOX)lParam;
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
SetEditBoxText(pDlgHeader, IDC_FILENAME, lpOpenFileBox->lpExt);
_fstrcpy(filename, lpOpenFileBox->lpExt);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
return DEFAULT;
case FOCUSCOMMAND:
if(wID == IDC_FILE)
{
iIndex = GetSelectedItem(pDlgHeader, IDC_FILE);
GetListBoxItem(pDlgHeader, IDC_FILE, filename, iIndex);
SetEditBoxText(pDlgHeader, IDC_FILENAME, filename);
pCtrlData = GetControlData(pDlgHeader, IDC_FILENAME);
OutFieldEditText(pCtrlData, FALSE);
return DEFAULT;
}
break;
case COMMAND:
switch(wID)
{
case IDOK:
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
GetEditBoxText(pDlgHeader, IDC_FILENAME, filename, 13);
if(strchr(filename, '*') != NULL
|| strchr(filename, '?') != NULL)
{
pCtrlData = GetControlData(pDlgHeader, IDC_FILE);
ReleaseListBoxBuff(pCtrlData);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
SetFocus(NULL);
FillListBox(pCtrlData);
return DEFAULT;
}
else if(!CheckFileName(lpOpenFileBox->fOpen, filename))
return DEFAULT;
// get path name
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDCANCEL:
// set directory to the default directory.
*(lpOpenFileBox->lpFileName) = '\0';
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDC_FILENAME:
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
GetEditBoxText(pDlgHeader, IDC_FILENAME, filename, 13);
if(strchr(filename, '*') != NULL
|| strchr(filename, '?') != NULL)
{
pCtrlData = GetControlData(pDlgHeader, IDC_FILE);
ReleaseListBoxBuff(pCtrlData);
FillFileListBox(pDlgHeader, IDC_FILE, filename);
SetFocus(NULL);
FillListBox(pCtrlData);
return DEFAULT;
}
else if(!CheckFileName(lpOpenFileBox->fOpen, filename))
return DEFAULT;
// get path name
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
case IDC_FILE:
if(GetListItemNum(pDlgHeader, IDC_FILE) < 1)
return DEFAULT;
// get path name
_getdcwd(_getdrive(), filename, _MAX_PATH);
_fstrcpy(lpOpenFileBox->lpFileName, filename);
iIndex = GetSelectedItem(pDlgHeader, IDC_FILE);
GetListBoxItem(pDlgHeader, IDC_FILE, filename, iIndex);
if(!lpOpenFileBox->fOpen)
{
if(MessageBox(NULL, "給定的文件已存在,是否替換?", "文件另存為",
MB_YESNO | MB_ICONQUESTION) == IDNO)
return DEFAULT;
}
if(_fstrlen(lpOpenFileBox->lpFileName) > 3)
_fstrcat(lpOpenFileBox->lpFileName, "\\");
_fstrcat(lpOpenFileBox->lpFileName, filename);
// set directory to the default directory.
_chdrive(lpOpenFileBox->iInitDrive);
_fstrcpy(filename, lpOpenFileBox->lpInitDir);
_chdir(filename);
return CLOSE;
break;
default:
break;
}
break;
case DRAWTEXT:
if( wID == IDC_DIRECTORY)
{
_getdcwd(_getdrive(), filename, _MAX_PATH);
cc_wt16(filename, ((PCTRLDATA)lParam)->lx, ((PCTRLDATA)lParam)->ty);
return OWNER;
}
return DEFAULT;
default:
return DEFAULT;
}
return DEFAULT;
}
/*
* Function: BOOL GUIAPI DialogBoxParam( PGUIINFO pGUIInfo, int Index, BOOL (FAR *DlgProc)(),LPSTR lpStr );
* This function create dialog box, and manage dialog. This is common
* funtion.
* Parameters:
* Index: index of dialog box;
* DlgProc: a pointer to the dialog process function;
* pStr: the parameter that give the DlgProc function,
* it often is a pointer.
* Return:
* success----TRUE;
* failure----FALSE, maybe cannot create swape file.
*/
BOOL GUIAPI DialogBoxParam( PGUIINFO pGUIInfo, PDLGHEADER pDlgHeader, int (FAR *DlgProc)(PDLGHEADER, UINT, WORD, LONG), LPSTR lpStr)
{
MSG Msg;
_vmhnd_t hdlImage;
SetPtrVis(HIDE);
SetFocus(NULL);
if(pGUIInfo)
{
do
{
if(GetMessageFromQueue(pGUIInfo, &Msg))
{
TranslateAccelerator(pGUIInfo, &Msg);
DisptchMessage(pGUIInfo, &Msg);
}
else
break;
}while(TRUE);
Msg.uMsg = MSG_KILLFOCUS;
Msg.wParam = 0;
Msg.lParam = 0L;
DisptchMessage(pGUIInfo, &Msg);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -