雷火电竞-中国电竞赛事及体育赛事平台

歡迎來到入門教程網(wǎng)!

C語言

當(dāng)前位置:主頁 > 軟件編程 > C語言 >

c語言在控制臺(tái)判定鼠標(biāo)左鍵的小例子

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:C語言|點(diǎn)擊:

復(fù)制代碼 代碼如下:

// temp1.cpp : Defines the entry point for the console application.
 //

 //#include <stdafx.h>
 #include <windows.h>
 #include <conio.h>
 #include <stdlib.h>
 #include<stdio.h>
 int main(int argc, char* argv[])
 {
  SetConsoleTitle("Hello World!");
  HANDLE hInput = GetStdHandle(STD_INPUT_HANDLE); // 獲取標(biāo)準(zhǔn)輸入設(shè)備句柄
  INPUT_RECORD inRec;
  DWORD res;

  while (1)
  {
   ReadConsoleInput(hInput, &inRec, 1, &res);
   if (inRec.EventType == MOUSE_EVENT && inRec.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) //鼠標(biāo)左鍵
   {
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),inRec.Event.MouseEvent.dwMousePosition);
    printf("Hello World!");
   }
   Sleep(100);
  }
  return 0;
 } 

上一篇:淺析Linux下精確控制時(shí)間的函數(shù)

欄    目:C語言

下一篇:解析如何用指針實(shí)現(xiàn)整型數(shù)據(jù)的加法

本文標(biāo)題:c語言在控制臺(tái)判定鼠標(biāo)左鍵的小例子

本文地址:http://www.jygsgssxh.com/a1/Cyuyan/4341.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有