home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 18 REXX
/
18-REXX.zip
/
dwnvprx.lzh
/
DWNVPRX.C
< prev
next >
Wrap
Text File
|
1995-05-02
|
5KB
|
148 lines
/* REXX extension DLL to allow VisPro REXX to manipulate
PM controls in other ways than supplied with the VisPro REXX
product.
Copyright (C) 1995, David W. Noon */
#define INCL_WINMESSAGEMGR
#define INCL_WINENTRYFIELDS
#define INCL_WINMLE
#define INCL_DOSMISC
#include <os2.h>
#define INCL_REXXFUNC
#include <rexxsaa.h>
#include <stdlib.h>
#include <string.h>
/* Inserts for the error message:
VPRX0001E Incorrect number of arguments passed. Should be %1.
where %1 gets replaced by the insert string. */
static PCHAR Arg_insert[2] = {"2","3"};
/* Inserts for the error message:
VPRX0003E The %1 argmuent is not an unsigned integer.
where %1 gets replaced by the insert string. */
static PCHAR Uint_insert[2] = {"second","third"};
/* The entry point DwnSetTextLimit() should be called from a REXX exec
by passing 2 arguments. The first should be the handle of the
entry field control to which the EM_SETTEXTLIMIT message is to be
sent. The second is an unsigned integer value representing the
maximum size of input field the control is to accept.
The return value is a Boolean (0=FALSE, 1=TRUE) as returned
by the control.
For example:
CALL DwnSetTextLimit VpItem(window,'EFIELD','GETHANDLE'),25
This will set the control labelled EFIELD to accept a maximum of 25
characters of input.
*/
ULONG APIENTRY DwnSetTextLimit(PUCHAR Function_name, ULONG argc,
RXSTRING argv[], PSZ Queue_name, PRXSTRING Ret_str)
{
MRESULT mrc;
if (argc != 2UL)
{
/* Incorrect number of arguments */
DosGetMessage(&Arg_insert[0],1UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),1UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else if (RXSTRLEN(argv[0]) > 10 ||
strspn(RXSTRPTR(argv[0]),"0123456789") != RXSTRLEN(argv[0]))
{
/* First argument is not a handle */
DosGetMessage(NULL,0UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),2UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else if (strspn(RXSTRPTR(argv[1]),"0123456789") != RXSTRLEN(argv[1]))
{
/* Second argument is not an unsigned number */
DosGetMessage(&Uint_insert[0],1UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),3UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else
{
/* Send the resize message to the entry field control */
mrc = WinSendMsg((HWND)strtoul(RXSTRPTR(argv[0]),NULL,10),EM_SETTEXTLIMIT,
MPFROMLONG(atol(RXSTRPTR(argv[1]))),MPFROMSHORT(0));
/* Now format the return code */
ultoa((ULONG)mrc,RXSTRPTR(*Ret_str),10);
Ret_str->strlength = strlen(RXSTRPTR(*Ret_str));
}
return 0UL;
}
/* The entry point DwnSetSel() should be called from a REXX exec
by passing 3 arguments. The first should be the handle of the
entry field control to which the MLM_SETSEL message is to be
sent. The second is an unsigned integer value representing the
anchor point at which text selection is to begin. The third is
the cursor point at which the text selection is to end. If the
anchor point and the cursor point are equal, it simply repositions
the cursor to that point, with no text selected.
The return value is a Boolean (0=FALSE, 1=TRUE) as returned by
the control.
For example:
CALL DwnSetSel VpItem(window,'EDITBOX','GETHANDLE'),0,0
This will position the cursor in the MLE control labelled EDITBOX
at the top-left corner.
*/
ULONG APIENTRY DwnSetSel(PUCHAR Function_name, ULONG argc,
RXSTRING argv[], PSZ Queue_name, PRXSTRING Ret_str)
{
MRESULT mrc;
if (argc != 3UL)
{
/* Incorrect number of arguments */
DosGetMessage(&Arg_insert[1],1UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),1UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else if (RXSTRLEN(argv[0]) > 10 ||
strspn(RXSTRPTR(argv[0]),"0123456789") != RXSTRLEN(argv[0]))
{
/* First argument is not a handle */
DosGetMessage(NULL,0UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),2UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else if (strspn(RXSTRPTR(argv[1]),"0123456789") != RXSTRLEN(argv[1]))
{
/* Second argument is not an unsigned number */
DosGetMessage(&Uint_insert[0],1UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),3UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else if (strspn(RXSTRPTR(argv[2]),"0123456789") != RXSTRLEN(argv[2]))
{
/* Third argument is not an unsigned number */
DosGetMessage(&Uint_insert[1],1UL,RXSTRPTR(*Ret_str),RXSTRLEN(*Ret_str),3UL,
"DWNVPRX.MSG",&(Ret_str->strlength));
}
else
{
/* Send the text selection message to the multi-line entry field control */
mrc = WinSendMsg((HWND)strtoul(RXSTRPTR(argv[0]),NULL,10),MLM_SETSEL,
MPFROMLONG(atol(RXSTRPTR(argv[1]))),
MPFROMLONG(atol(RXSTRPTR(argv[2]))));
/* Now format the return code */
ultoa((ULONG)mrc,RXSTRPTR(*Ret_str),10);
Ret_str->strlength = strlen(RXSTRPTR(*Ret_str));
}
return 0UL;
}