C++ Directx错误DrawTextA和LPCSTR以及HDC

C++ Directx错误DrawTextA和LPCSTR以及HDC,c++,directx,directx-9,lpcstr,C++,Directx,Directx 9,Lpcstr,在调试模式下,我得到以下结果: Severity Code Description Project File Line Error C2660 'DrawTextA': function does not take 4 arguments Win32Project6 c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp 41 Sever

在调试模式下,我得到以下结果:

Severity    Code    Description Project File    Line
Error   C2660   'DrawTextA': function does not take 4 arguments Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   41

Severity    Code    Description Project File    Line
Error   C2065   'i': undeclared identifier  Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   53

Severity    Code    Description Project File    Line
Error       IntelliSense: argument of type "const char *" is incompatible with parameter of type "HDC"  Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   41

Severity    Code    Description Project File    Line
Error       IntelliSense: argument of type "int" is incompatible with parameter of type "LPCSTR"    Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   41
Severity    Code    Description Project File    Line
Error       IntelliSense: argument of type "D3DCOLOR" is incompatible with parameter of type "LPRECT"   Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   41
Severity    Code    Description Project File    Line
Error       IntelliSense: too few arguments in function call    Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   41

Severity    Code    Description Project File    Line
Error   C2065   'i': undeclared identifier  Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   53

Severity    Code    Description Project File    Line
Error   C2228   left of '.name' must have class/struct/union    Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   53


Severity    Code    Description Project File    Line
Error   C2228   left of '.c_str' must have class/struct/union   Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   53
Severity    Code    Description Project File    Line
Error   C2660   'DrawTextA': function does not take 4 arguments Win32Project6   c:\users\dani\documents\visual studio 2015\projects\win32project6\win32project6\hacks.cpp   53

Severity    Code    Description Project File    Line
Error       IntelliSense: identifier "i" is undefined   Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   53


Severity    Code    Description Project File    Line
Error       IntelliSense: argument of type "int" is incompatible with parameter of type "LPCSTR"    Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   53

Severity    Code    Description Project File    Line
Error       IntelliSense: argument of type "D3DCOLOR" is incompatible with parameter of type "LPRECT"   Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   53


Severity    Code    Description Project File    Line
Error       IntelliSense: too few arguments in function call    Win32Project6   c:\Users\Dani\Documents\Visual Studio 2015\Projects\Win32Project6\Win32Project6\Hacks.cpp   53
Hacks.cpp的代码

    #include "Hacks.h"

    int MenuIndex;

    D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
    D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
    D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 0, 255);
    D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
    D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);

    void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont)
    {
        D3DXCreateFont(d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
            OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
            choiceFont.c_str(), &Font);
    }

    void Hacks::InitializeMenuItems()
    {
        hack[WALLHACK].name = "WallHack and chams";
        hack[CUSTOM_CROSSHAIR].name = "Show custom crosshair";
        hack[NO_RECOIL].name = "No Recoil";
        hack[UNLIM_AMMO].name = "Unlimited equipment";
        hack[AUTO_FIRE].name = "Auto Fire";
        hack[HIDE_MENU].name = "Hide menu [INSERT]";
        hack[HIDE_MENU].on = false;
    }

    void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color)
    {
        RECT rct = { x - 120, y + 120, y + 15 };
        Font->DrawTextA(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Color);
    }

    void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
    {
        if (!hack[HIDE_MENU].on)
        {
            DrawFilledRectangle(55, 20, 200, 50, fontBlue, d3dDevice);
            DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice);
            DrawTextA("GAME", 190, 30, fontWhite);

            DrawFilledRectangle(30, 55, 250, (62 * MAX_MENU_ITEMS), fontBlue, d3dDevice);
            DrawBorderBox(30, 55, 250, (62 * MAX_MENU_ITEMS), 6, fontBlack, d3dDevice);

            int y = 40;
            for (int i = 0; i < MAX_MENU_ITEMS; i++)
            {
                DrawFilledRectangle(45, 30 + y, 220, 40, hack[i].on ? fontGreen : fontRed, d3dDevice);
                DrawBorderBox(45, 30 + y, 220, 40, 4, fontBlack, d3dDevice);
            }

            DrawTextA(hack[i].name.c_str(), 170, 39 + y, fontBlack);
            y + 50;
        }
    }

    void Hacks::DrawFilledRectangle(int x, int y, int width, int height, D3DCOLOR color, IDirect3DDevice9 *d3dDevice)
    {

    }

    void Hacks::DrawBorderBox(int x, int y, int width, int height, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice)
    {

    }

    void Hacks::KeyboardInput()
    {

    }


