Microsoft KB Archive/12012

{|
 * width="100%"|

Programming the Mouse from a Real-Mode C Program

 * }

Q12012

6.00 6.00A 6.00AX 7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg -- The information in this article applies to: - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax - Microsoft C/C++ for MS-DOS, versions 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SUMMARY ======= The text below presents a code example to test the mouse in a C program. You must install the mouse driver before using this program. MORE INFORMATION ================ The information in this program is presented in the "Mouse Programming Interface" chapter of the "Microsoft Mouse Programmer's Reference," available from Microsoft Press. Sample Code --- #include #include int m1 = 0, m2 = 0, m3 = 0, m4 = 0; union REGS Mouse_regs; void mouse(void) { Mouse_regs.x.ax = m1; Mouse_regs.x.bx = m2; Mouse_regs.x.cx = m3; Mouse_regs.x.dx = m4; int86(0x33, &Mouse_regs, &Mouse_regs); m1 = Mouse_regs.x.ax; m2 = Mouse_regs.x.bx; m3 = Mouse_regs.x.cx; m4 = Mouse_regs.x.dx; } void main(void) { // Turn on the mouse m1 = 1; // SHOW MOUSE Opcode -- See reference m2 = m3 = m4 = 0; // Additional parameters (init = 0) mouse; // Make it happen for // Loop until both buttons are down { m1 = 3; // Get mouse status m2 = m3 = m4 = 0; mouse; if (m2 & 1) printf("Left button down\n"); if (m2 & 2) printf("Right button down\n"); if (m2 & 1 && m2 & 2) { printf("BOTH!\n"); exit(0); } } } Additional reference words: kbinf 6.00 6.00a 6.00ax 7.00 1.00 1.50 KBCategory: kbprg KBSubcategory: CLngIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbPTProdChange kbvc150 kbvc100 kbCCompSearch kbZNotKeyword3 kbCComp600DOS kbCComp600aDOS kbCComp600axDOS kbCVC700DOS