home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 4
/
BUGCD1997_05.BIN
/
aplic
/
clip4win
/
clip4win.exe
/
C4W30E.HUF
/
SOURCE
/
MEMOEDIT.PRG
< prev
next >
Wrap
Text File
|
1994-06-22
|
4KB
|
129 lines
/////////////////////////
//
// memoedit.prg - alternative MEMOEDIT() function using an edit control
//
// Written by: John M. Skelton, 12-May-93.
//
// Copyright (C) 1993 Skelton Software, Kendal Cottage, Hillam, Leeds LS25 5HP, UK.
// All Rights Reserved.
//
/////////////////////////
/*
* You can define C4W_V1 to get the version 1 behaviour.
*/
//#define C4W_V1
#ifndef C4W_V1
#define WIN_WANT_ALL
#endif // C4W_V1
#include "windows.ch"
#ifdef C4W_V1
#define IDD_EDIT "edit"
#define IDD_OK "ok"
#define IDD_CANCEL "cancel"
#else // C4W_V1
#define IDD_EDIT 500 // avoid internal values (which start at 100)
#define IDD_OK IDOK
#define IDD_CANCEL IDCANCEL
#endif // C4W_V1
function memoedit(cText)
local aDlg, cRet
#ifndef C4W_V1
local hFocus := GetFocus()
#endif // C4W_V1
aDlg = CreateDialog("Memo Edit", ;
WS_CAPTION + WS_SYSMENU + WS_GROUP + WS_TABSTOP ;
+ WS_THICKFRAME + WS_VISIBLE + WS_POPUP, ;
50, 30, 250, 165)
aDlg = AppendDialog(aDlg, IDD_EDIT, DLG_EDIT, ;
ES_LEFT + ES_MULTILINE + ES_NOHIDESEL ;
+ ES_AUTOVSCROLL + ES_AUTOHSCROLL + ES_WANTRETURN ;
+ WS_VSCROLL + WS_HSCROLL + WS_BORDER + WS_TABSTOP ;
+ WS_CHILD + WS_VISIBLE, ;
10, 10, 230, 120, ;
cText)
#ifdef C4W_V1
aDlg = AppendDialog(aDlg, IDD_OK, DLG_BUTTON, ;
BS_DEFPUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ;
50, 140, 50, 15, ;
"&Ok")
aDlg = AppendDialog(aDlg, IDD_CANCEL, DLG_BUTTON, ;
BS_PUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ;
150, 140, 50, 15, ;
"&Cancel")
if ModalDialog(aDlg) = 0 .or. GetDialogResult(aDlg, "cancel") = .T.
cRet = cText
else
cRet = GetDialogResult(aDlg, "edit")
endif
return cRet
#else // C4W_V1
aDlg = AppendDialog(aDlg, IDD_OK, DLG_BUTTON, ;
BS_DEFPUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ;
50, 145, 50, 15, ;
"&Ok")
aDlg = AppendDialog(aDlg, IDD_CANCEL, DLG_BUTTON, ;
BS_PUSHBUTTON + WS_TABSTOP + WS_CHILD + WS_VISIBLE, ;
150, 145, 50, 15, ;
"&Cancel")
aDlg = AppendDialog(aDlg, -1, DLG_STATIC, ;
SS_CENTER + WS_CHILD + WS_VISIBLE, ;
50, 133, 150, 10, ;
"For Tab press Control-Tab")
/*
* Note: ModalDialog() returns 0 if cancelled, e.g. by Esc or
* if EndDialog() is used with IDCANCEL
*/
if ModalDialog(aDlg, , , ;
{|hDlg, nMsg, nwParam, nlParam| ;
Dlg(hDlg, nMsg, nwParam, nlParam, @cText)}) == 0
// cancelled
cRet = cText
else
cRet = cText
endif
SetFocus(hFocus)
return cRet
#define MAKELPARAM(nLow, nHigh) ((nLow) + (nHigh) * 65536)
static function Dlg(hDlg, nMsg, nwParam, nlParam, cText)
local hEdit
do case
case nMsg == WM_INITDIALOG
// Nothing much needed: the edit control is first and has WS_TABSTOP,
// so it will automatically get the input focus.
// Let's allow rather large strings (maybe you should WinExec() an
// editor!)...
hEdit = GetDlgItem(hDlg, IDD_EDIT)
SendMessage(hEdit, EM_LIMITTEXT, 0, 0) // & see edit.prg
// ... and deselect the text (not sure why SendMessage() doesn't work!)
PostMessage(hEdit, EM_SETSEL, 0, 0)
// the SendMessage() above could be:
// SendDlgItemMessage(hDlg, IDD_EDIT, EM_LIMITTEXT, 0, 0)
case nMsg == WM_COMMAND
do case
case nwParam == IDD_OK .or. nwParam == IDD_CANCEL
if nwParam == IDD_OK
// see edit.prg for many Edit*() functions
cText = GetDlgItmText(hDlg, IDD_EDIT)
endif
EndDialog(hDlg, nwParam)
endcase
otherwise
return 0
endcase
return 1
#endif // C4W_V1