Project Perfect Mod Forums
:: Home :: Get Hosted :: PPM FAQ :: Forum FAQ :: Privacy Policy :: Search :: Memberlist :: Usergroups :: Register :: Profile :: Log in to check your private messages :: Log in ::


The time now is Sat Apr 20, 2024 1:15 am
All times are UTC + 0
C++ Question
Moderators: Global Moderators, Offtopic Moderators
Post new topic   Reply to topic Page 1 of 1 [6 Posts] Mark the topic unread ::  View previous topic :: View next topic
Author Message
iceman559
Stealth Laser Trooper


Joined: 26 Jul 2003
Location: AZ, US

PostPosted: Sat Sep 27, 2003 5:41 am    Post subject:  C++ Question Reply with quote  Mark this post and the followings unread

ok, are the following code snippets C or C++ or even if they are real code?

Code:
HFONT hf;
    HDC hdc;
    long lfHeight;
   
    hdc = GetDC(NULL);
    lfHeight = -MulDiv(12, GetDeviceCaps(hdc, LOGPIXELSY), 72);
    ReleaseDC(NULL, hdc);

    hf = CreateFont(lfHeight, 0, 0, 0, 0, TRUE, 0, 0, 0, 0, 0, 0, 0, "Times New Roman");

    if(hf)
    {
        DeleteObject(g_hfFont);
        g_hfFont = hf;
    }
    else
    {
        MessageBox(hwnd, "Font creation failed!", "Error", MB_OK | MB_ICONEXCLAMATION);
    }


and

Code:
char szSize[100];
    char szTitle[] = "These are the dimensions of your client area:";
    HFONT hfOld = SelectObject(hdc, hf);

    SetBkColor(hdc, g_rgbBackground);
    SetTextColor(hdc, g_rgbText);

    if(g_bOpaque)
    {
        SetBkMode(hdc, OPAQUE);
    }
    else
    {
        SetBkMode(hdc, TRANSPARENT);
    }

    DrawText(hdc, szTitle, -1, prc, DT_WORDBREAK);

    wsprintf(szSize, "{%d, %d, %d, %d}", prc->left, prc->top, prc->right, prc->bottom);
    DrawText(hdc, szSize, -1, prc, DT_SINGLELINE | DT_CENTER | DT_VCENTER);

    SelectObject(hdc, hfOld);

_________________
<b>::Counter-Strike File Source</b>
<b>::The Army of Chaos Empire</b>


Back to top
View user's profile Send private message Send e-mail Visit poster's website Skype Account AIM Address
Banshee
Supreme Banshee


Also Known As: banshee_revora (Steam)
Joined: 15 Aug 2002
Location: Brazil

PostPosted: Sat Sep 27, 2003 5:44 pm    Post subject: Reply with quote  Mark this post and the followings unread

Looks more like C++ than C... btw, what is this hdc type of variable?

Back to top
View user's profile Send private message Visit poster's website Skype Account
iceman559
Stealth Laser Trooper


Joined: 26 Jul 2003
Location: AZ, US

PostPosted: Sat Sep 27, 2003 6:15 pm    Post subject: Reply with quote  Mark this post and the followings unread

i dont know, thats y I was asking, i tried embedding it into my program, but it doesnt work it says none of the variables are declared, so i try declaring them, and it doesnt work, heres where i got it from, http://www.winprog.org/tutorial/fonts.html

_________________
<b>::Counter-Strike File Source</b>
<b>::The Army of Chaos Empire</b>


Back to top
View user's profile Send private message Send e-mail Visit poster's website Skype Account AIM Address
Banshee
Supreme Banshee


Also Known As: banshee_revora (Steam)
Joined: 15 Aug 2002
Location: Brazil

PostPosted: Sat Sep 27, 2003 7:31 pm    Post subject: Reply with quote  Mark this post and the followings unread

This is C++ for programs like Borland C++ or Visual C++

Back to top
View user's profile Send private message Visit poster's website Skype Account
iceman559
Stealth Laser Trooper


Joined: 26 Jul 2003
Location: AZ, US

PostPosted: Sat Sep 27, 2003 8:11 pm    Post subject: Reply with quote  Mark this post and the followings unread

no, C++ is the same. It wouldn't change code just because u have a diff program. also, it just has help for those programs. all the other code works fine with Dev, its just the font stuff

_________________
<b>::Counter-Strike File Source</b>
<b>::The Army of Chaos Empire</b>


Back to top
View user's profile Send private message Send e-mail Visit poster's website Skype Account AIM Address
John Galt
Commander


Joined: 01 Aug 2003
Location: Galt's Gulch

PostPosted: Sun Sep 28, 2003 6:11 am    Post subject: Reply with quote  Mark this post and the followings unread

hdc means Handle Device Context.

Delphi Help -> WinAPI wrote:

Property Handle: HDC;

The Handle property specifies the Windows GDI handle to the device context for this canvas.

Set Handle to the HDC for the device context the canvas must draw into. When a windowed control responds to a Windows paint message, the HDC for drawing is passed in to the PaintWindow method. In other cases, an HDC can be obtained for a window by calling the GetDeviceContext method of a control. Additionally, Windows provides API calls to obtain an HDC for a printer or for a memory image.


Sorry, I'm not familiar with C, so I can't help you any more...

Back to top
View user's profile Send private message Visit poster's website Skype Account
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [6 Posts] Mark the topic unread ::  View previous topic :: View next topic
 
Share on TwitterShare on FacebookShare on Google+Share on DiggShare on RedditShare on PInterestShare on Del.icio.usShare on Stumble Upon
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 © phpBB Group

[ Time: 0.1636s ][ Queries: 11 (0.0082s) ][ Debug on ]