ParsX.com
پذیرش پروژه از دانشجویی ... تا سازمانی 09376225339
 
   ProfileProfile   Log in to check your private messagesLog in to check your private messages  |  FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups Log inLog in   RegisterRegister 

guestion

 
Post new topic   Reply to topic    ParsX.com Forum Index -> C/C++ Programming
View previous topic :: View next topic  
Author Message
hamidhamed
مهمون يكي دو روزه


Joined: 03 Apr 2005
Posts: 2

PostPosted: Sun Apr 03, 2005 6:05 am    Post subject: guestion Reply with quote

چگونه ميتوان با ماوس در زبان سي كاركرد؟
Back to top
vahid
بي تو هرگز


Joined: 26 Nov 2004
Posts: 3067
Location: Tehran

PostPosted: Mon Apr 04, 2005 8:40 am    Post subject: Reply with quote

يه مثال برات ميزنم تحليلش كن:
#include "dos.h"

#include "graphics.h"

union REGS i, o ;

main( )

{

int gd = DETECT, gm, maxx, maxy, x, y, button ;

initgraph ( &gd, &gm, "c:\\tc\\bgi" ) ;

maxx = getmaxx( ) ; 

maxy = getmaxy( ) ;

rectangle ( 0, 56, maxx, maxy ) ;

setviewport ( 1, 57, maxx - 1, maxy - 1, 1 ) ;

gotoxy ( 26, 1 ) ; 

printf ( "Mouse Demonstration Program" ) ;

if ( initmouse( ) == 0 )

{

closegraph( ) ;   

restorecrtmode( ) ;

printf ( "\nMouse driver not loaded" ) ;

exit ( 1 ) ;

}

restrictmouseptr ( 1, 57, maxx - 1, maxy - 1 ) ;

showmouseptr( ) ;

gotoxy ( 1, 2 )  ;   

printf ( "Left Button" ) ;

gotoxy ( 15, 2 ) ;   

printf ( "Right Button" ) ;

gotoxy ( 55, 3 ) ;   

printf ( "Press any key to exit..." ) ;

while ( !kbhit( ) )

{

getmousepos ( &button, &x, &y ) ;

gotoxy ( 5, 3 ) ;

( button & 1 ) == 1 ? printf ( "DOWN" ) : printf ( "UP  " ) ;

gotoxy ( 20, 3 ) ;

( button & 2 ) == 2 ? printf ( "DOWN" ) : printf ( "UP  " ) ;

gotoxy ( 65, 2 ) ;

printf ( "X = %03d  y = %03d", x, y ) ;

}

}

 

/* initialises mouse */

initmouse( )   

{

i.x.ax = 0 ;

int86 ( 0x33, &i, &o ) ;

return ( o.x.ax ) ;

}

 

/* displays mouse pointer */

showmouseptr( )   

{

i.x.ax = 1 ;

int86 ( 0x33, &i, &o ) ;

}

 

/* restricts mouse movement */

restrictmouseptr ( int x1, int y1, int x2, int y2 ) 

{

i.x.ax = 7 ;   

i.x.cx = x1 ;   

i.x.dx = x2 ;

int86 ( 0x33, &i, &o ) ;

i.x.ax = 8 ;   

i.x.cx = y1 ;   

i.x.dx = y2 ;

int86 ( 0x33, &i, &o ) ;

}

 

/* gets mouse coordinates and button status */

getmousepos ( int *button, int *x, int *y )

{

i.x.ax = 3 ;

int86 ( 0x33, &i, &o ) ;

*button = o.x.bx ;   

*x = o.x.cx ;   

*y = o.x.dx ;

Back to top
Display posts from previous:   
Post new topic   Reply to topic    ParsX.com Forum Index -> C/C++ Programming All times are GMT + 3.5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum