Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

JSG

DrawText Question.

This topic is 5479 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 am playing around with windows GDI and I am curious about an error I get. This is a section of my code. RECT myrect = {0,0,10,10}; //The DC is correct. DrawText(hMainDC, "Hello There", 11, myrect, DT_CENTER); I get an error saying that: error C2664: ''DrawTextA'' : cannot convert parameter 4 from ''struct tagRECT'' to ''struct tagRECT *'' What am I doing wrong?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Do this:

DrawText(hMainDC, "Hello There", 11, &myrect, DT_CENTER);

You just needed to add an "&" before myrect.

Share this post


Link to post
Share on other sites
Hi brother!!

I''d like to add something to the previous answer you received:
putting the ''&'' actually gives the address of the variable and not the variable itself, so that the function can work with the variable itself instead of working with of a copy that would have the same value. This way, you can save some CPU time as well as some bytes in memory because the copy of the variable isnt performed. Furthermore, it allows the function to make the modifications on the variable itself (otherwise it''d keep its old value and things would look kinda weird) and that method is especially handy when you re using big variables (eg. big structures, arrays or objects, and so on).

Hope I ve been useful.

Prog, Sex & Rock''n''Roll :
I don''t like the Prog but the prog likes me.

Share this post


Link to post
Share on other sites
Yes thanks. I knew about the refrence but I gues it just didnt click when I was reading the error.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!