home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Hall of Fame
/
HallofFameCDROM.cdr
/
window
/
mewel12.lzh
/
CHANGES.DOC
< prev
next >
Wrap
Text File
|
1989-06-28
|
36KB
|
1,102 lines
CHANGES TO MEWEL 1.2
--------------------
This document details changes and additions which have been made to the
latest version of MEWEL. These changes have *not* been included in the
regular users manual.
One of the goals of enhancing MEWEL is to further increase the compatability
between MEWEL apps and Microsoft Windows apps. Some of these enhancements
have been done expressedly for this purpose.
*******************************************************************************
ADDITIONAL PARAMETER ADDED TO DIALOGCREATE()
--------------------------------------------
An additional parameter has been added to the end of the argument list for
DialogCreate(). The last argument is the identifier of the dialog box. The
prototype for DialogCreate() now looks like this :
HWND pascal DialogCreate(HWND hParent, int row1,int col1,int row2,int col2,
BYTE *title, WORD attr, WORD dlgflags,
BOOL (pascal *dlgfunc)(),
WORD id); <=============== new!
This change was done so that dialog boxes could be given control ids just
like any other windows.
*******************************************************************************
CreateWindow() ADDED
--------------------
Instead of using the various XXXCreate() functions to create a window of
a specific class (ie, EditCreate(), StaticCreate(), etc), you can now
use a single generic creation function - CreateWindow(). This is pretty
much the same CreateWindow() found in Microsoft Windows.
HWND pascal CreateWindow(char *szClass, char *szWindow, DWORD dwStyle,
WORD x, WORD y, WORD width, WORD height,
WORD attr, /* <- different from MS-WIndows */
WORD id, /* <- different from MS-WIndows */
HWND hParent, HMENU hMenu, WORD hInst,
DWORD lpParam)
This is a generic function for creating any type of window in MEWEL.
Parameters
szClass is the name of the window class. It can be a user-defined class
or one of the following predefined classes :
"NORMAL" "BUTTON" "EDIT" "LISTBOX" "SCROLLBAR"
"STATIC" "PUSHBUTTON" "CHECKBOX" "RADIOBUTTON" "TEXT"
"FRAME" "BOX"
szWIndow is the title of the window.
dwStyle are the style bits for the window (WIN_HAS_BORDER, etc).
x and y are the coordinates of the upper left corner of the winmdow.
width and height define the extent of the window.
attr is the color attribute of the window.
id is the control id of the window (especially important for controls).
hParent is the handle of the parent window, or NULLHWND if there is no parent.
hMenu is the handle of the associated menubar.
hInst must be 0 for now. This parameter is in their for MS-WINDOWS
compatability.
lpParam is a user-defined value. This value will be passed to the window
procedure when the window is created - the window procedure will receive a
WM_CREATE message with the value of lpParam passed in the lParam parameter.
Returns
The window handle of the created window if successful, NULLHWND if not.
*******************************************************************************
BETTER SUPPORT FOR USER-DEFINED CLASSES
---------------------------------------
We have increased the support for user defined window classes. We have
implemented the Microsoft Windows function RegisterClass(). To use this
function, you fill in a structure of type WNDCLASS and pass it as the
only argument to RegisterClass(). MEWEL will register your new class and
keep it in a global table of all classes. You can then pass the class name
as an argument to the CreateWindow() function when you want to create a
window of the new class.
The WNDCLASS struct is defined in WINDOW.H, but is repeated here:
typedef struct wndClass
{
struct wndClass *next; /* used internally by MEWEL */
DWORD dwStyle; /* style bits for the class */
int (pascal *pfnWndProc)(); /* the window proc for this class */
int (pascal *pfnDefWndProc)(); /* used internally by MEWEL */
int cbClsExtra; /* # of extra bytes for the class */
int cbWndExtra; /* # of window extra bytes per window */
char *szClassName; /* the name of the class */
char *szBaseClass; /* name of base class */
WORD idClass; /* used internally by MEWEL */
} WNDCLASS;
szBaseClass is the name of the class which the new class will be derived
from. For instance, if you want to make a new class of data entry fields
which only accept numeric input, then you would drive a new class from the
"EDIT" base class. Where does this base class come into play when you
subclass? Two times - when you create a window of the new class, the
creation procedure associated with the base class will be called (in the
example above, EditCreate would be called), and when you call DefWinProc(),
the default window procedure for the base class would be invoked.
int pascal RegisterClass(WNDCLASS *pWndClass)
Allows you to create your own window class. A window class has several
important properties associated with it, including the name of the class,
the default window procedure that all windows in this class will have,
style bits, and the number of bytes which will be allocated for the
window extra area for each window in the class.
Parameters
pWndClass is a pointer to a WNDCLASS structure. This structure is defined
is the file WINDOW.H. The following fields should be filled in by the
application program :
DWORD dwStyle; /* the class style bits */
int (pascal *pfnWndProc)(); /* default winproc for the class */
int cbWndExtra; /* # of bytes allocated for the window extra area */
char *szClassName; /* the name of the class */
char *szBaseClass; /* the name of the base class */
All other fields will be automatically filled in by the RegisterClass()
function.
Returns
TRUE if the class was registered, FALSE if not.
Example
extern int pascal MyClassProc();
WNDCLASS wndClass;
wndClass.szClassName = "MyClass";
wndClass.szCaseClass = "Edit";
wndClass.cbWndExtra = 0;
wndClass.dwStyle = 0L;
wndClass.pfnWndProc = MyClassProc;
if (!RegisterClass(&wndClass))
{
....... /* error */
}
******************************************************************************
WINDOW EXTRA BYTES NOW SUPPORTED
--------------------------------
Like Microsoft Windows, MEWEL now supports a per-window storage area which
your application programs can use to store per-window data. Each window which
you create has a pointer to an (possibly null) allocated block of memory
which your application program can manipulate. This area is known as the
"window extra bytes" area.
How much memory is allocated?
This is determined by the value of the cbWndExtra field in the window's
class structure. You fill this value in when you register a window class with
the RegisterClass() call.
All of the predefined window classes have zero (0) in the cbWndExtra field.
This means that if you create any kind of predefined class of window, no window
extra bytes are allocated to that window. You can allocate this area yourself
by using the SetWIndowExtra() function.
You can query or set a single byte value, a two byte value (WORD), or a four
byte value (LONG). There are six API functions corresponding to the six
operations you can perform on the extra bytes.
For those of you who purchased the MEWEL 1.0 source code, please note that
the window information that used to reside in the window extra bytes has now
been moved to the class extra bytes area.
BOOL pascal SetWindowExtra(HWND hWnd, int nBytes)
Allocates memory for a window's extra byte area. The memory block is
initially set to all zeros.
Parameters
hWnd is the window handle of the window to query.
nBytes is the number of bytes to allocate for the area.
Returns
TRUE if the operation was successful, FALSE if not.
BYTE *pascal GetWindowExtra(HWND hWnd)
Retrieves the address of the beginning of the window extra area.
Parameters
hWnd is the window handle of the window to query.
Returns
The address of the window extra byte area.
PLEASE NOTE --- The address returned by GetWindowExtra() is *NOT*
the same address that you get if you looked at the pWinExtra field of the
window structure.
BYTE pascal GetWindowByte(HWND hWnd, int iByte)
Retrieves the single byte residing at the 'iByte' position in the window
extra area.
Parameters
hWnd is the window handle of the window to query.
iByte is the 0-based byte offset from the start of the window extra area.
Returns
The byte at pWinExtra[iByte].
WORD pascal GetWindowWord(HWND hWnd, int iWord)
Retrieves the single word residing at the 'iWord' position in the window
extra area.
Parameters
hWnd is the window handle of the window to query.
iWord is the 0-based word offset from the start of the window extra area.
Returns
The word at pWinExtra[iWord].
LONG pascal GetWindowLong(HWND hWnd, int iLong)
Retrieves the single long residing at the 'iLong' position in the window
extra area.
Parameters
hWnd is the window handle of the window to query.
iLong is the 0-based long offset from the start of the window extra area.
Returns
The long at pWinExtra[iLong].
BYTE pascal SetWindowByte(HWND hWnd, int iByte, BYTE byte)
Sets the value of the single byte residing at the 'iByte' position in the
window extra area.
Parameters
hWnd is the window handle of the window to query.
iByte is the 0-based byte offset from the start of the window extra area.
byte is the single byte value.
Returns
The byte at pWinExtra[iByte].
int pascal SetWindowWord(HWND hWnd, int iWord, WORD word)
Sets the value of the single word residing at the 'iWord' position in the
window extra area.
Parameters
hWnd is the window handle of the window to query.
iWord is the 0-based word offset from the start of the window extra area.
word is the single word value.
Returns
The word at pWinExtra[iWord].
LONG pascal SetWindowLong(HWND hWnd, int iLong, LONG llong)
Sets the value of the single long residing at the 'iLong' position in the
window extra area.
Parameters
hWnd is the window handle of the window to query.
iLong is the 0-based long offset from the start of the window extra area.
long is the single long value.
Returns
The long at pWinExtra[iLong].
*******************************************************************************
WinSetFlag() FUNCTION ADDED
---------------------------
DWORD pascal WinSetFlags(HWND hWnd, DWORD fFlags)
OR's the window's flags field with the value in the second parameter.
Parameters
hWnd is the handle of the window to query.
fFlags is the double word value of the flags to OR the current flags with.
Returns
The new value of the flags field if successful, 0 if not.
*******************************************************************************
IMPROVED MESSAGE BOXES
----------------------
You can now define which push button will be the default button in a message
box. Three new flags have been defined which can be ORed with the other
flags. These are :
MB_BUTTON1DEF - button 1 is the default button
MB_BUTTON2DEF - button 2 is the default button
MB_BUTTON3DEF - button 3 is the default button
For example,
rc = MessageBox("Do you want to continue?", NULL, NULL, "Error!",
MB_YESNO | MB_BUTTON2DEF);
would make the <NO> button the default button within the message box. If the
user were to press <ENTER> as soon as the message box came up, the IDNO code
would be returned to the application.
In addition, the user can now press the first letter of a pushbutton in order
to invoke that button. For example, if you have a YES/NO message box, the
user can press 'y' to choose YES and 'n' to choose NO.
*******************************************************************************
NEW MENU ATTRIBUTES
-------------------
MF_SHADOW - puts a shadow on the bottom right side of the menu. There are
two global variables which you can access in order to change the change the
character and attribute used to produce the shadow. These variables are :
BYTE chShadow = '░';
BYTE attrShadow = 0x07;
If you would like a pulldown menu to have a shadow behind it, give the
first item in the popup the attribute of MF_SHADOW. For example :
hPop1 = CreateMenu(hMenu);
ChangeMenu(hPop1, 0, "~New", ID_NEW, MF_APPEND | MF_SHADOW);
ChangeMenu(hPop1, 0, "~Open...ALT+O",ID_OPEN, MF_APPEND);
........
ChangeMenu(hPop1, 0, "~Generate", ID_GENERATE, MF_APPEND);
MF_HELP - used to define a menu item which will be used to invoke help.
If this item is in the menubar (where it should be, according to CUA), then
the item will be displayed right justified at the end of the menu bar. A
vertical separator will be displayed to the left of it. The help item
cannot be move to by cursoring on the menubar; however, you can select it with
the mouse or you can press the corresponding accelerator key to invoke it,
When this item is selected, a WM_HELP message is sent to the winproc of the
menu's parent window. wParam will contain the id of the menu item, so you can
use the id to provide context-sensitive help.
*******************************************************************************
WS_CLIP STYLE ADDED
--------------------
In an effort to speed up window output, we have introduced the WS_CLIP
style for windows. When output is written to a window which has the WS_CLIP
style, the window is checked for overlapping windows. Text will not be written
into areas occupied by overlapping windows. Of course, this checking will
slow down output, so you should be prudent about using the WS_CLIP style.
Generally, the WS_CLIP style should be used in the following situations:
- You write to a window which can be obscured by its children.
- You write to a window which can be overlapped by a sibling.
*******************************************************************************
*******************************************************************************
*******************************************************************************
MEWEL RESOURCE COMPILER
-----------------------
What is a resource file?
------------------------
A resource can be considered to be any kind of data. This data is kept in an
external data file called a "resource file", and is read in by your application
when needed.
There are several advtantages to using resource files. First and foremost,
the size of your MEWEL application's EXE file is decreased since data
is kept in another file. Second, the amount of memory that your MEWEL app
uses is decreased since resources can be read in when needed, and then
discarded when their usefulness has ended. Third, you can make changes
to various resource objects (like menus and dialog boxes) without having to
recompile your entire application again.
A resource file consistes of one or more object definitions. An object can
be a string table, an accelerator table, a menu, or a dialog box. We will
discuss each object below, along with the definition of its syntax.
Compiling Resource Files
------------------------
A resource file normally ends with a ".rc" extension. When you can invoke the
resource compiler as follows:
rc filename <---- assumes a .rc extension
rc filename.ext <---- you can use any extension
The generated output will be written to a file of the same name but with a
".res" extension.
DEFINITIONS AND SYNTAX
----------------------
Please note that an 'identifier' is a number in this version of the resource
compiler. To give your identifiers more meaning, you can use #define's to
specify a meaningful name. For example, you would use something like this :
#define MY_MENU 200
....
MY_MENU MENU
...
StringTables
------------
A stringtable consists of a series of strings and their corresponding numeric
identifiers. In your MEWEL application, you can load a string from the resource
file merely by specifying its identifier.
Your resource file can have only one STRINGTABLE defined.
STRINGTABLE
BEGIN
identifier1, "string1"
identifier2, "string2"
.........
END
Example
#define "errormsg.h" /* contains the error message id's */
STRINGTABLE
BEGIN
ERR_OUTOFSPACE, "You have run out of memory!"
ERR_FILENOTFOUND, "The file was not found"
ERR_BADFORMAT, "An illegal format was encountered"
END
Accelerators
------------
Accelerators are discussed in detail in the MEWEL manual. Basically, an
accelerator is an association between a key and a numeric identifier. When
the key is pressed from within your MEWEL application, a WM_COMMAND message
in sent to your window procedure with the corresponding identifier placed in
the wParam argument.
identifier ACCELERATORS
BEGIN
keycode, identifier
keycode, identifier
........
END
Example
#include "keys.h"
#include "app.h"
#define MyAccel 100
..
MyAccel ACCELERATORS
BEGIN
F1, ID_HELP
ALT_S, ID_SHOW
CTRL_A, ID_ALL
END
Menus
-----
identifier MENU ---- MENUITEM SEPARATOR
BEGIN /
menuitems --------------- MENUITEM "string", identifier options
END \ |
---- POPUP "string" options |
BEGIN |
menuitems MENUBREAK
END CHECKED
INACTIVE
GRAYED
HELP
SHADOW
Example
ID_MYMENU MENU
BEGIN
POPUP "File" SHADOW
BEGIN
MENUITEM "Open", 1
MENUITEM "Save", 2
MENUITEM "Save As", 3
MENUITEM SEPARATOR
MENUITEM "ESC=Cancel", 99 INACTIVE
END
MENUITEM "F1=Help", ID_HELP HELP
END
Dialog Boxes
------------
identifier DIALOG x,y,cx,cy [,color]
[CAPTION "string"]
BEGIN
control-class "title", ctrl-id, x,y,cx,cy [,color]
........
END
control-class
-------------
TEXT
FRAME
BOX
EDIT
CHECKBOX
PUSHBUTTON
RADIOBUTTON
LISTBOX
SCROLLBAR
Example
#define ID_NAMETEXT 200
#define ID_NAME 201
ID_MYDLG DIALOG 10,3,50,15
CAPTION "My Dialog"
BEGIN
TEXT "Name:", ID_NAMETEXT, 12,5,5,1
EDIT "", ID_NAME, 20,5,25,1
END
Miscellaneous
-------------
1) The word BEGIN and END can be replaced by a left curly brace and a right
curly brace respectively. For example,
STRINGTABLE STRINGTABLE
BEGIN {
.... is the same as .....
END }
2) You can use the #include directive to include a file.
Example
#include "foo.h"
3) You can use the #define directive to define simple symbols in terms
of other symbols.
Example
#define IDMENU 1
#define IDDLG 999
USING RESOURCES IN MEWEL
------------------------
WORD pascal OpenResourceFile(char *szFileName)
Opens a resource file for use.
Parameters
szFileName is the full name of the resource file to open. You do not
have to specify the ".res" extension.
Returns
The module handle if the resource file was opened, 0 if not.
void pascal CloseResourceFile(WORD hModule)
Closes a resource file.
Parameters
hModule is the handle of the resource file to close.
Returns
Nothing.
int pascal LoadString(WORD hModule, WORD idStr, BYTE *pBuffer, WORD nMax)
Loads in a string from a resource file.
Parameters
hModule is the handle of the opened resource file.
idStr is the identifier of the particular string which you want to load.
pBuffer is a pointer to a user-defined buffer which the string will be
copied into.
nMax is the size of the user-defined buffer.
Returns
TRUE if successful, FALSE if not.
HACCEL pascal LoadAccelerators(WORD hModule, WORD idAccel)
Loads in an accelerator table from a resource file.
Parameters
hModule is the handle of the opened resource file.
idAccel is the identifier of the particular accelerator table which you
want to load.
Returns
A non-zero handle to the loaded accelerator table if successful, 0 if not.
HMENU LoadMenu(WORD hModule, WORD idMenu, HWND hParent)
Loads in a menu from a resource file.
Parameters
hModule is the handle of the opened resource file.
idMenu is the identifier of the particular menu table which you want to load.
hParent is the handle of the menu's parent window.
Returns
A non-zero handle to the loaded menu if successful, 0 if not.
HDLG pascal LoadDialog(WORD hModule, WORD idDialog, HWND hParent,
BOOL (pascal *dlgfunc)())
Loads in a dialog box from a resource file.
Parameters
hModule is the handle of the opened resource file.
idDialog is the identifier of the particular dialog box which you want
to load.
hParent is the handle of the dialog box's parent window.
dlgfunc is a pointer to the user-defined dialog box procedure.
Returns
A non-zero handle to the loaded dialog box if successful, 0 if not.
BYTE *pascal DosGetResource(WORD hModule, WORD idType, WORD idName)
Low level function for loading in a particular resource from a resource file.
Parameters
hModule is the handle of the opened resource file.
idType is the type of resource to load. It can be on of the following:
RT_MENU
RT_DIALOG
RT_STRING
RT_ACCELTABLE
idName is the identifier of the particular object which you want to load.
Returns
A pointer to the loaded resource if successful, NULL if not. The pointer
is to a malloc()'ed area of memory, and can be free()'ed when you no longer
need it.
Example
-------
char buf[120];
HWND hMain;
HMENU hMenu;
HACCEL hAccel;
WORD hRes;
........
if ((hRes = OpenResourceFile("TEST.RES")))
{
LoadString(hRes, ID_ERRSTR, buf, sizeof(buf));
if ((hAccel = LoadAccelerators(hRes, 1)))
{
AcceleratorSetFocus(hAccel);
AcceleratorSetWnd(hMain);
}
if ((hMenu = LoadMenu(hRes, ID_MYMENU, hMain)) != NULLHWND)
SetMenu(hMain, hMenu);
CloseResourceFile(hRes);
}
CHANGES AND ADDITIONS TO MEWEL 1.1
Easy way to get Scrollbar handles
---------------------------------
int pascal WinGetScrollbars(HWND hWnd, HWND *hHorizSB, HWND *hVertSB)
This function is used to retrieve a window's scrollbar handles.
Parameters
hWnd is the handle of the window which contains the scrollbars. (ie - the
parent window).
hHorizSB and hVertSB are pointers to handles which will be used to hold
the returned horizontal and vertical scrollbar handles. If a window does
not contain a particular scrollbar, the corresponding handle pointer will
receive a NULL value.
Returns
FALSE if hWnd was not a valid window handle, TRUE otherwise.
Example
HWND hMain;
HWND hVSB, hHSB;
if (WinGetScrollbars(hMain, &hHSB, &hVSB) == TRUE)
{
if (hVSB == NULLHWND)
MessageBox("No vertical scroll bar!", NULL, NULL, "Warning", MB_OK);
if (hHSB == NULLHWND)
MessageBox("No horizontal scroll bar!", NULL, NULL, "Warning", MB_OK);
}
Enhanced WM_CHAR message
------------------------
WM_CHAR message now has the shift state in the low word of lParam.
Accelerator Keys in dialogs
---------------------------
If a letter of the title or text of a control is highlighted by prefixing
the letter with '~', you can set focus to that control by pressing the
ALT key along with the letter. For instance, if you create a listbox
whose title is "~Files", then when the listbox is displayed, the 'F' will
be highlighted. You can move to that listbox by pressing the ALT+F key.
WS_GROUP style
--------------
A dialog box control can have the WS_GROUP style. When a control has this
style, it can be moved to by pressing the UP or DOWN arrow keys from within
the dialog box.
BOOL pascal SetDlgItemStyle(HWND hDlg, int id, DWORD dwStyle)
Paramters
hDlg is the handle to the dialog box.
id is the identifier of the control within the dialog box.
dwStyle can be WS_GROUP or any combination of WS_XXXX attributes.
Returns
TRUE if id corresponded to a valid control, FALSE if not.
SOUND FUNCTIONS added (file sound.c and sound.h)
---------------------
void SoundBeep(void)
Produces a standard error tone (900 Hz).
Parameters
None.
Returns
Nothing.
void SoundClick(void)
Produces a pseudo-clicking sound.
Parameters
None.
Returns
Nothing.
void SoundNote(note, octave, duration)
int note, octave;
unsigned duration;
Parameters
'Note' can be one of the following values :
RESTNOTE - Rest (silence for duration)
CNOTE, CsNOTE - C, C sharp
DNOTE, DsNOTE - D, D sharp
ENOTE, FNOTE, FsNOTE - E, F, F sharp
GNOTE, GsNOTE - G, G sharp
ANOTE, AsNOTE, BNOTE - A, A sharp, B
The "octave" parameter is the octave in which to play the note, and ranges from
MIN_OCTAVE to MAX_OCTAVE, with the higher octaves almost inaudible. An octave
value of MID_OCTAVE and note value of CNOTE will give middle C.
The "duration" is the duration of the note in milliseconds.
Returns
Nothing.
void SoundTone(freq, duration, pause)
unsigned freq, duration, pause;
Parameters
freq - cycles per second
duration - period of square waves in milliseconds
pause - period of quiet calibrated in milliseconds
Returns
Nothing.
TIMER CHANGES (file wintimer.c)
--------------
Multiple timers were added ala Microsoft Windows. The 'id' parameter in
both the SetTimer() and KillTimer() functions can contain any valid
integer. Likewise, the wParam of WM_TIMER messages will contain a valid id
number. Please see the demo program TIMEDEMO.C for an example of using
both multiple timers and sound.
The 'interval' parameter in the SetTimer() function has been changed from
clock ticks to milliseconds. For example, the call
SetTimer(hWnd, 1, 1000, NULL);
will set a timer with an id of 1 to go off every second.
MONO MAPPING ADDED (file winmono.c)
------------------
MEWEL now has an internal attribute mapping table which will be used if the
MEWEL programmer specifies. The table maps color attributes into monochrome
attributes. In order to enable mono mapping, the MEWEl programmer must call
the function WinUseMonoMap(TRUE). (See below).
VidGetMode() now returns the video mode number. This will help you deter-
mine if you are running on a mono system (mode 7 is mono).
void pascal WinUseMonoMap(int bUseit)
This function tells MEWEL whether or not you want to use the mono map
to translate color attributes to mono attributes. The passed parameter,
buseit, should be non-zero if you want to use the mono mapping, and zero
if you do not want to map. By default, when MEWEL starts up, mono mapping
is disabled.
PARAMETERS
bUseit is TRUE if mono mapping should be used, FALSE if not.
RETURNS
Nothing.
EXAMPLE
/* Enable mono maping if we are running on a mono system */
if (VidGetMode() == 7)
WinUseMonoMap(TRUE);
int pascal WinMapAttr(int attr)
Given an attribute in the form of (bg * 16 + fg), returns the mapped mono
attribute.
PARAMETERS
attr is the color attribute to map.
RETURNS
The mapped attribute in the form (bg * 16 + fg).
void pascal WinSetMonoMapColor(int idxColor, int bForeground, int inewColor)
This is used to set a mapping in the monochrome mapping table. idxColor
is the color to map, and can range from 0 to 15. bForeground is TRUE if
idxColor is a foreground color, FALSE if it's a background color. inewColor
is the color which idxColor should be mapped to; inewColor must be either
0 (for black), 7 (for white), 8 or 15.
PARAMETERS
idxColor is the color attribute to map. It must be betwen 0 and 15.
bForeground is TRUE if idxColor is a foreground attribute, FALSE if
idxColor is a background attribute.
inewColor is the monochrome attribute to associated with the color
attribute idxColor.
RETURNS
Nothing.
EXAMPLE
/* Map the green foreground attribute into white on a mono system */
#define GREEN 2
#define WHITE 7
......
WinSetMonoMapColor(GREEN, TRUE, WHITE);
MULTILINE EDIT CLASSES ADDED
----------------------------
Multiline edit controls, similar to those found is Microsoft Windows, were
added to MEWEL.
The following keys invoke edit actions :
LEFT, RIGHT, UP, DOWN character and line movement
PGUP, PGDN scroll up/down one window of text
HOME, END go to beginning/end of line
CTRL-PGUP, CTRL-PGDN go to beginning/end of buffer
INS toggle insert mode
DEL deletes the character under the cursor, or deletes
the selected text
BACKSPACE deletes the character to the left of the cursor
SHIFT LEFT, SHIFT DOWN, extends the selected area
SHIFT UP, SHIFT RIGHT,
SHIFT HOME, SHIFT END
F9 Pastes the contents of the pick buffer in the text
SHIFT F9 Copies the selected area to the scrap buffer
Edit Styles
-----------
Several styles can be applied to MEWEL edit controls. They are :
ES_MULTILINE - the edit control spans multiple lines
ES_AUTOVSCROLL - when the use presses ENTER at the last row of a multiline
edit control, the control is scrolled one line up.
ES_AUTOHSCROLL - if the user enters a character at the last column of an
edit control, the control scrolls one character to the
right
These styles are applied when you call EditCreate. As an example,
hEditWnd = EditCreate(hMain, 10, 30, 16, 50, "Edit Box", 0x31,
WIN_HAS_BORDER | WIN_VSCROLL | WIN_HSCROLL |
ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_MULTILINE,
ID_EDIT);
This creates a multiline edit control which has both horizontal and verti-
cal scrollbars. Both automatic horizontal and vertical scrolling are
enabled.
New Edit Notification Messages
EN_HSCROLL
EN_VSCROLL
Sent to the edit control's parent window when the user clicks the
horizontal and vertical scrollbars.
New Edit Messages
EM_GETHANDLE
Retrieves the far address of the an edit control's text buffer.
lParam is a pointer to a user-supplied far pointer to a holder for the text
buffer.
Example
char far *szHandle;
.....
SendMessage(hEdit, EM_GETHANDLE, 0, (DWORD) (char far **) &szHandle);
EM_GETLINE
This message is sent to an edit control in order to retreive the contents
of a certain line.
wParam is the 1-based index of the line to retrieve.
lParam is a far ptr to the buffer to receive the line.
EM_GETLINECOUNT
Returns the number of lines in the edit control.
EM_GETMODIFY
Returns TRUE if the contents of the edit control has been modified, FALSE
if not.
EM_GETSEL
Retrieves the current text selection points.
lParam is a pointer to a user-supplied far pointer to a 2-word memory
location. The 0-based starting point will be copies to the first word and
the ending point will be copied to the second word.
Example
WORD markers[2];
WORD *pMarkers;
.....
pMarkers = markers;
SendMessage(hEdit, EM_GETSEL, 0, (DWORD) (WORD far **) &szHandle);
EM_LIMITTEXT
This message is sent to an edit control in order to limit the number of
characters which can be inserted into the control.
wParam contains the maximum number of characters which the edit control
should handle.
EM_LINEFROMCHAR
Given a 0-based position into the edit buffer, returns the 1-based line
number of the line which falls on that position.
wParam is the 0-based position.
EM_LINEINDEX
Given a 1-based line number, returns a 0-based offset from the start of
the edit buffer where the first character of that line occurs.
wParam is the 1-based index of the line to examine.
EM_LINELENGTH
This message is sent to an edit control in order to find out how many
characters are in a specific line.
wParam is the 1-based index of the line to examine.
EM_LINESCROLL
This message is sent to an edit control in order to scroll the contents
horizontally or vertically.
HIWORD(lParam) is the number of lines to scroll.
LOWORD(lParam) is the number of columns to scroll.
EM_REPLACESEL
This message is sent to an edit control in order to replace the selected
text with another string.
lParam is a far pointer to a NULL-terminated string. This string will
replace the contents of the selected area.
EM_SETMODIFY
Sets the "buffer dirty" flag associated with the edit control.
wParam should be TRUE if you want to set the "buffer dirty" flag, FALSE if
you want to clear it.
EM_SETSEL
Sets a selected area in the edit control.
LOWORD(lParam) is the 0-based starting point of the selection and
HIWORD(lParam) is the 0-based ending point of the selection. If lParam is
-1L, then the entire text will be selected.
WM_COPY
Copies the selected text into the "scrap buffer".
WM_CUT
Copies the selected text into the "scrap buffer" and then deletes the
selected text.
WM_PASTE
Inserts the contents of the "scrap buffer" into the edit buffer starting at
the cursor position.
Multiple-selection listboxes supported
--------------------------------------
The LBS_MULTIPLESEL style can be used for listboxes where more than one
item can be selected.
There are two listbox messages which can be used with multiple-selection
listboxes. The LB_GETSEL message has been enhanced to work with multiple
selection listboxes. wParam is the index of an entry to test to see if it
has been selected or not. The LB_SETSEL message will set the selection
state of a listbox entry. The message details are as follows :
LB_SETSEL
wParam is 0 if the item is to be de-selected, and non-zero if the item is
to be selected.
LOWORD(lParam) is the index of the listbox entry to select or de-select.
If LOWORD(lParam) is -1, then all of the entries will be selected or
de-selected, depending on the value of wParam.