Wndlib 1.0 INTRODUCTION ============ Wndlib is a C++ class library for Microsoft Windows. For the most part (with the exception of the file I/O and printing dialog-boxes and functions) it is implemented in header files. This means no linking, no extra code, and no worrying about memory modules. There are curently over 37 classes, most of which were created for use creating commercial quality Windows programs. Burnham Park Software, Inc. is committed to constantly upgrading and enhancing Wndlib. The price of registration will go up with new enhancements so if Wndlib is useful, register now. Note: Wndlib has been tested with Borland C++ 3.1 and 4.0. There is no reason (with minor modifications) that it would not work with Visual C++ or Symantec C++. It has also been designed to co-exist or supplement other class libraries such as Borlands OWL or Microsoft's Foundation classes. INSTALLATION ============ STEP ONE: Copy the files WNDCLASS.H and WNDDB.H to your compiler's include directory. For example: copy c:\xtalk\fil\wnd*.h c:\cpp\include STEP TWO: Copy the remaining files to the desired directory so that they maybe examined and compiled. For example: copy c:\xtalk\fil\*.* c:\cpp\src\test File list ========= This is a complete file list. WNDCLASS.H - the main header file. WNDDB.H - the I/O dialog-box header file. WNDDB.OBJ - the I/O dialog-box object file. WNDDB.RES - the I/O dialog-box resource file. WNDEX.H - the example program header file. WNDEX.CPP - the example program main file. WNDEX.RC - the example program resource file. WNDEX.DEF - the example program definition file. WNDEX.IDE - the example program Borland C++ 4.0 IDE. WNDEX.EXE - the example program executable. WNDEX.MAK - the example program make file. README.TXT - this text file. FILE_ID.DIZ - Wndlib ID file. ORDER.FRM - Wndlib order form. USING THE LIBRARY ================= Wndlib is composed of two parts (with more to be added in future versions). The first is the WNDCLASS.H header file. This may be easily added to any C++ Windows program file by an include statement such as in this example: #include This will automatically give the programmer access to all of the classes available in WNDCLASS.H without having to link anything in later. An example of a class is the GLOBALMEMORY_CLASS. This class simplifies allocating and freeing memory under Windows. An example of a function that uses GLOBALMEMORY_CLASS follows: void count(){ int i, j; GLOBALMEMORY_CLASS array; // Declare array array.Allocint(20); // Allocate array array.Lock(); // Lock in memory for(i = 0; i < 20; i++) array.Setint(i, 0); // Initialize for(i = 0; i < 100; i++){ j = random(20); array.Setint(j, array.Getint(j) + 1); // Increment } array.Unlock(); // Unlock array.Free(); // Free } This function doesn't do very much, but it illustrates the ease of using C++ classes over using standard C. The second part of Wndlib is the WNDDB I/O dialox-box functions. The WNDDB.H header file is necessary along with the WNDDB.OBJ and WNDDB.RES files (which must be linked into the program). The WNDDB part of the library contains two different File-Open and File-Save as dialog-boxes plus the functions to manipulate them. REFERENCE GUIDE =============== This is not a complete or comprehensive reference guide. The complete reference guide is very long (it is contained in the printed manual) so only a condensed version is listed here. The classes in WNDCLASS.H are only types and must be defined in your program. The classes in WNDDB.H are already defined and may be used if WNDDB.H is included in your program and WNDDB.OBJ and WNDDB.RES are linked with it. WNDCLASS.H BASEWINDOW_CLASS Class that manipulates window handles (HWND). HWND Get() Returns the window handle. void Set(HWND) Sets the window handle. BOOL Show() Shows window in normal state. LONG SendMessage(UINT, WPARAM, LPARAM) Sends message to window. void GetRect(RECT*) Gets window's screen coordinates. WINDOW_CLASS Class that is used to create windows. WINDOWCLASS(HINSTANCE, LPSTR) Constuctor that sets up window. void Create() Creates window using defaults. void dwStyle(DWORD) Set style flags. WINDOWMESSAGE_CLASS Class used for the message loop. int TranslateAccel(HANDLE) Used in message loop to handle accel. int TestMessage() Test for message. void DoMessage() Translates and dispatches message. WINDOWACCEL_CLASS Class used to handle accelerators. EDITWINDOW_CLASS Class for edit child windows. BUTTONWINDOW_CLASS Class for button child windows. LISTBOXWINDOW_CLASS Class for listbox child windows. DIALOGBOXWINDOW_CLASS Class for handling dialog-boxes. void CheckButton(int) Checks a checkbox control. void UncheckButton(int) Unchecks a checkbox control. void CheckRadio(int, int, int) Checks a radio button. void GetText(int, LPSTR) Gets a character string. void ListboxInsert(int, LPSTR) Inserts a string into a listbox. MDICLIENTWINDOW_CLASS Class for MDI client windows. MDICHILDWINDOW_CLASS Class for MDI child windows. MOVEWINDOW_CLASS Class for moving and centering windows. WND_CLASS Class for creating and registering classes. INSTANCE_CLASS Class to store and manipulate hinstance. LOCALMEMORY_CLASS Class facilitate local memory allocation. LOCALARRAY_CLASS Class to handle local two-dimensional arrays. LOCALSTRUCT_CLASS Class to handle local dynamic structures. GLOBALMEMORY_CLASS Class to handle global memory allocation. int Allocchar(DWORD) Allocates a block of characters. int Allocint(DWORD) Allocates a block of integers. int Allocfloat(DWORD) Allocates a block of floats. void Lock() Locks block in memory. void Unlock() Unlocks block in memory. void Free() Frees block. int Getint(int) Retrieves an integer. void Setint(int, int) Sets the value of an integer. GLOBALARRAY_CLASS Class to handle global two-dim. arrays. int Allocint(int, int) Allocates a int x int block. int Getint(int, int) Retrieves an integer. void Setint(int, int, int) Sets the value of an integer. GLOBALSTRUCT_CLASS Class to handle global structures. GLOBALSTRUCT_CLASS(int) Constructor determines struct size. int Alloc(int) Allocates int structures. void Free() Frees memory block. void Add() Adds a new structure. void Remove() Removes a structure. void Insert() Inserts a structure. void Remove() Removes a structure. void First() Moves pointer to first structure. void Last() Moves pointer to last structure. void Next() Moves pointer to next structure. void Prev() Moves pointer to previous structure. LPSTR Getp_struct(int) Returns pointer to structure. LPSTR Getp_struct() Returns pointer to current structure. DIALOGBOX_CLASS Class to call up and display dialog-boxes. DIALOGBOX_CLASS(HINSTANCE) Constructor takes hinstance as arg. DialogBox(HWND, FARPROC, LPSTR) Simplifies calling a dialog-box. FILE_CLASS Class to handle file I/O. int OpenRead(LPSTR) Opens file for reading. int OpenWrite(LPSTR) Opens file for writing. char Readchar() Reads a character. inr Readint() Reads an integer. float Readfloat() Reads a float. void ReadBuffer(LPSTR, int) Reads bytes into a buffer. void Writechar(char) Writes a character. void Writeint(int) Writes an integer. void Writefloat(float) Writes a float. void WriteBuffer(LPSTR, int) Writes bytes from a buffer. void Close() Closes a file. TIMER_CLASS Class to setup a timer TIMER_CLASS(HINSTANCE) Constuctor takes hinstance as arg. void Set(HWND, int, FARPROC) Creates a timer with a callback func. void Setmessage(HWND, int) Creates a timer as a WM_TIMER message. void Kill() Kills timer. CURSOR_CLASS Class to manipulate the cursor. HCURSOR Get() Retrieves current cursor handle. void Set(HCURSOR) Sets current cursor. void Show() Shows current cursor. void Hide() Hides current cursor. void SetARROW() Sets cursor to arrow. void SetWAIT() Sets cursor to timer. void SetCROSS() Sets cursor to crosshair. void SetUPARROW() Sets cursor to up arrow. void SetSIZENWSE() Sets cursor to size arrows. void Restore() Restores old cursor. void Destroy() Destroys cursor. MOUSE_CLASS Class to handle mouse coordinates. MOUSE_CLASS(HWND) Constuctor takes window as arg. void GetClientPos() Retrieves mouse position in client. int Getx() Retrieves x coordinate of mouse. int Gety() Retrieves y coordinate of mouse. MENU_CLASS Class to manipulate menus. MENU_CLASS(HWND) Constructor get menu from window. MENU_CLASS(HINSTANCE, HWND, LSPTR) Constructor loads menu. void Get() Retieves menu from window. void Set() Sets window's menu. int GetState(int, int) Retrieves state of menu item. int GetState(int) Retrieves state of menu item by command. void CheckItem(int, int) Checks menu item. void EnableItem(int int) Enables menu item. HELP_CLASS Class to load and display help file. HELP_CLASS(HWND, LPSTR) Constuctor takes window and name of help file. void HelpIndex() Opens help file's index (or contents). void Help(int) Opens a help file topic. BASEDC_CLASS Base class for device contexts. HDC GetHDC() Retrieves HDC. void SetHDC() Sets HDC. void Delete() Deletes current HDC. void Compatible(HDC) Creates a compatible HDC. HANDLE Select(HANDLE) Selects an object into the HDC. void Line(int, int, int, int) Draws line. DC_CLASS Class for DC's connected to windows. DC_CLASS() Contructor. DC_CLASS(HWND) Constructor that attaches DC to a window. void Get() Gets a DC based on the current window. void Get(HWND) Gets a DC based on the supplied window. void Release() Releases DC. PAINT_CLASS Class based on PAINTSTRUCT. void Begin(HWND) Opens the PAINTSTRUCT to paint the DC. void End() Closes the PAINTSTRUCT. int Getleft() Retrieves the left x-coordinate of the paint rect. int Getright() Retrieves the right x-coordinate of the paint rect. int Gettop() Retrieves the top y-coordinate of the paint rect. int Getbottom() Retrieves the bottom y-coordinate of the paint rect. TEXT_CLASS Class to manipulate text metrics. void Get(HDC) Retrieves text metrics. int GetHeight() Retrieves text height. BRUSH_CLASS Class to manipulate brushes. CreateSolid(int, int, int) Creates a solid brush based on RGB values. HANDLE Select() Selects current brush into DC. void Delete() Deletes current brush. void SelectDelete() Selects then deletes current brush. void SelectSolid(int, int, int) Creates brush then selects into DC. PEN_CLASS Class to manipulate pens. void CreatePen(int, int COLORREF) Creates pen with style, width, and color specified. void CreateSolid(int, COLORREF) Create solid pen with width and color specified. HANDLE Select() Selects pen into DC. void Delete() Deletes current pen. void SelectDelete() Selects then deletes current pen. void SelectSolid(int, int, int) Creates solid pen then selects into DC. BRUSHPEN_CLASS Class to manipulate both pens and brushes. void CreateSolid(COLORREF) Creates solid pen and brush and selects into DC. void Select() Selects pen and brush into DC. void Delete() Deletes current pen and brush. void SelectDelete() Selects then deletes current pen and brush. void SelectSolid(int, int, int) Creates solid pen and brush then selects into DC. BITMAP_CLASS Class to manipulates bitmaps and facilitate BitBlt. BITMAP_CLASS() Constructor without window handle. BITMAP_CLASS(HWND) Constructor with window handle. HDC GetHDCMEM() Retrieves handle to memory device context. HBITMAP GetHBITMAP() Retrieves handle to bitmap. void Setbitmap(HBITMAP) Sets handle to bitmap. void Setup() Create memory device context and get dimensions. void Cleanup() Cleans up mem DC and bitmap. void Draw(int, int, int, int) Draw the bitmap at x, y with dimensions of dx & dy. void Stretch(int, int, int, int, int, int) Draw the bitmap while forcing it to fit in a rect. BITMAPCONVERT_CLASS Class to convert bitmaps from a coordinate system. FONT_CLASS Class to manipulate fonts. PRINT_CLASS Class to help use the Windows printing system. WNDDB.H FILEDB_CLASS Class that handles the dialox-boxes for file I/O. FILEDB_CLASS() Constructor that initializes the default spec to *.*. FILEDB_CLASS(char *) Constructor that sets the default spec. char *Getfilespec() Retrieves file spec. char *Getfilename() Retrieves filename. char *Getdefaultspec() Retrieves default spec. char *Getcaption() Retrieves dialog-box caption. char *Getdescription() Retrieves file description. int Gethead() Retrieves file header. int Getflag() Retrieves file flag. HANDLE Gethinstance() Retrieves hinstance. void Setdefaultspec(char *) Sets the default file spec. void Setcpation(char *) Sets the dialog-box caption. void Setdescription(char *) Sets the file description. void Setapplicationname(char *) Sets the program's name. void Sethinstance(HANDLE) Sets the hinstance. void parsefilename(LPSTR, LPSTR) Parses a string to retrieve a valid filename. void DescriptionList(HWND) Fill a description listbox. int FileOpen(HWND, int) Open a file picked from the FileOpen dialog-box. int FileOpen(HWND) Open a file with defaults. int FileSaveas(HWND, int) Save a file using the FileSave as dialog-box. int FileSaveas(HWND) Save a file with defaults. int DescriptionOpen(HWND, int) Open a description file. int DescriptionOpen(HWND) Open a description file with defaults. int DescriptionSaveas(HWND, int) Save a description file. int DescriptionSaveas(HWND) Save a description file with defaults. int FileMessage(HWND, int) Display a file I/O related message. int FileRead(HWND) Start reading from a file. int FileWrite(HWND) Start writing to a file. PRINTDB_CLASS Class to handle printing. REGISTERING WNDLIB ================== WNDLIB is shareware which means that WNDLIB was distributed freely in order to allow people to "test drive" it. The try-before-you-buy concept allows users to find out which programs are useful before purchasing them. If a shareware program is useful or entertaining, please support it through registration. The registration fee for WNDLIB is only $22. Registration entitles you to the newest version of the program, a Windows 3.1 hypertext help file, a printed manual, customer support (through the mail or on Compuserve), an account on our BBS, an unlimited distribution license, source code and information (and discounts) on other offerings from Burnham Park Software, Inc. To register, send a check or money order to: Burnham Park Software, Inc. P.O. Box #814 Chicago, IL 60690-0814 Phone: (312) 922-6313 BBS: (312) 922-2839 Compuserve: 71532,3271 AOL: J null B Delphi: MARBRO GEnie: XRG36978 Internet: jnullb@aol.com Wndlib is supplied as is. The author disclaims all warranties, expressed or implied, including, without limitation, the warranties of merchantability and of fitness for any purpose. The author assumes no liability for damages, direct or consequential, which may result from the use of WNDlib.