mouse

C++: change the cursor for one button only

Thursday, January 10th, 2008

// handle WM_SETCURSOR in button class
BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT msg)
{
    ::SetCursor(m_hMyCursor);
    return TRUE;
}

Mouse handling with DOS functions in C++

Wednesday, January 25th, 2006

#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<process.h>
void main()
{
     clrscr();_setcursortype(_NOCURSOR);
     REGS regs;
     //Initializing and showing mouse
     regs.x.ax=0;int86(0×33,&regs,&regs);
     regs.x.ax=1;int86(0×33,&regs,&regs);
     //Reading mouse click
     for( ; ; )
     {
 //Updating mouse motions
 regs.x.ax=3;int86(0×33,&regs,&regs);
 //Reading mouse click
 if(regs.x.bx==1)
 {
    gotoxy(2,2);textbackground(1);textcolor(15);
    cprintf(”;Left Button Clicked!”;);
    delay(100);
 }
 if(regs.x.bx==2)
 {
    gotoxy(2,2);textcolor(15);textbackground(1);
    cprintf(”;Right Button Clicked!”;);
    delay(100);
 }
 gotoxy(1,2);textbackground(1);cprintf(”;                  [...]

Keep on coding