CODE for Hacks.h

#include "d3d9.h"
#include <ctime>
#include <iostream>

#define D3DHOOK_TEXTURES
#define MAX_MENU_ITEMS 6

#define WALLHACK 0
#define CUSTOM_CROSSHAIR 1
#define NO_RECOIL 2
#define UNLIM_AMMO 3
#define AUTO_FIRE 4
#define HIDE_MENU 5

/*DEFINITION FOR OUT CHAMS*/




class Hacks
{
public:
    int m_Stride;

    void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont);
    void Hacks::InitializeMenuItems();
    void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color);
    void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice);
    void Hacks::DrawFilledRectangle(int x, int y, int width, int height,D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
    void Hacks::DrawBorderBox(int x, int y, int width, int height, int thickness, D3DCOLOR color, IDirect3DDevice9 *d3dDevice);
    void Hacks::KeyboardInput();

    LPDIRECT3DTEXTURE9 texRed;
    LPDIRECT3DTEXTURE9 textGreen;

    LPDIRECT3DTEXTURE9 textBlue;
    LPDIRECT3DTEXTURE9 textWhite;

    D3DVIEWPORT9 ViewPort;

    LPD3DXFONT Font;

    struct d3dMenuHack
    {
        bool on;
        std::string name;
    };

    d3dMenuHack hack[MAX_MENU_ITEMS];

};
#包括“Hacks.h”
国际货币指数;
D3DCOLOR fontRed=D3DCOLOR_ARGB(255,255,0,0);
D3DCOLOR fontGreen=D3DCOLOR_ARGB(255,0,255,0);
D3DCOLOR fontBlue=D3DCOLOR_ARGB(255,0,0,255);
D3DCOLOR fontWhite=D3DCOLOR_ARGB(255、255、255、255);
D3DCOLOR fontBlack=D3DCOLOR_ARGB(255,0,0,0);
void Hacks::CreateFont(IDirect3DDevice9*d3dDevice,std::string choiceFont)
{
D3DXCreateFont(d3dDevice,20,0,FW_粗体,0,FALSE,默认字符集,
输出默认精度、默认质量、默认音高,
choiceFont.c_str(),&Font);
}
void Hacks::InitializeMenuItems()
{
hack[WALLHACK].name=“WALLHACK和chams”;
hack[CUSTOM_CROSSHAIR].name=“Show CUSTOM CROSSHAIR”;
攻击[无后坐].name=“无后坐”;
黑客[UNLIM_AMMO].name=“无限装备”;
hack[AUTO_FIRE].name=“AUTO FIRE”;
hack[HIDE_MENU].name=“HIDE MENU[INSERT]”;
hack[HIDE_MENU].on=false;
}
void Hacks::Draw_Text(LPCSTR TextToDraw、int x、int y、D3DCOLOR Color)
{
RECT rct={x-120,y+120,y+15};
Font->DrawTextA(NULL,TextToDraw,-1,&rct,DT_NOCLIP,Color);
}
void Hacks::DrawMenu(IDirect3DDevice9*d3dDevice)
{
如果(!hack[隐藏菜单].on)
{
DrawFilledRectangle(55,20,200,50,fontBlue,d3dDevice);
DrawBorderBox(55、20、200、50、4、fontBlack、d3dDevice);
DrawTextA(“游戏”,190,30,fontWhite);
DrawFilledRectangle(30,55,250,(62*最大菜单项),fontBlue,D3D设备);
DrawBorderBox(30、55、250,(62个最大菜单项),6个,fontBlack,D3D设备);
int y=40;
对于(int i=0;i
是的,我将它设置为多字节字符集,当我从教程的创建者那里复制代码时,它工作得非常好,但问题是,它们完全相同的代码100%相同,但其中一个工作,另一个不工作,设置设置设置为win 32,调试和发布都会出现错误

这是教程代码:

#include "hacks.h";


/*--------------CHEAT RELATED VARS-------------------*/

int MenuIndex = 0;

// Create a colour for the text 
D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);  
D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);    
D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 42, 255);    
D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);  
D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);  
/*---------------------------------------------------*/


