Windows.h

时间:2018-12-01 20:02:34

标签: c++

我不确定Windows.h库如何在c ++中工作。我正在创建一个简单的菜单,但是您所做的选择是由F1,F2等触发的。 例如:

    switch(choice)
    {
    case VK_F1:
    //do smth break;

1。鉴于我的选择是(F1-F10,S,V,P,T),我该如何输入该选择。另外,编译器给我一个选择整数时出错的错误,除了整数以外

  1. VK_F1是什么数据类型? 谢谢!

编辑:整个代码

#include <iostream>

#include <conio.h>

#include <windows.h>
using namespace std;

void meniu()
{
  cout << "(F1)Introducere date pentru extragerea " << endl;
  cout << "(F2)Filtrarea castigurilor precedente" << endl;
  cout << "(F3)Filtre dupa frecventa medie pe extragere" << endl;
  cout << "(F4)Extractii" << endl;
  cout << "(F5)Modificare extragere precedenta" << endl;
  cout << "(F6)Cauta castiguri in baze de date" << endl;
  cout << "(F7)Analiza tripleti extrageri precedente dupa intarziere" <<
    endl;
  cout << "(F8)Analiza tripleti extrageri precedente dupa durata evolutie"
    << endl;
  cout << "(F9)Genereaza multime de solutii" << endl;
  cout << "(F10)Analiza tripleti fara criterii" << endl;
  cout << "(S)Studiu frecvente" << endl;
  cout << "(V)Studiu triplet evolutiv" << endl;
  cout << "(F)Afiseaza frecventa de aparatie" << endl;
  cout << "(P)Studiu extrageri" << endl;
  cout << "(T)Raport privind extragerile precedente pe triplet" << endl;
  cout << "(X)Iesire" << endl;



}



bool isConsecutive(int nr1, int nr2, int nr3, int nr4, int nr5, int nr6)
{
  if (nr1 == nr2 + 1 && nr2 == nr3 + 1 || nr2 == nr3 + 1 && nr3 == nr4 + 1 || nr3 ==
    nr4 + 1 && nr4 == nr5 + 1 || nr4 == nr5 + 1 && nr5 == nr6 + 1) // daca sunt 
    consecutive
    return true;
  else
    return false;

}
int main()
{
  int alegere;
  bool deschis = true;
  int trei_nr[3], varianta[6];
  long long counter = 0;
  while (deschis == true)
  {
   meniu();
    switch (alegere) {
      cin >> alegere;
    case VK_F1:
      for (int i = 0; i <= 2; i++)
      {
        cout << "nr[" << i << "]=";
        cin >> trei_nr[i];
        cout << endl;
      }
      break;
    case VK_F2:
      break;
    case VK_F3:
      break;
    case VK_F4:
      break;
    case VK_F5:
      break;
    case VK_F6:
      break;
    case VK_F7:
      break;
    case VK_F8:
      break;
    case VK_F9: // Generarea variantelor
      for (int n1 = 1; n1 <= 44; n1++)
      {
        for (int n2 = n1 + 1; n2 <= 45; n2++)
        {
          for (int n3 = n2 + 1; n3 <= 46; n3++)
          {
            for (int n4 = n3 + 1; n4 <= 47; n4++)
            {
              for (int n5 = n4 + 1; n5 <= 48; n5++)
              {
                for (int n6 = n5 + 1; n6 <= 49; n6++)
                {
                  counter++;
                }

              }
            }
          }
        }
      }
      break;
    case VK_F10:
      break;
    case 'S':
      break;
    case 'V':
      break;
    case 'F':
      break;
    case 'P':
      break;
    case 'T':
      break;
    case 'X':
      deschis = false;
      break;
    }



  }
  cout << counter;
  return 0;
}

1 个答案:

答案 0 :(得分:1)

取决于Windows如何表示按键。

如果Windows使用两个字符表示功能键,则不仅需要简单的开关,还需要检测两个字符(例如0x1b,0x4A)。

将按键处理为消息可能更容易。 switch可以用于不同的消息值。

注意:消息值可能与键盘输入的值不同。

OP需要进一步调查。推荐Petzold撰​​写的Windows书。