Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Mouse interrupt handling This example is designed to ask you to clean the screen by clicking mouse. In the code, the following line must be

Mouse interrupt handling

This example is designed to ask you to clean the screen by clicking mouse.

In the code, the following line must be included:

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)

In addition, VK_LBUTTON, VK_RBUTTON, VK_MBUTTON indicate left button, Right button, Middle button respectively.

//Example

#include

#include

#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0) //Must have this line

using namespace std;

int main()

{

while (1)

{

printf("Trick or treat. Smell my feet. Give me something good to eat. ONLY CLICK TO CLEAN THE SCREEN ");

if (KEY_DOWN(VK_LBUTTON))

{

printf("Left click to clean the screen. Pause 1 second.");

Sleep(1000);//pause 1 second

system("cls");//Clean the screen

}

if (KEY_DOWN(VK_RBUTTON))

{

printf("Right click to clean the screen. Pause 1 second.");

Sleep(1000);//pause 1 second

system("cls");//Clean the screen

}

if (KEY_DOWN(VK_MBUTTON))

{

printf("Middle click to clean the screen. Pause 1 second.");

Sleep(1000);//pause 1 second

system("cls");//Clean the screen

}

Sleep(20); //set time interval.

}

return 0;

}

  1. Does the code below work as well? Please explain the effect of { } in the if clause.

if (KEY_DOWN(VK_MBUTTON))

printf("Middle click to clean the screen. Pause 1 second.");

Sleep(1000);//pause 1 second

system("cls");//Clean the screen

  1. How the function Sleep(1000) works?
  2. Please try to design a new feature and modify the code. Show your code below.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

Explain the function and purpose of the Job Level Table.

Answered: 1 week ago