void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont)
{
        D3DXCreateFont( d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET, 
                OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, 
                choiceFont.c_str(), &m_font );
}


void Hacks::InitializeMenuItems()
{
    hack[WALLHACK].name = " WallHack and chams";
    hack[CUSTOM_CROSSHAIR].name = " Show custom crosshair";
    hack[NO_RECOIL].name = " No Recoil";
    hack[UNLIM_AMMO].name = " Unlimited equipment";
    hack[AUTO_FIRE].name = "All guns Automatic";
    hack[HIDE_MENU].name = " Hide hack [INSERT]";
    //make the hack visible by default
    hack[HIDE_MENU].on = false; //shows hack by default
}

void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
{
    if(!hack[HIDE_MENU].on)
    {
        //Add game name here, and put border around it
        DrawFilledRect( 55, 20, 200, 50, fontBlue, d3dDevice );
        DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice );
        Draw_Text("COD 4 MP hack", 190, 30, fontWhite);

        //draw back of our hack, transparent black
        DrawFilledRect( 30, 55, 250, (62*MAX_MENU_ITEMS),fontBlue, d3dDevice );
        //draw hack border
        DrawBorderBox(30, 55, 250, (62*MAX_MENU_ITEMS), 6/*was 6*/, fontBlack, d3dDevice );
        //Reset our time and update the text again in 2 secs
        int y = 40;
        for(int i = 0; i < MAX_MENU_ITEMS; i ++)
        {
            //Draw each box's back colour, this will be based on whether the hack is on e.g.
            //red means off and green means on
            DrawFilledRect( 45, 30+y, 220, 40, hack[i].on ? fontGreen : fontRed, d3dDevice );

            //draw box Around Each hack item If the item is highlighted it will show with a white border
            DrawBorderBox(45, 30+y, 220, 40, 4, fontBlack, d3dDevice );

            //draw White border to show the user which hack item is currently selected
            if(MenuIndex == i)
            {
                DrawBorderBox(41, 26+y, 228, 48, 4, fontWhite, d3dDevice );
            }

            //Ternary at its finest, if the  hack is on we display the text colour in green
            //otherwise its green
            //Draw_Text(hack[i].KeyAssigned.c_str(), 160 , 32+y, fontWhite);
            Draw_Text(hack[i].name.c_str(), 170 , 39+y, fontBlack);
            //Draw_Text(hack[i].state. c_str(), 355 , 32+y, hack[i].on ? fontGreen : fontRed);
            //used to position the next item below by 30 height units
            y+= 50;
        }
        Draw_Text("Select using arrow keys", 170, ((62*MAX_MENU_ITEMS)+7), fontWhite);
        Draw_Text("Turn ON/OFF [END] key", 170, ((62*MAX_MENU_ITEMS)+27), fontWhite);
    }
}

void Hacks::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *pDevice)
{
    //Top horiz line
    DrawFilledRect( x, y, w, thickness,  Colour, pDevice );
    //Left vertical line
    DrawFilledRect( x, y, thickness, h, Colour, pDevice );
    //right vertical line
    DrawFilledRect( (x + w), y, thickness, h, Colour, pDevice );
    //bottom horiz line
    DrawFilledRect( x, y + h, w+thickness, thickness, Colour, pDevice );
}


