2000-03-05 19:58:08 +00:00
|
|
|
/* ----------------- dialbox.c -------------- */
|
|
|
|
|
|
|
|
#include "dflat.h"
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
static int inFocusCommand(DF_DBOX *);
|
|
|
|
static void dbShortcutKeys(DF_DBOX *, int);
|
|
|
|
static int ControlProc(DFWINDOW, DFMESSAGE, DF_PARAM, DF_PARAM);
|
|
|
|
static void FirstFocus(DF_DBOX *db);
|
|
|
|
static void NextFocus(DF_DBOX *db);
|
|
|
|
static void PrevFocus(DF_DBOX *db);
|
|
|
|
static DF_CTLWINDOW *AssociatedControl(DF_DBOX *, enum DfCommands);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
static BOOL SysMenuOpen;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
static DF_DBOX **dbs = NULL;
|
2000-03-05 19:58:08 +00:00
|
|
|
static int dbct = 0;
|
|
|
|
|
|
|
|
/* --- clear all heap allocations to control text fields --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfClearDialogBoxes(void)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < dbct; i++)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = (*(dbs+i))->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
while (ct->class)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if ((ct->class == DF_EDITBOX ||
|
|
|
|
ct->class == DF_COMBOBOX) &&
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->itext != NULL)
|
|
|
|
{
|
|
|
|
free(ct->itext);
|
|
|
|
}
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dbs != NULL)
|
|
|
|
{
|
|
|
|
free(dbs);
|
|
|
|
dbs = NULL;
|
|
|
|
}
|
|
|
|
dbct = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* -------- DFM_CREATE_WINDOW Message --------- */
|
|
|
|
static int CreateWindowMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db = wnd->extension;
|
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
DFWINDOW cwnd;
|
|
|
|
int rtn, i;
|
|
|
|
/* ---- build a table of processed dialog boxes ---- */
|
|
|
|
for (i = 0; i < dbct; i++)
|
|
|
|
if (db == dbs[i])
|
|
|
|
break;
|
|
|
|
if (i == dbct) {
|
2003-06-19 02:48:13 +00:00
|
|
|
dbs = DfRealloc(dbs, sizeof(DF_DBOX *) * (dbct+1));
|
2000-03-05 19:58:08 +00:00
|
|
|
*(dbs + dbct++) = db;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
rtn = DfBaseWndProc(DF_DIALOG, wnd, DFM_CREATE_WINDOW, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
ct = db->ctl;
|
|
|
|
while (ct->class) {
|
|
|
|
int attrib = 0;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfTestAttribute(wnd, DF_NOCLIP))
|
|
|
|
attrib |= DF_NOCLIP;
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->Modal)
|
2003-06-19 02:48:13 +00:00
|
|
|
attrib |= DF_SAVESELF;
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->setting = ct->isetting;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class == DF_EDITBOX && ct->dwnd.h > 1)
|
|
|
|
attrib |= (DF_MULTILINE | DF_HASBORDER);
|
|
|
|
else if ((ct->class == DF_LISTBOX || ct->class == DF_TEXTBOX) &&
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->dwnd.h > 2)
|
2003-06-19 02:48:13 +00:00
|
|
|
attrib |= DF_HASBORDER;
|
|
|
|
cwnd = DfDfCreateWindow(ct->class,
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->dwnd.title,
|
2003-06-19 02:48:13 +00:00
|
|
|
ct->dwnd.x+DfGetClientLeft(wnd),
|
|
|
|
ct->dwnd.y+DfGetClientTop(wnd),
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->dwnd.h,
|
|
|
|
ct->dwnd.w,
|
|
|
|
ct,
|
|
|
|
wnd,
|
|
|
|
ControlProc,
|
|
|
|
attrib);
|
2003-06-19 02:48:13 +00:00
|
|
|
if ((ct->class == DF_EDITBOX ||
|
|
|
|
ct->class == DF_COMBOBOX) &&
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->itext != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(cwnd, DFM_SETTEXT, (DF_PARAM) ct->itext, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* -------- DFM_LEFT_BUTTON Message --------- */
|
|
|
|
static BOOL LeftButtonMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db = wnd->extension;
|
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
|
|
|
if (DfWindowSizing || DfWindowMoving)
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfHitControlBox(wnd, p1-DfGetLeft(wnd), p2-DfGetTop(wnd))) {
|
|
|
|
DfPostMessage(wnd, DFM_KEYBOARD, ' ', DF_ALTKEY);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
while (ct->class) {
|
|
|
|
DFWINDOW cwnd = ct->wnd;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class == DF_COMBOBOX) {
|
|
|
|
if (p2 == DfGetTop(cwnd)) {
|
|
|
|
if (p1 == DfGetRight(cwnd)+1) {
|
|
|
|
DfSendMessage(cwnd, DFM_LEFT_BUTTON, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(DfInFocus) == DF_LISTBOX)
|
|
|
|
DfSendMessage(wnd, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
else if (ct->class == DF_SPINBUTTON) {
|
|
|
|
if (p2 == DfGetTop(cwnd)) {
|
|
|
|
if (p1 == DfGetRight(cwnd)+1 ||
|
|
|
|
p1 == DfGetRight(cwnd)+2) {
|
|
|
|
DfSendMessage(cwnd, DFM_LEFT_BUTTON, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* -------- DFM_KEYBOARD Message --------- */
|
|
|
|
static BOOL KeyboardMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db = wnd->extension;
|
|
|
|
DF_CTLWINDOW *ct;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfWindowMoving || DfWindowSizing)
|
2000-03-05 19:58:08 +00:00
|
|
|
return FALSE;
|
|
|
|
switch ((int)p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_F1:
|
|
|
|
ct = DfGetControl(DfInFocus);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfDisplayHelp(wnd, ct->help))
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_SHIFT_HT:
|
|
|
|
case DF_BS:
|
|
|
|
case DF_UP:
|
2000-03-05 19:58:08 +00:00
|
|
|
PrevFocus(db);
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ALT_F6:
|
2000-03-05 19:58:08 +00:00
|
|
|
case '\t':
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_FWD:
|
|
|
|
case DF_DN:
|
2000-03-05 19:58:08 +00:00
|
|
|
NextFocus(db);
|
|
|
|
break;
|
|
|
|
case ' ':
|
2003-06-19 02:48:13 +00:00
|
|
|
if (((int)p2 & DF_ALTKEY) &&
|
|
|
|
DfTestAttribute(wnd, DF_CONTROLBOX)) {
|
2000-03-05 19:58:08 +00:00
|
|
|
SysMenuOpen = TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
DfBuildSystemMenu(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_CTRL_F4:
|
|
|
|
case DF_ESC:
|
|
|
|
DfSendMessage(wnd, DFM_COMMAND, DF_ID_CANCEL, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* ------ search all the shortcut keys ----- */
|
|
|
|
dbShortcutKeys(db, (int) p1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return wnd->Modal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------- COMMAND Message --------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static BOOL CommandMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db = wnd->extension;
|
2000-03-05 19:58:08 +00:00
|
|
|
switch ((int) p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_OK:
|
|
|
|
case DF_ID_CANCEL:
|
2000-03-05 19:58:08 +00:00
|
|
|
if ((int)p2 != 0)
|
|
|
|
return TRUE;
|
|
|
|
wnd->ReturnCode = (int) p1;
|
|
|
|
if (wnd->Modal)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfPostMessage(wnd, DFM_ENDDIALOG, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_CLOSE_WINDOW, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ID_HELP:
|
2000-03-05 19:58:08 +00:00
|
|
|
if ((int)p2 != 0)
|
|
|
|
return TRUE;
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfDisplayHelp(wnd, db->HelpName);
|
2000-03-05 19:58:08 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ----- window-processing module, DF_DIALOG window class ----- */
|
|
|
|
int DfDialogProc(DFWINDOW wnd, DFMESSAGE msg, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
int rtn;
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db = wnd->extension;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
switch (msg) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CREATE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
return CreateWindowMsg(wnd, p1, p2);
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_SHIFT_CHANGED:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->Modal)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_LEFT_BUTTON:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (LeftButtonMsg(wnd, p1, p2))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_KEYBOARD:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (KeyboardMsg(wnd, p1, p2))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CLOSE_POPDOWN:
|
2000-03-05 19:58:08 +00:00
|
|
|
SysMenuOpen = FALSE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_LB_SELECTION:
|
|
|
|
case DFM_LB_CHOOSE:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (SysMenuOpen)
|
|
|
|
return TRUE;
|
|
|
|
DfSendMessage(wnd, DFM_COMMAND, inFocusCommand(db), msg);
|
|
|
|
break;
|
|
|
|
case DFM_COMMAND:
|
|
|
|
if (CommandMsg(wnd, p1, p2))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_PAINT:
|
2000-03-05 19:58:08 +00:00
|
|
|
p2 = TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_MOVE:
|
|
|
|
case DFM_DFM_SIZE:
|
|
|
|
rtn = DfBaseWndProc(DF_DIALOG, wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->dfocus != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd->dfocus, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return rtn;
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CLOSE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (!p1)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(wnd, DFM_COMMAND, DF_ID_CANCEL, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfBaseWndProc(DF_DIALOG, wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- create and execute a dialog box ---------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
BOOL DfDialogBox(DFWINDOW wnd, DF_DBOX *db, BOOL Modal,
|
|
|
|
int (*wndproc)(struct DfWindow *, enum DfMessages, DF_PARAM, DF_PARAM))
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
|
|
|
BOOL rtn;
|
|
|
|
int x = db->dwnd.x, y = db->dwnd.y;
|
|
|
|
DFWINDOW DialogWnd;
|
|
|
|
|
|
|
|
if (!Modal && wnd != NULL)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
x += DfGetLeft(wnd);
|
|
|
|
y += DfGetTop(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
DialogWnd = DfDfCreateWindow(DF_DIALOG,
|
2000-03-05 19:58:08 +00:00
|
|
|
db->dwnd.title,
|
|
|
|
x, y,
|
|
|
|
db->dwnd.h,
|
|
|
|
db->dwnd.w,
|
|
|
|
db,
|
|
|
|
wnd,
|
|
|
|
wndproc,
|
2003-06-19 02:48:13 +00:00
|
|
|
Modal ? DF_SAVESELF : 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
DialogWnd->Modal = Modal;
|
|
|
|
FirstFocus(db);
|
2003-06-19 02:48:13 +00:00
|
|
|
DfPostMessage(DialogWnd, DFM_INITIATE_DIALOG, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (Modal)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(DialogWnd, DFM_CAPTURE_MOUSE, 0, 0);
|
|
|
|
DfSendMessage(DialogWnd, DFM_CAPTURE_KEYBOARD, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
while (DfDispatchMessage ())
|
|
|
|
;
|
2003-06-19 02:48:13 +00:00
|
|
|
rtn = DialogWnd->ReturnCode == DF_ID_OK;
|
|
|
|
DfSendMessage(DialogWnd, DFM_RELEASE_MOUSE, 0, 0);
|
|
|
|
DfSendMessage(DialogWnd, DFM_RELEASE_KEYBOARD, 0, 0);
|
|
|
|
DfSendMessage(DialogWnd, DFM_CLOSE_WINDOW, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return rtn;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- return command code of in-focus control window ---- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static int inFocusCommand(DF_DBOX *db)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
while (ct->class) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->wnd == DfInFocus)
|
2000-03-05 19:58:08 +00:00
|
|
|
return ct->command;
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------- find a specified control structure ------- */
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *DfFindCommand(DF_DBOX *db, enum DfCommands cmd, int class)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
while (ct->class)
|
|
|
|
{
|
|
|
|
if (ct->class == class)
|
|
|
|
if (cmd == ct->command)
|
|
|
|
return ct;
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- return the window handle of a specified command ---- */
|
2003-06-19 02:48:13 +00:00
|
|
|
DFWINDOW DfControlWindow(DF_DBOX *db, enum DfCommands cmd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
while (ct->class)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class != DF_TEXT && cmd == ct->command)
|
2000-03-05 19:58:08 +00:00
|
|
|
return ct->wnd;
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --- return a pointer to the control structure that matches a window --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *WindowControl(DF_DBOX *db, DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
while (ct->class)
|
|
|
|
{
|
|
|
|
if (ct->wnd == wnd)
|
|
|
|
return ct;
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ---- set a control DF_ON or DF_OFF ----- */
|
|
|
|
void DfControlSetting(DF_DBOX *db, enum DfCommands cmd,
|
2000-03-05 19:58:08 +00:00
|
|
|
int class, int setting)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(db, cmd, class);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL) {
|
|
|
|
ct->isetting = setting;
|
|
|
|
if (ct->wnd != NULL)
|
|
|
|
ct->setting = setting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- return pointer to the text of a control window ---- */
|
2003-06-19 02:48:13 +00:00
|
|
|
char *DfGetDlgTextString(DF_DBOX *db,enum DfCommands cmd,DFCLASS class)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(db, cmd, class);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL)
|
|
|
|
return ct->itext;
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- set the text of a control specification ------ */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfSetDlgTextString(DF_DBOX *db, enum DfCommands cmd,
|
2000-03-05 19:58:08 +00:00
|
|
|
char *text, DFCLASS class)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(db, cmd, class);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL) {
|
2003-06-19 02:48:13 +00:00
|
|
|
ct->itext = DfRealloc(ct->itext, strlen(text)+1);
|
2000-03-05 19:58:08 +00:00
|
|
|
strcpy(ct->itext, text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- set the text of a control window ------ */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfPutItemText(DFWINDOW wnd, enum DfCommands cmd, char *text)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(wnd->extension, cmd, DF_EDITBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_TEXTBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_COMBOBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_LISTBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_SPINBUTTON);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_TEXT);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL) {
|
|
|
|
DFWINDOW cwnd = (DFWINDOW) (ct->wnd);
|
|
|
|
switch (ct->class) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_COMBOBOX:
|
|
|
|
case DF_EDITBOX:
|
|
|
|
DfSendMessage(cwnd, DFM_CLEARTEXT, 0, 0);
|
|
|
|
DfSendMessage(cwnd, DFM_ADDTEXT, (DF_PARAM) text, 0);
|
|
|
|
if (!DfIsMultiLine(cwnd))
|
|
|
|
DfSendMessage(cwnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_LISTBOX:
|
|
|
|
case DF_TEXTBOX:
|
|
|
|
case DF_SPINBUTTON:
|
|
|
|
DfSendMessage(cwnd, DFM_ADDTEXT, (DF_PARAM) text, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_TEXT: {
|
|
|
|
DfSendMessage(cwnd, DFM_CLEARTEXT, 0, 0);
|
|
|
|
DfSendMessage(cwnd, DFM_ADDTEXT, (DF_PARAM) text, 0);
|
|
|
|
DfSendMessage(cwnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- get the text of a control window ------ */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfGetItemText(DFWINDOW wnd, enum DfCommands cmd,
|
2000-03-05 19:58:08 +00:00
|
|
|
char *text, int len)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(wnd->extension, cmd, DF_EDITBOX);
|
2005-05-11 16:50:39 +00:00
|
|
|
char *cp;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_COMBOBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_TEXTBOX);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct == NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
ct = DfFindCommand(wnd->extension, cmd, DF_TEXT);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL) {
|
|
|
|
DFWINDOW cwnd = (DFWINDOW) (ct->wnd);
|
|
|
|
if (cwnd != NULL) {
|
|
|
|
switch (ct->class) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_TEXT:
|
|
|
|
if (DfGetText(cwnd) != NULL) {
|
|
|
|
cp = strchr(DfGetText(cwnd), '\n');
|
2000-03-05 19:58:08 +00:00
|
|
|
if (cp != NULL)
|
2003-06-19 02:48:13 +00:00
|
|
|
len = (int) (cp - DfGetText(cwnd));
|
|
|
|
strncpy(text, DfGetText(cwnd), len);
|
2000-03-05 19:58:08 +00:00
|
|
|
*(text+len) = '\0';
|
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_TEXTBOX:
|
|
|
|
if (DfGetText(cwnd) != NULL)
|
|
|
|
strncpy(text, DfGetText(cwnd), len);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_COMBOBOX:
|
|
|
|
case DF_EDITBOX:
|
|
|
|
DfSendMessage(cwnd,DFM_GETTEXT,(DF_PARAM)text,len);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------- set the text of a listbox control window ------ */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfGetDlgListText(DFWINDOW wnd, char *text, enum DfCommands cmd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfFindCommand(wnd->extension, cmd, DF_LISTBOX);
|
|
|
|
int sel = DfSendMessage(ct->wnd, DFM_LB_CURRENTSELECTION, 0, 0);
|
|
|
|
DfSendMessage(ct->wnd, DFM_LB_GETTEXT, (DF_PARAM) text, sel);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -- find control structure associated with text control -- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static DF_CTLWINDOW *AssociatedControl(DF_DBOX *db,enum DfCommands Tcmd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
while (ct->class) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class != DF_TEXT)
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct->command == Tcmd)
|
|
|
|
break;
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
return ct;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --- process dialog box shortcut keys --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void dbShortcutKeys(DF_DBOX *db, int ky)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct;
|
|
|
|
int ch = DfAltConvert(ky);
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
if (ch != 0) {
|
|
|
|
ct = db->ctl;
|
|
|
|
while (ct->class) {
|
|
|
|
char *cp = ct->itext;
|
|
|
|
while (cp && *cp) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (*cp == DF_SHORTCUTCHAR &&
|
2000-03-05 19:58:08 +00:00
|
|
|
tolower(*(cp+1)) == ch) {
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class == DF_TEXT)
|
2000-03-05 19:58:08 +00:00
|
|
|
ct = AssociatedControl(db, ct->command);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class == DF_RADIOBUTTON)
|
|
|
|
DfSetRadioButton(db, ct);
|
|
|
|
else if (ct->class == DF_CHECKBOX) {
|
|
|
|
ct->setting ^= DF_ON;
|
|
|
|
DfSendMessage(ct->wnd, DFM_PAINT, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
else if (ct->class) {
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(ct->wnd, DFM_SETFOCUS, TRUE, 0);
|
|
|
|
if (ct->class == DF_BUTTON)
|
|
|
|
DfSendMessage(ct->wnd,DFM_KEYBOARD,'\r',0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cp++;
|
|
|
|
}
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --- dynamically add or remove scroll bars
|
|
|
|
from a control window ---- */
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfSetScrollBars(DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
int oldattr = DfGetAttribute(wnd);
|
|
|
|
if (wnd->wlines > DfClientHeight(wnd))
|
|
|
|
DfAddAttribute(wnd, DF_VSCROLLBAR);
|
2005-05-07 21:24:31 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearAttribute(wnd, DF_VSCROLLBAR);
|
|
|
|
if (wnd->textwidth > DfClientWidth(wnd))
|
|
|
|
DfAddAttribute(wnd, DF_HSCROLLBAR);
|
2005-05-07 21:24:31 +00:00
|
|
|
else
|
2003-06-19 02:48:13 +00:00
|
|
|
DfClearAttribute(wnd, DF_HSCROLLBAR);
|
|
|
|
if (DfGetAttribute(wnd) != oldattr)
|
|
|
|
DfSendMessage(wnd, DFM_BORDER, 0, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ------- DFM_CREATE_WINDOW Message (Control) ----- */
|
2000-03-05 19:58:08 +00:00
|
|
|
static void CtlCreateWindowMsg(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct;
|
2000-03-05 19:58:08 +00:00
|
|
|
ct = wnd->ct = wnd->extension;
|
|
|
|
wnd->extension = NULL;
|
|
|
|
if (ct != NULL)
|
|
|
|
ct->wnd = wnd;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ------- DFM_KEYBOARD Message (Control) ----- */
|
|
|
|
static BOOL CtlKeyboardMsg(DFWINDOW wnd, DF_PARAM p1, DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfGetControl(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
switch ((int) p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_F1:
|
|
|
|
if (DfWindowMoving || DfWindowSizing)
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (!DfDisplayHelp(wnd, ct->help))
|
|
|
|
DfSendMessage(DfGetParent(wnd),DFM_COMMAND,DF_ID_HELP,0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
case ' ':
|
2003-06-19 02:48:13 +00:00
|
|
|
if (!((int)p2 & DF_ALTKEY))
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_ALT_F6:
|
|
|
|
case DF_CTRL_F4:
|
|
|
|
case DF_ALT_F4:
|
|
|
|
DfPostMessage(DfGetParent(wnd), DFM_KEYBOARD, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(wnd) == DF_EDITBOX)
|
|
|
|
if (DfIsMultiLine(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
return FALSE;
|
|
|
|
switch ((int) p1) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_UP:
|
|
|
|
if (!DfIsDerivedFrom(wnd, DF_LISTBOX)) {
|
|
|
|
p1 = DF_CTRL_FIVE;
|
|
|
|
p2 = DF_LEFTSHIFT;
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_BS:
|
|
|
|
if (!DfIsDerivedFrom(wnd, DF_EDITBOX)) {
|
|
|
|
p1 = DF_CTRL_FIVE;
|
|
|
|
p2 = DF_LEFTSHIFT;
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_DN:
|
|
|
|
if (!DfIsDerivedFrom(wnd, DF_LISTBOX) &&
|
|
|
|
!DfIsDerivedFrom(wnd, DF_COMBOBOX))
|
2000-03-05 19:58:08 +00:00
|
|
|
p1 = '\t';
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DF_FWD:
|
|
|
|
if (!DfIsDerivedFrom(wnd, DF_EDITBOX))
|
2000-03-05 19:58:08 +00:00
|
|
|
p1 = '\t';
|
|
|
|
break;
|
|
|
|
case '\r':
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfIsDerivedFrom(wnd, DF_EDITBOX))
|
|
|
|
if (DfIsMultiLine(wnd))
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfIsDerivedFrom(wnd, DF_BUTTON))
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(DfGetParent(wnd), DFM_COMMAND, DF_ID_OK, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
/* ------- DFM_CLOSE_WINDOW Message (Control) ----- */
|
2000-03-05 19:58:08 +00:00
|
|
|
static void CtlCloseWindowMsg(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = DfGetControl(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL) {
|
|
|
|
ct->wnd = NULL;
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetParent(wnd)->ReturnCode == DF_ID_OK) {
|
|
|
|
if (ct->class == DF_EDITBOX || ct->class == DF_COMBOBOX) {
|
2000-03-05 19:58:08 +00:00
|
|
|
if (wnd->TextChanged) {
|
2003-06-19 02:48:13 +00:00
|
|
|
ct->itext=DfRealloc(ct->itext,strlen(wnd->text)+1);
|
2000-03-05 19:58:08 +00:00
|
|
|
strcpy(ct->itext, wnd->text);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (!DfIsMultiLine(wnd)) {
|
2000-03-05 19:58:08 +00:00
|
|
|
char *cp = ct->itext+strlen(ct->itext)-1;
|
|
|
|
if (*cp == '\n')
|
|
|
|
*cp = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
else if (ct->class == DF_RADIOBUTTON || ct->class == DF_CHECKBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
ct->isetting = ct->setting;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void FixColors(DFWINDOW wnd)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = wnd->ct;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class != DF_BUTTON)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (ct->class != DF_SPINBUTTON && ct->class != DF_COMBOBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2005-05-07 21:24:31 +00:00
|
|
|
wnd->WindowColors[DF_FRAME_COLOR][DF_FG] =
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetParent(wnd)->WindowColors[DF_FRAME_COLOR][DF_FG];
|
2005-05-07 21:24:31 +00:00
|
|
|
wnd->WindowColors[DF_FRAME_COLOR][DF_BG] =
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetParent(wnd)->WindowColors[DF_FRAME_COLOR][DF_BG];
|
|
|
|
if (ct->class != DF_EDITBOX && ct->class != DF_LISTBOX)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2005-05-07 21:24:31 +00:00
|
|
|
wnd->WindowColors[DF_STD_COLOR][DF_FG] =
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetParent(wnd)->WindowColors[DF_STD_COLOR][DF_FG];
|
2005-05-07 21:24:31 +00:00
|
|
|
wnd->WindowColors[DF_STD_COLOR][DF_BG] =
|
2003-06-19 02:48:13 +00:00
|
|
|
DfGetParent(wnd)->WindowColors[DF_STD_COLOR][DF_BG];
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* -- generic window processor used by dialog box controls -- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static int ControlProc(DFWINDOW wnd,DFMESSAGE msg,DF_PARAM p1,DF_PARAM p2)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_DBOX *db;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
if (wnd == NULL)
|
|
|
|
return FALSE;
|
2003-06-19 02:48:13 +00:00
|
|
|
db = DfGetParent(wnd) ? DfGetParent(wnd)->extension : NULL;
|
2000-03-05 19:58:08 +00:00
|
|
|
|
|
|
|
switch (msg) {
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CREATE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
CtlCreateWindowMsg(wnd);
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_KEYBOARD:
|
2000-03-05 19:58:08 +00:00
|
|
|
if (CtlKeyboardMsg(wnd, p1, p2))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_PAINT:
|
2000-03-05 19:58:08 +00:00
|
|
|
FixColors(wnd);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(wnd) == DF_EDITBOX ||
|
|
|
|
DfGetClass(wnd) == DF_LISTBOX ||
|
|
|
|
DfGetClass(wnd) == DF_TEXTBOX)
|
|
|
|
DfSetScrollBars(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_BORDER:
|
2000-03-05 19:58:08 +00:00
|
|
|
FixColors(wnd);
|
2003-06-19 02:48:13 +00:00
|
|
|
if (DfGetClass(wnd) == DF_EDITBOX) {
|
|
|
|
DFWINDOW oldFocus = DfInFocus;
|
|
|
|
DfInFocus = NULL;
|
|
|
|
DfDefaultWndProc(wnd, msg, p1, p2);
|
|
|
|
DfInFocus = oldFocus;
|
2000-03-05 19:58:08 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_SETFOCUS: {
|
|
|
|
DFWINDOW pwnd = DfGetParent(wnd);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (p1)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
if (pwnd != NULL)
|
|
|
|
{
|
|
|
|
pwnd->dfocus = wnd;
|
|
|
|
DfSendMessage(pwnd, DFM_COMMAND,
|
2003-06-19 02:48:13 +00:00
|
|
|
inFocusCommand(db), DFM_ENTERFOCUS);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
DfSendMessage(pwnd, DFM_COMMAND,
|
2003-06-19 02:48:13 +00:00
|
|
|
inFocusCommand(db), DFM_LEAVEFOCUS);
|
2000-03-05 19:58:08 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
case DFM_CLOSE_WINDOW:
|
2000-03-05 19:58:08 +00:00
|
|
|
CtlCloseWindowMsg(wnd);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
return DfDefaultWndProc(wnd, msg, p1, p2);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- change the focus to the first control --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void FirstFocus(DF_DBOX *db)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = db->ctl;
|
2000-03-05 19:58:08 +00:00
|
|
|
if (ct != NULL)
|
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
while (ct->class == DF_TEXT || ct->class == DF_BOX) {
|
2000-03-05 19:58:08 +00:00
|
|
|
ct++;
|
|
|
|
if (ct->class == 0)
|
|
|
|
return;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(ct->wnd, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- change the focus to the next control --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void NextFocus(DF_DBOX *db)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = WindowControl(db, DfInFocus);
|
2000-03-05 19:58:08 +00:00
|
|
|
int looped = 0;
|
|
|
|
if (ct != NULL)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
ct++;
|
|
|
|
if (ct->class == 0)
|
|
|
|
{
|
|
|
|
if (looped)
|
|
|
|
return;
|
|
|
|
looped++;
|
|
|
|
ct = db->ctl;
|
|
|
|
}
|
2003-06-19 02:48:13 +00:00
|
|
|
} while (ct->class == DF_TEXT || ct->class == DF_BOX);
|
|
|
|
DfSendMessage(ct->wnd, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ---- change the focus to the previous control --- */
|
2003-06-19 02:48:13 +00:00
|
|
|
static void PrevFocus(DF_DBOX *db)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DF_CTLWINDOW *ct = WindowControl(db, DfInFocus);
|
2000-03-05 19:58:08 +00:00
|
|
|
int looped = 0;
|
|
|
|
if (ct != NULL)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (ct == db->ctl)
|
|
|
|
{
|
|
|
|
if (looped)
|
|
|
|
return;
|
|
|
|
looped++;
|
|
|
|
while (ct->class)
|
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
--ct;
|
2003-06-19 02:48:13 +00:00
|
|
|
} while (ct->class == DF_TEXT || ct->class == DF_BOX);
|
|
|
|
DfSendMessage(ct->wnd, DFM_SETFOCUS, TRUE, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-19 02:48:13 +00:00
|
|
|
void DfSetFocusCursor(DFWINDOW wnd)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
if (wnd == DfInFocus)
|
2000-03-05 19:58:08 +00:00
|
|
|
{
|
2003-06-19 02:48:13 +00:00
|
|
|
DfSendMessage(NULL, DFM_SHOW_CURSOR, 0, 0);
|
|
|
|
DfSendMessage(wnd, DFM_KEYBOARD_CURSOR, 1, 0);
|
2000-03-05 19:58:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|