如何在c++中获得头文件

How to get header files in c++

本文关键字:文件 c++      更新时间:2023-10-16

我想在dev c++中运行这段代码

void CheckMouseButtonStatus()
 {
   //Check the mouse left button is pressed or not
   if ((GetKeyState(VK_LBUTTON) & 0x80) != 0)
   {
        AfxMessageBox(_T("LButton pressed"));
   }
      //Check the mouse right button is pressed or not
   if ((GetKeyState(VK_RBUTTON) & 0x80) != 0)
  {
       AfxMessageBox(_T("RButton pressed"));
  }
  }

但是当我编译时,我得到这个错误

[Error] '_T'未在此范围内声明

[错误]'AfxMessageBox'未在此范围内声明

我使用#include <windows.h>作为标题。

我从https://vcpptips.wordpress.com/tag/check-if-mouse-is-pressed/

得到代码

AfxMessageBox是Visual Studio自带的MFC的一部分。不能在dev - c++中使用MFC。您可以使用Windows API调用MessageBox。

你应该这样做:

#include <afxwin.h>