Jump to content
  • Advertisement
Sign in to follow this  
POLSKASH

Can't set RECT values?

This topic is 4889 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have RECT* srcRectBg; declared in the private scope of a class. In the constructor's implementation, I have srcRectBg->left = 0; and it gives me an access violation. What the crap?

Share this post


Link to post
Share on other sites
Advertisement
The member itself is nothing but a pointer, are you sure it's been allocated properly (i.e. is pointing to valid data)?

Share this post


Link to post
Share on other sites
Hmm, I added srcRectBg = new Rectangle(0,0,0,640,480) above srcRectBg->left = 0;

Now I'm getting 100+ errors on the next piece of code in the exact same place?! This stuff compiled just fine before adding in the allocation.

Share this post


Link to post
Share on other sites
That does sound strange (your second post). Post some of your code. si it just that you wrote Rectungle instead of RECT?

One thing I would avoid is unnecessary use of memory allocation. Im almost 100% sure that you do NOT need to in your case.

Functions such as SetRect are misleading someitmes. They take a RECT* as a parameter, but that should not persuede you to declare your RECTS as pointers then allocate their memeory. Do this:

RECT rec;

SetRect( &rec,....);

Share this post


Link to post
Share on other sites
Rectangle? According to MSDN there's a Rectangle function at least but I can't find any matching type, especially not any inheriting from RECT.
If it really needs be allocated dynamically then shouldn't you allocate a RECT instead, and what's the fifth parameter supposed to do?

Share this post


Link to post
Share on other sites
Quote:
Original post by doynax
Rectangle? According to MSDN there's a Rectangle function at least but I can't find any matching type, especially not any inheriting from RECT.
If it really needs be allocated dynamically then shouldn't you allocate a RECT instead, and what's the fifth parameter supposed to do?


Damn it, i tried rating you up to 1337, but barely missed....

Share this post


Link to post
Share on other sites
sorry if im mistaken, but this is what your preceding posts tell about your code:

int myfunc
{
RECT* srcRectBg;
srcRectBg = new Rectangle(0,0,0,640,480);
}



isnt it supposed to be "srcRectBg = new RECT(...)" or sumthing like that?

Share this post


Link to post
Share on other sites
I don't think it's really necessary to dynamically allocated this structure. And, heh, I was calling Rectangle(HDC,left,...). It's not even related to what I'm doing. ;) I'm just gonna declare a RECT variable and not a pointer.

Share this post


Link to post
Share on other sites
And I get this error when doing srcRectBg = new RECT(0,0,640,480);

error C2661: 'tagRECT::tagRECT' : no overloaded function takes 4 parameters

Share this post


Link to post
Share on other sites
Quote:
Original post by POLSKASH
And I get this error when doing srcRectBg = new RECT(0,0,640,480);
The RECT structure doesn't have any constructor. Try simply allocating it instead.
srcRectBg = new RECT;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!