delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/01/17/23:28:44

From: "Gautam N. Lad" <gautam AT interlog DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP and GRX20 : Entryfield class in my GUI
Date: 17 Jan 1997 23:33:09 GMT
Organization: InterLog Internet Services
Lines: 83
Message-ID: <5bp27m$m6j@news.interlog.com>
NNTP-Posting-Host: ip203-250.cc.interlog.com
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
Can someone please help me out with this Entryfield class I'm trying
to produce under DJGPP, using GRX20.  I have a class Entryfield, with
a member GetText(GrMouseEvent evt), unfortunately, it doesn't respond!
Here's the snippet from the program:

//------------------------------SNIP----------------------------------------
// WINDOW.HPP - Defines classes
class Entryfield
{
public:
        void DrawE(int x, int y, int w, int h);
        void GetText(GrMouseEvent evt);
        int ClickedE(int mx, int my);
private:
        int ex,ey,ew,eh;	/* variables to hold entryfield's
				   x,y locations and width,height */
	
        int key;		/* Variable that contains the keypress 
                                   value */
        int x;			// Scrap
        char BUF[15];		// Holds text
        char BUF2[15];		// Scrap
        GrFBoxColors ec;	// Entryfield's colour
;

// WINDOW.CPP - Classes
/* The file OUT is used to keep track of key press.  Unfortunately it
   contains NOTHING! 
   ENTER is: #define ENTER   0x1c0d
*/
void Entryfield::GetText(GrMouseEvent evt)
{
    FILE *FP;
    FP=fopen("OUT","w");
        GrMouseGetEventT(GR_M_EVENT,&evt,0L);
        GrMouseSetLimits(ex,ey,ex,ey);
        while(key != ENTER)
        {
        if (evt.flags & GR_M_KEYPRESS)
            {
            key = evt.key;
            if (key == ENTER) break;
            sprintf(BUF,"%c",key);
            GrTextXY(ex+1,ey+1,BUF,GrAllocColor(0,0,0),GrAllocColor(255,0,0));
            fprintf(FP,"KEY=%c BUF=%s X=%d",key,BUF,x);
            }
        }
    fclose(FP);
}

// TB.CPP - My program
/* I have the for(;;) loop that keeps repeating until right mouse button
is down.  When it is, the program exits (this is just for now).
When the LEFT button is down, this if loop is examined.  If true 
(TRUE = 1), then text gets retrieved.
*/

                if (ENT.ClickedE(evt.x,evt.y))
                 {
                  ENT.GetText(evt);
                }

//------------------------------SNIP----------------------------------------


Please note that I do not have a 100% understanding of Classes.  
I only know basic classes.  I will soon learn inheritance 
(already know a little) to simplify my Entryfield (it will inherit 
attributes of the Dialog class to draw the entryfields).

Thanks!
Please reply by E-Mail!
****************************************************
* Gautam N. Lad                                    *
*--------------------------------------------------*
*                                                  *
* E-Mail	: gautam AT interlog DOT com              *
* Website	: http://www.interlog.com/~gautam  *
*                                                  *
* OS/2, DOS/Windows, Graphics Gallery, Software,   *
* Links, Rayzor Editor/2, POV-Ray,  and more.      *
****************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019