Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ help

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Wed Apr 16, 2008 10:27 pm    Post subject: C++ help Reply with quote

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Apr 16, 2008 10:40 pm    Post subject: Reply with quote

Just use the TEXT or _T macro.

#include "tchar.h"
FindWindow(NULL, _T("QUAKE3"));

and GDI is pretty flickery ingame.
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Wed Apr 16, 2008 10:55 pm    Post subject: Reply with quote

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Apr 16, 2008 10:59 pm    Post subject: Reply with quote

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
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Wed Apr 16, 2008 11:06 pm    Post subject: Reply with quote

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
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Wed Apr 16, 2008 11:21 pm    Post subject: Reply with quote

HWND target = NULL;
TCHAR *window = _T("icculus.org/quake3");

target = FindWindow(NULL, window);
Back to top
View user's profile Send private message
Snootae
Grandmaster Cheater
Reputation: 0

Joined: 16 Dec 2006
Posts: 969
Location: --->

PostPosted: Wed Apr 16, 2008 11:43 pm    Post subject: Reply with quote

it works Razz

thanks slovach!

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites