Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8046101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:42:35+00:00 2026-06-05T05:42:35+00:00

i’ve hit another wall in my printText function and have been searching for a

  • 0

i’ve hit another wall in my printText function and have been searching for a while now for a solution with no luck.

Basically, the printText function is called within the WM_PAINT message to paint text to a win32 window. It works fine but only for one call. If i try to call the function for a second time with different parameters nothing appears to happen.

Im sure i am just completely overlooking something again but I can’t see what it could possibly be.

the function is as follows:

void controls::printText(unsigned char R, unsigned char G, unsigned char B, int x, int y, LPCSTR text, HWND parent, PAINTSTRUCT pss, HDC hdc)
{

    hdc = BeginPaint(parent, &pss);
    SetBkMode(hdc, TRANSPARENT);
    SetTextColor(hdc, RGB(R,G,B));
    TextOut(hdc, x, y, text, strlen(text));     
    EndPaint(parent, &pss);

}

It is inside a ‘controls’ class and the calls are as follows:

HDC hdc, hdc2;
PAINTSTRUCT ps, ps2;

ctrls->printText(255,0,0,30,50,"Test text",hWnd,ps,hdc);
ctrls->printText(255,0,0,30,80,"test text 2",hWnd,ps2,hdc2);

There are two(2) HDC and PAINTSTRUCT declarations as I’ve been playing with the code trying to find a solution; I tried removing the paintstruct and hdc arguments from the function and having them declared inside the function as locals (which doesn’t make a great deal of sense to me) with no success.

Basically, the first line,

ctrls->printText(255,0,0,30,50,"Test text",hWnd,ps,hdc);

Will do as it should and print “test text”, in red, starting at (30,50) but the second line does not print anything. If i remove the first line, however, the second line works fine also.

please note: i may have used paint and print synonymously here whilst describing.

I think i’ve included everything relevant here but if any other code is needed just let me know and i’ll post it as soon as i see the message 🙂

Thanks in advance again guys,
your time and answers are much appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T05:42:36+00:00Added an answer on June 5, 2026 at 5:42 am

    The documentation quite clearly states

    An application should not call BeginPaint except in response to a
    WM_PAINT message.

    So you should call it once per WM_PAINT and no more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.