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 Loading Font

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

Joined: 09 Jan 2008
Posts: 84

PostPosted: Sat Jan 17, 2009 7:12 am    Post subject: [C++] Help Loading Font Reply with quote

how can i load and use font from the resource file (.rc) ?
_________________
Code:
XXXXXX      XXXXXX
   XXXXX  XXXXX
     XXXXXXXX
    D I R E C T
     XXXXXXXX
   XXXXX  XXXXX
XXXXXX      XXXXXX
      GameDev
Back to top
View user's profile Send private message
aquaboy007
Expert Cheater
Reputation: 0

Joined: 14 May 2006
Posts: 199

PostPosted: Sat Jan 17, 2009 7:39 am    Post subject: Reply with quote

There are 2 threads in search n destroy forums about this... I'll tell you what I do anyway...

you need to first get the logfont structure of the font you need. Read here:
http://www.codeguru.com/cpp/g-m/gdi/fonthandlinganddetection/article.php/c155

then add the font to your resource file. just like an icon. the type is "FONT" and the id is 8 i think... its on MSDN.

then findresource, loadresource, lockresource. then use addfontmemresourceex and createfont(using the logfont details you got previously)

then you have to set the font for all controls, which are all windows themselves. so you need to use enumchildwindows using a proc, inside which you sendmessage WM_SETFONT.

here are some samples...

resource file...
Code:

IDR_FONT1                 FONT                      "visitor2.ttf"

resource header...
Code:

#define IDR_FONT1                       103


wm_initdialog
Code:

hRes = FindResource(hInst, MAKEINTRESOURCE(103), RT_FONT);
hResLoad = (HRSRC)LoadResource(hInst,hRes);
lpResLock = (char *)LockResource(hResLoad);
AddFontMemResourceEx(lpResLock,SizeofResource(NULL,hRes),0,&nbfonts);
hFont=CreateFont(-13,0,0,0,400,0,0,0,0,3,2,5,2,TEXT("Visitor TT2 BRK"));
EnumChildWindows( hWndDlg, (WNDENUMPROC) EnumChildProc, NULL);


finally enumchildproc
Code:
SendMessage( hwnd, WM_SETFONT, (WPARAM)hFont, MAKELPARAM( true, 0 ) );

_________________
x0r wrote:
So now there are versions which come with a certain level of BSODs?

DAEngine PREMIUM - Now with 20% less BSODs!
Back to top
View user's profile Send private message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sat Jan 17, 2009 9:35 pm    Post subject: Reply with quote

If he CreateFonts before the WM_CREATE message is processed, or the window is loaded at all i should say, won't it automatically set the font to his font?
_________________
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