 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Apr 16, 2008 10:27 pm Post subject: C++ help |
|
|
so i've got this code that pkedpker posted (thanks)
| Code: | void DrawMyText(char *windowcaption, float x, float y, char *mybuffer, int howmany)
{
gamewindowhandle = FindWindow(NULL, windowcaption); //get the game hwnd
HDC hdc = GetDC(gamewindowhandle);
SetBkColor(hdc,RGB(255,255,255)); //WHITE BACKGROUND
SetBkMode(hdc, TRANSPARENT); //MAKES BACKGROUND TRANSPARENT
//SO ALL YOU SEE IS THE TEXT
//MAKE SHADOW FOR TEXT (BLACK) and offset it by 1 pixel
SetTextColor(hdc,RGB(0,0,0));
TextOut(hdc,x+1,y+1, mybuffer,howmany);
//MAKE SECOND SHADOW FOR TEXT (BLACK) and offset it by 2 pixels
TextOut(hdc,x+2,y+2, mybuffer,howmany);
//PRINTS MY TEXT OVER THE BLACK TEXT IN RED, GIVES IT A DROP SHADOW APPEARANCE.
SetTextColor(hdc,RGB(255,0,0));
TextOut(hdc,x,y, mybuffer,howmany);
UpdateWindow(gamewindowhandle);
ReleaseDC(gamewindowhandle,hdc);
} |
but i've got errors, i know i can just use L"my string" for strings i set, but how could i do the equivalent to a variable, because adding the L just changes the name
i've tried doing this:
gamewindowhandle = FindWindow(NULL, (LPCWSTR)windowcaption); to make it a wide string, should this work properly? _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 16, 2008 10:40 pm Post subject: |
|
|
Just use the TEXT or _T macro.
#include "tchar.h"
FindWindow(NULL, _T("QUAKE3"));
and GDI is pretty flickery ingame. |
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Apr 16, 2008 10:55 pm Post subject: |
|
|
i need to use a variable though, so:
char *windowcaption
gamewindowhandle = FindWindow(NULL, windowcaption);
but _T just changes it to Lwindowcaption, which isn't declared, how do i do it with a variable? _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 16, 2008 10:59 pm Post subject: |
|
|
| Snootae wrote: | i need to use a variable though, so:
char *windowcaption
gamewindowhandle = FindWindow(NULL, windowcaption);
but _T just changes it to Lwindowcaption, which isn't declared, how do i do it with a variable? |
why do you need to?
anyway, TCHAR + _T |
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Apr 16, 2008 11:06 pm Post subject: |
|
|
well i need to use the function several times, with different text
hmm, could you give me an example, i don't really understand _________________
|
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Wed Apr 16, 2008 11:21 pm Post subject: |
|
|
HWND target = NULL;
TCHAR *window = _T("icculus.org/quake3");
target = FindWindow(NULL, window); |
|
| Back to top |
|
 |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Apr 16, 2008 11:43 pm Post subject: |
|
|
it works
thanks slovach! _________________
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|