delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/25/08:16:01

From: Waldemar Schultz <schultz AT ma DOT tum DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: GRX 2.3 mouse usage
Date: Fri, 25 Feb 2000 13:55:29 +0100
Organization: [posted via] Leibniz-Rechenzentrum, Muenchen (Germany)
Lines: 68
Message-ID: <38B67BC1.1379D48D@ma.tum.de>
NNTP-Posting-Host: pcritter10.mathematik.tu-muenchen.de
Mime-Version: 1.0
X-Trace: wsc10.lrz-muenchen.de 951483335 6182 131.159.69.74 (25 Feb 2000 12:55:35 GMT)
X-Complaints-To: news AT lrz-muenchen DOT de
NNTP-Posting-Date: 25 Feb 2000 12:55:35 GMT
X-Mailer: Mozilla 4.7 [de] (Win98; I)
X-Accept-Language: de,en,en-US
Xcanpos: shelf.2/200003101701!0004873791
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

compiling the attached program in a W98/DOS Window wit gcc -lgrx20 (2.95.2)
doesn't behave as I expect.

1. without #define GR_MOUSE the program terminates if a key is pressed,
   (as expected)
   but the cursor doesn't move when the mouse is moved.
   
2. with #define GR_MOUSE the cursor moves when the mouse is moved,
   but the program doesn't terminate when a key is pressed;
   (it does terminate when a button is pressed (as expected))

where is my misunderstanding ? Thanks for help.
sorry for the lengthy example.
==================GRX.c================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <grx20.h>

#define GR_MOUSE

int main (int argc, char **argv)
{
char buf[2048];
int i=0,k=0;
int x,y,w,h,n;
GrColor bgc = GrAllocColor(128,0,0);       //red
GrColor fgc = GrAllocColor(255,255,255);   //white
GrMouseEvent evt;

 while(kbhit()) if(!getch()) getch(); //empty keyboard buffer

 GrSetMode(GR_default_graphics);
 x=GrScreenX()-1; y=GrScreenY()-1; h=14; w=8; n=256;
 GrClearScreen(bgc);

 if(!GrMouseDetect()) { GrSetMode(GR_default_text); return EXIT_FAILURE;}
 GrMouseEventMode(1);                        //use interrupt
 GrMouseEventEnable(0,1);                    //disable keypress events
 GrMouseSetCursorMode(GR_M_CUR_NORMAL);
 GrMouseInit();
 GrMouseWarp(x/2,y/2);
 GrMouseSetColors(GrWhite(),GrBlack());
 GrMouseDisplayCursor();

 sprintf(buf,"Resolution %4d x %-4d Colors: %d",x+1,y+1,n);
 GrTextXY(x/2-strlen(buf)*w/2,y/2-h/2,buf,fgc,bgc);

 do {
#ifdef GR_MOUSE
  GrMouseGetEvent(GR_M_MOTION | GR_M_BUTTON_CHANGE, &evt);
  i=(evt.flags & GR_M_BUTTON_CHANGE);
#endif
  k=kbhit();
 } while(!k && !i);

 GrMouseUnInit();
 GrSetMode(GR_default_text);
 while(kbhit()) if(!getch()) getch(); //empty keyboard buffer
 return EXIT_SUCCESS;
}

-- 
 Gruss Waldemar Schultz.
 Technische Universität München, Zentrum Mathematik M1, D 80290 München
 Tel: +49 (0)89 2892 8226        FAX: +49 (0)89 2892 8228

- Raw text -


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