//We receive the 2-D Coordinates the colour and the device we want to use to draw those colours with
void Hacks::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* dev)
{
    //We create our rectangle to draw on screen
    D3DRECT BarRect = { x, y, x + w, y + h }; 
    //We clear that portion of the screen and display our rectangle
    dev->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}


void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour)
{
    // Create a rectangle to indicate where on the screen it should be drawn
    RECT rct = {x- 120, y, x+ 120, y + 15};

    // Draw some text 
    m_font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Colour );
}


void Hacks::KeyboardInput()
{
    if(GetAsyncKeyState(VK_UP)&1)
    {
        if(MenuIndex > 0)
        {
            MenuIndex--;
        }
    }

    if(GetAsyncKeyState(VK_DOWN)&1)
    {
        if(MenuIndex < MAX_MENU_ITEMS-1)
        {
            MenuIndex++;
        }
    }

    if(GetAsyncKeyState(VK_END)&1)
    {
        hack[MenuIndex].on = !hack[MenuIndex].on;
        if(MenuIndex == NO_RECOIL)
        {
            //this is where we write memory, these are nop values
        }
        if(MenuIndex == UNLIM_AMMO)
        {
            //this is where we write memory
        }
    }

    if(GetAsyncKeyState(VK_INSERT)&1)
    {
        //TEXT DOESNT CHANGE as the hack is either hidden or not 
        //and if its hidden you cant tell the user to turn hack on(at least we wont)
        hack[HIDE_MENU].on = !hack[HIDE_MENU].on;
    }
}
#包括“hacks.h”;
/*--------------作弊相关变量-------------------*/
int MenuIndex=0;
//为文本创建颜色
D3DCOLOR fontRed=D3DCOLOR_ARGB(255,255,0,0);
D3DCOLOR fontGreen=D3DCOLOR_ARGB(255,0,255,0);
D3DCOLOR fontBlue=D3DCOLOR_ARGB(255,0,42,255);
D3DCOLOR fontWhite=D3DCOLOR_ARGB(255、255、255、255);
D3DCOLOR fontBlack=D3DCOLOR_ARGB(255,0,0,0);
/*---------------------------------------------------*/
void Hacks::CreateFont(IDirect3DDevice9*d3dDevice,std::string choiceFont)
{
D3DXCreateFont(d3dDevice,20,0,FW_粗体,0,FALSE,默认字符集,
输出默认精度、默认质量、默认音高,
choiceFont.c_str(),&m_font);
}
void Hacks::InitializeMenuItems()
{
hack[WALLHACK].name=“WALLHACK和chams”;
hack[CUSTOM_CROSSHAIR].name=“Show CUSTOM CROSSHAIR”;
攻击[无后坐].name=“无后坐”;
黑客[UNLIM_AMMO].name=“无限装备”;
hack[AUTO_FIRE].name=“所有枪支自动”;
hack[HIDE_MENU].name=“HIDE hack[INSERT]”;
//默认情况下使黑客可见
hack[HIDE_MENU].on=false;//默认显示hack
}
void Hacks::DrawMenu(IDirect3DDevice9*d3dDevice)
{
如果(!hack[隐藏菜单].on)
{
//在此处添加游戏名称,并在其周围添加边框
DrawFilledRect(55,20,200,50,fontBlue,d3dDevice);
DrawBorderBox(55、20、200、50、4、fontBlack、d3dDevice);
绘制文本(“COD 4 MP hack”,190,30,fontWhite);
//把我们的黑头发往后缩,透明的黑色
DrawFilledRect(30、55、250,(62个最大菜单项),fontBlue,D3D设备);
//画黑边
DrawBorderBox(30、55、250,(62个最大菜单项),6/*为6*/,fontBlack,d3dDevice);
//重置时间并在2秒内再次更新文本
int y=40;
对于(int i=0;i