📄 gvpdlg.c
字号:
char *
get_sound_name(int index)
{
static char buf[64];
char *p, *q;
HINI hini;
if (index==0)
return szNone;
if (index==1)
return szSpeaker;
/* get human readable name for system sound */
if ( (hini = PrfOpenProfile(hab, szMMini)) == NULLHANDLE )
return "";
PrfQueryProfileString(hini, (PCSZ)"MMPM2_AlarmSounds", (PCSZ)sound_entry[index], (PCSZ)"##", buf, sizeof(buf));
PrfCloseProfile(hini);
p = strchr(buf,'#');
if (p != (char *)NULL) {
q = strchr(++p,'#');
if (q != (char *)NULL) {
*q = '\0';
return p;
}
}
return "";
}
int
find_sound_name(char *entry)
{
int i;
for (i=0; i<system_num; i++) {
if (strcmp(entry, get_sound_entry(i))==0)
return i;
}
return -1; /* no find */
}
void
add_sounds(HWND hwnd)
{
int ifile;
for (ifile=system_num-1; ifile>=0; ifile--)
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_INSERTITEM, MPFROMSHORT(0),
MPFROMP(get_sound_name(ifile)));
}
void
free_sounds(void)
{
if (system_sounds != (char *)NULL)
free(system_sounds);
}
void
change_sounds(void)
{
nHelpTopic = IDS_TOPICSOUND;
WinDlgBox(HWND_DESKTOP, hwnd_frame, SoundDlgProc, hlanguage, IDD_SOUND, NULL);
}
MRESULT EXPENTRY SoundDlgProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
char buf[MAXSTR];
int ievent, ifile;
static struct sound_s dsound[NUMSOUND]; /* copy of sound[] */
char *szWaveFilter = "*.wav";
static char szPath[MAXSTR];
static int file_start;
char *p;
switch (msg) {
case WM_INITDLG:
file_start = load_sounds();
for (ievent=0; ievent<NUMSOUND; ievent++) {
strcpy(dsound[ievent].file, sound[ievent].file);
load_string(sound[ievent].title, buf, sizeof(buf));
WinSendDlgItemMsg(hwnd, SOUND_EVENT, LM_INSERTITEM,
MPFROMLONG(LIT_END), MPFROMP(buf));
}
ievent = 0;
WinSendDlgItemMsg(hwnd, SOUND_EVENT, LM_SELECTITEM, MPFROMLONG(ievent), MPFROMLONG(TRUE));
/* force update of SOUND_FILE */
WinSendMsg(WinWindowFromID(hwnd, SOUND_EVENT), WM_CONTROL,
MPFROM2SHORT(SOUND_EVENT, LN_SELECT), MPFROMLONG(0));
break;
case WM_CONTROL:
if (mp1 == MPFROM2SHORT(SOUND_EVENT, LN_SELECT)) {
ievent = (int)WinSendDlgItemMsg(hwnd, SOUND_EVENT, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
if (ievent == LIT_NONE) {
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), FALSE);
break;
}
ifile = find_sound_name(dsound[ievent].file);
if (ifile >= 0) {
strcpy(buf, get_sound_name(ifile));
szPath[0] = '\0';
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), ifile!=0);
}
else {
/* must be WAVE file */
strcpy(szPath, dsound[ievent].file);
p = strrchr(szPath, '\\');
if (p != (char *)NULL) {
strcpy(buf,++p);
*p = '\0';
}
else {
strcpy(buf, szPath);
}
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), TRUE);
}
strcat(szPath, szWaveFilter);
WinEnableWindowUpdate(WinWindowFromID(hwnd, SOUND_FILE), FALSE);
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_DELETEALL, MPFROMLONG(0), MPFROMLONG(0));
listbox_directory(hwnd, szPath, SOUND_FILE, SOUND_PATH);
add_sounds(hwnd);
WinEnableWindowUpdate(WinWindowFromID(hwnd, SOUND_FILE), TRUE);
WinShowWindow(WinWindowFromID(hwnd, SOUND_FILE), TRUE);
ifile = (int)WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_SEARCHSTRING,
MPFROM2SHORT(0,LIT_FIRST), MPFROMP(buf));
if (ifile != LIT_NONE)
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_SELECTITEM, MPFROMLONG(ifile), MPFROMLONG(TRUE));
else
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_SELECTITEM, MPFROMLONG(0), MPFROMLONG(TRUE));
}
if (mp1 == MPFROM2SHORT(SOUND_FILE, LN_SELECT)) {
ifile = (int)WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_QUERYITEMTEXT,
MPFROM2SHORT(ifile,sizeof(buf)), MPFROMP(buf));
ievent = (int)WinSendDlgItemMsg(hwnd, SOUND_EVENT, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
if (ifile >= file_start) {
if (buf[0] == '[') { /* selected a directory */
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), FALSE);
}
else { /* selected a WAVE file */
int i = WinQueryDlgItemText(hwnd, SOUND_PATH, MAXSTR, (PBYTE)dsound[ievent].file);
if (dsound[ievent].file[i-1] != '\\') {
dsound[ievent].file[i++] = '\\';
dsound[ievent].file[i] = '\0';
}
listbox_getpath(hwnd, dsound[ievent].file + i, SOUND_FILE);
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), TRUE);
}
}
else {
WinEnableWindow(WinWindowFromID(hwnd, SOUND_TEST), ifile!=0);
strcpy(dsound[ievent].file,get_sound_entry(ifile));
}
}
if (mp1 == MPFROM2SHORT(SOUND_FILE, LN_ENTER)) {
ifile = (int)WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
WinSendDlgItemMsg(hwnd, SOUND_FILE, LM_QUERYITEMTEXT,
MPFROM2SHORT(ifile,sizeof(buf)), MPFROMP(buf));
if (buf[0] == '[') {
WinQueryDlgItemText(hwnd, SOUND_PATH, sizeof(szPath), (PBYTE)szPath);
listbox_getpath(hwnd, szPath, SOUND_FILE);
strcat(szPath, szWaveFilter);
listbox_directory(hwnd, szPath, SOUND_FILE, SOUND_PATH);
add_sounds(hwnd);
}
else {
WinSendMsg(hwnd, WM_COMMAND, MPFROMSHORT(SOUND_TEST), MPFROMLONG(0));
}
}
break;
case WM_COMMAND:
switch (SHORT1FROMMP(mp1)) {
case ID_HELP:
get_help();
return (MRESULT)FALSE;
case SOUND_EVENT:
return (MRESULT)FALSE;
case SOUND_FILE:
return (MRESULT)FALSE;
case SOUND_TEST:
ievent = (int)WinSendDlgItemMsg(hwnd, SOUND_EVENT, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
if (strlen(dsound[ievent].file)==0)
return FALSE;
if (!(pfnMciPlayFile) || strcmp(dsound[ievent].file,BEEP)==0) {
DosBeep(200,200);
return FALSE;
}
if (isdigit((int)(*dsound[ievent].file)))
play_system_sound(dsound[ievent].file);
else {
buf[0] = '\042';
strcpy(buf+1, dsound[ievent].file);
strcat(buf, "\042");
if ((*pfnMciPlayFile)(hwnd_frame, (PBYTE)buf, 0, 0, 0))
DosBeep(200,200);
}
return (MRESULT)FALSE;
case IDOK:
for (ievent=0; ievent<NUMSOUND; ievent++)
strcpy(sound[ievent].file, dsound[ievent].file);
free_sounds();
WinDismissDlg(hwnd, DID_OK);
return (MRESULT)TRUE;
case DID_CANCEL:
free_sounds();
WinDismissDlg(hwnd, DID_CANCEL);
return (MRESULT)TRUE;
}
break;
}
return WinDefDlgProc(hwnd, msg, mp1, mp2);
}
/* update path with current selection */
/* returned path has a trailing \ if it is a directory */
void
listbox_getpath(HWND hwnd, char *path, int listbox)
{
int i;
char buf[MAXSTR];
char *p;
ULONG len;
i = (int)WinSendDlgItemMsg(hwnd, listbox, LM_QUERYSELECTION,
MPFROMSHORT(LIT_FIRST), MPFROMLONG(0));
WinSendDlgItemMsg(hwnd, listbox, LM_QUERYITEMTEXT,
MPFROM2SHORT(i,sizeof(buf)), MPFROMP(buf));
if (buf[0] == '[') {
/* directory or drive */
if (buf[1] == '-') { /* drive */
len = MAXSTR;
path[0] = toupper(buf[2]);
path[1] = ':';
path[2] = '\\';
DosQueryCurrentDir(buf[2]+1-'a', (PBYTE)path+3, &len);
}
else {
if (strcmp(buf, "[..]")==0) {
if ((p = strrchr(path,'\\')) != (char *)NULL)
*(++p)='\0';
}
else {
if (path[strlen(path)-1] != '\\')
strcat(path,"\\");
if ((p = strchr(buf, ']')) != (char *)NULL)
*p = '\0';
strcat(path, buf+1);
strcat(path, "\\");
}
}
}
else {
if (path[strlen(path)-1] != '\\')
strcat(path,"\\");
strcat(path, buf);
}
}
/* empty list box, then fill it with files and subdirectories given */
/* by path and stext */
/* if path doesn't contain directory, use directory in stext */
/* update stext to point to directory */
void
listbox_directory(HWND hwnd, char *path, int listbox, int stext)
{
APIRET rc;
FILEFINDBUF3 findbuf;
HDIR hdir;
ULONG cFilenames = 1;
char *p;
char dpath[MAXSTR];
char spath[MAXSTR];
int i;
ULONG drivenum, drivemap;
if (strrchr(path, '\\') == (char *)NULL) {
WinQueryWindowText(WinWindowFromID(hwnd, stext), MAXSTR, (PBYTE)dpath);
if (strlen(dpath)==0)
strcpy(dpath, szExePath);
strcpy(spath, dpath);
if (spath[strlen(spath)-1] != '\\')
strcat(spath,"\\");
strcat(spath, path);
}
else {
strcpy(spath, path);
strcpy(dpath, path);
p = strrchr(dpath,'\\');
*(++p)='\0';
if (strlen(dpath) > 3)
*(--p)='\0';
}
if ( (strlen(dpath) != 3) &&(dpath[strlen(dpath)-1] == '\\') )
dpath[strlen(dpath)-1] = '\0';
WinSetWindowText(WinWindowFromID(hwnd, stext), (PCSZ)dpath);
strcat(dpath, (strlen(dpath) > 3) ? "\\*" : "*");
/* stuff in filenames */
WinSendDlgItemMsg(hwnd, listbox, LM_DELETEALL, MPFROMLONG(0), MPFROMLONG(0));
hdir = HDIR_CREATE;
cFilenames = 1;
rc = DosFindFirst((PBYTE)spath, &hdir, FILE_NORMAL,
&findbuf, sizeof(findbuf), &cFilenames, FIL_STANDARD);
while (!rc) {
WinSendDlgItemMsg(hwnd, listbox, LM_INSERTITEM,
MPFROMLONG(LIT_SORTASCENDING), MPFROMP(findbuf.achName));
cFilenames = 1;
rc = DosFindNext(hdir, &findbuf, sizeof(findbuf), &cFilenames);
}
DosFindClose(hdir);
/* stuff in subdirectory names */
hdir = HDIR_CREATE;
cFilenames = 1;
rc = DosFindFirst((PBYTE)dpath, &hdir, MUST_HAVE_DIRECTORY,
&findbuf, sizeof(findbuf), &cFilenames, FIL_STANDARD);
while (!rc) {
strcpy(spath,"[");
strcat(spath,findbuf.achName);
strcat(spath,"]");
if (strcmp(findbuf.achName, ".") != 0)
WinSendDlgItemMsg(hwnd, listbox, LM_INSERTITEM,
MPFROMLONG(LIT_SORTASCENDING), MPFROMP(spath));
cFilenames = 1;
rc = DosFindNext(hdir, &findbuf, sizeof(findbuf), &cFilenames);
}
DosFindClose(hdir);
DosQueryCurrentDisk(&drivenum, &drivemap);
/* stuff in drive list */
for (i=1; i<=26; i++) {
if (drivemap & 1) {
sprintf(spath,"[-%c-]",i-1+'a');
WinSendDlgItemMsg(hwnd, listbox, LM_INSERTITEM,
MPFROMLONG(LIT_END), MPFROMP(spath));
}
drivemap >>= 1;
}
}
MRESULT EXPENTRY
InstallDlgProc(HWND hwnd, ULONG mess, MPARAM mp1, MPARAM mp2)
{
switch(mess) {
case WM_INITDLG:
WinSendMsg( WinWindowFromID(hwnd, INSTALL_DLL),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
WinSetWindowText( WinWindowFromID(hwnd, INSTALL_DLL),
(PCSZ)option.gsdll );
WinSendMsg( WinWindowFromID(hwnd, INSTALL_INCLUDE),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
WinSetWindowText( WinWindowFromID(hwnd, INSTALL_INCLUDE),
(PCSZ)option.gsinclude );
WinSendMsg( WinWindowFromID(hwnd, INSTALL_OTHER),
EM_SETTEXTLIMIT, MPFROM2SHORT(MAXSTR, 0), MPFROMLONG(0) );
WinSetWindowText( WinWindowFromID(hwnd, INSTALL_OTHER),
(PCSZ)option.gsother );
WinSetFocus(HWND_DESKTOP, WinWindowFromID(hwnd, INSTALL_INCLUDE));
break;
case WM_COMMAND:
switch(SHORT1FROMMP(mp1)) {
case ID_DEFAULT:
install_default(hwnd);
return(FALSE);
case DID_OK:
WinEnableWindow(WinWindowFromID(hwnd, DID_OK), FALSE);
WinQueryWindowText(WinWindowFromID(hwnd, INSTALL_DLL),
MAXSTR, (PBYTE)option.gsdll);
WinQueryWindowText(WinWindowFromID(hwnd, INSTALL_INCLUDE),
MAXSTR, (PBYTE)option.gsinclude);
WinQueryWindowText(WinWindowFromID(hwnd, INSTALL_OTHER),
MAXSTR, (PBYTE)option.gsother);
WinDismissDlg(hwnd, DID_OK);
return (MRESULT)TRUE;
case ID_HELP:
get_help();
return (MRESULT)TRUE;
}
break;
}
return WinDefDlgProc(hwnd, mess, mp1, mp2);
}
BOOL
install_gsdll(void)
{
nHelpTopic = IDS_TOPICADVANCEDCFG;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -