Test tc cursor mouse operation (TC)
The mouse operation code used in the Code is controlled by the common registers _ AX, _ BX, _ CX, _ DX.
I really want to use TC multithreading to solve this problem, but I didn't find a specific implementation method on the Internet. Is there only a multi-thread method in C ++ or MS VC? Annoying
int main(){ char szText[20] = ""; for(;;) { if(LeftPress()) { MouseGetXY(); if(MouseX < 0 || MouseX > 800 || MouseY < 0 || MouseY > 600) printf("Cursor is not in the Active Area of the screen!\n"); else { printf("LeftButton Pressed!\n"); sprintf(szText, "cursorX,Y:(%d, %d)\n", MouseX, MouseY); printf(szText); } //sleep(1); } if(RightPress()) { MouseGetXY(); if(MouseX < 0 || MouseX > 400 || MouseY < 0 || MouseY > 300) printf("Cursor is not in the Active Area of the screen!\n"); else { printf("RightButton Pressed!\n"); sprintf(szText, "CursorX,Y:(%d, %d)\n", MouseX, MouseY); printf(szText); /*moveto(120,240);*/ textcolor(5); cprintf("/*RButton Test*/"); printf("\n"); } //sleep(1); } if(kbhit()) { if(0x011b == bioskey(0)) { printf("\ntestEnd\n"); break; } } if(!LeftPress() && !RightPress()) continue; printf("test again:\n"); } getch();}
Problem: When the code is left-pressed or right-clicked, the print statement is printed multiple times.
Solution: After all the corresponding statements are executed, add a sleep (1.
Cause: this problem should be caused by multi-thread round robin;
Textcolor (6 );
Textbackground (7 );
Cprintf ("Left and Right button both Pressed! \ N ");
The execution efficiency of these three statements is too low.