DrawString Funktion

05/04/2015 21:12 Wirbelwind94#1
Guten Abend,
ich versuche mich gerade an den Draw Funktionen, hab da leider keine guten Seiten gefunden wo es gut erklärt ist und etwas zusammengewürfelt.

 
#include <iostream>
#include <ddraw.h>
int x{250};
int y{250};
const char* text{ "Hallo Arma 3" };
char * distanceInfo;
COLORREF TextCOLOR;
HDC HDC_Desktop;
void DrawString(int x, int y, COLORREF TextCOLOR, const char* text)
{
SetTextAlign(HDC_Desktop, TA_CENTER
SetBkColor(HDC_Desktop, RGB(0, 0, 0));
SetBkMode(HDC_Desktop, TRANSPARENT);
SetTextColor(HDC_Desktop, TextCOLOR);
TextOutA(HDC_Desktop, x, y, text, strlen(text));
DeleteObject(Font);
}
int main()
{
TextCOLOR = RGB(255, 255, 0);
DrawString(x, y, TextCOLOR, distanceInfo);
return 0;
}

Folgende Fehlermeldung bekomme ich..
-> error LNK1168: "C:\Users\Wirbelwind\Desktop\Arma3\Debug\Arma3.exe " kann nicht zum Schreiben geöffnet werden.

Bitte mir erklären warum sie kommt und wie ich es beheben kann.
Wenn jemand eine Seite hat wo es sehr gut erklärt ist mir bitte auch schreiben.

Lg Wirbelwind
05/04/2015 21:31 _asm#2
Ist ein Link Fehler. Compile dein Projekt während Arma3 nicht geöffnet ist.
05/04/2015 21:56 Wirbelwind94#3
Ja Danke ist jetz weg, aber hab noch eine weitere Fehlermeldung..
-> Ausnahmefehler bei 0x556C4380 (msvcr120d.dll) in Projekt1.exe: 0xC0000005: Zugriffsverletzung beim Lesen an Position 0x00000000

Fehlermeldung kommt in einen seperaten Fenster

und zeigt somit nichts an.
05/04/2015 22:00 snow#4
Quote:
Code:
char * distanceInfo;
Quote:
Code:
DrawString(x, y, TextCOLOR, distanceInfo);
Du übergibst ja auch keine gültige Adresse.
05/05/2015 21:33 Wirbelwind94#5
Ich habs zur Zeit so..

Code:
#include <iostream>
#include <ddraw.h>
 
int x{250};
int y{250};
const char* text1{ "Hallo Arma 3" };
 
COLORREF TextCOLOR;
HDC HDC_Desktop;
HFONT Font;
HWND TargetWnd;
 
void DrawString(int x, int y, COLORREF TextCOLOR, const char* text)
{
    SetTextAlign(HDC_Desktop, TA_CENTER | TA_NOUPDATECP);
    SetBkColor(HDC_Desktop, RGB(255, 0, 0));
    SetTextColor(HDC_Desktop, TextCOLOR);
    SelectObject(HDC_Desktop, Font);
    TextOutA(HDC_Desktop, x, y, text, strlen(text));
    DeleteObject(Font);
}
 
 
int main()
{
    TargetWnd = FindWindow(0, "Arma 3");
    HDC HDC_Desktop = GetDC(TargetWnd);
    TextCOLOR = RGB(255, 255, 0);
    DrawString(x, y, TextCOLOR, text1);
    system("PAUSE");
}
Dennoch zeigt es bis jetz nichts an..

Lg Wirbelwind