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 7592411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:53:56+00:00 2026-05-30T20:53:56+00:00

I am using GDI+ to render login window. It all works fine on windows

  • 0

I am using GDI+ to render login window. It all works fine on windows 7, but
on windows XP (SP3 with all updates) there’s absolutely no output.

Code in WM_PAINT

PAINTSTRUCT ps;
HDC         hdc = BeginPaint( hwnd, &ps );
Graphics    *graphics= new Graphics( hdc );

if ( graphics->Clear( BACKGROUND_COLOR ) != Ok )
{
    LOGGER << "LoginWindow::Error clearing surface" << endl;
    goto clean;
}

if ( graphics->DrawImage( dialogHeader, 0, 0, dialogHeaderSize.cx, dialogHeaderSize.cy ) != Ok )
{
    LOGGER << "LoginWindow::Error drawing image" << endl;
    goto clean;
}

if ( graphics->DrawRectangle( dialogBorderPen, 0, 0, LOGIN_WINDOW_WIDTH - 1, LOGIN_WINDOW_HEIGHT - 1 ) != Ok )
{
    LOGGER << "LoginWindow::Error drawing rectangle" << endl;
    goto clean;
}

clean:
delete graphics;
EndPaint( hwnd, &ps );

dialogHeader is a .png image loded with following code:

dialogHeader = Bitmap::FromFile( imagePath );

GDI+ is initialized like this:

GdiplusStartupInput gdiplusStartupInput;
Status              gdiplusStatus;
ULONG_PTR           gdiplusToken;

gdiplusStatus = GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL );

if ( gdiplusStatus != Ok )
{
    LOGGER << "Main::Failed to initialize GDI+. ErrorCode=" << gdiplusStatus << endl;
    return 1;
}

Some known facts:

  • Painting code always executes successfully (verified with debugger – Visual Studio 2010)
  • Image is loaded without error
  • This occurs whether windows themes/aero is turned off or on
  • When I drag window on windows XP out of screen and then back the image is displayed like this:

http://imageshack.us/photo/my-images/851/winxp2.png/

Output on windows 7

http://imageshack.us/photo/my-images/824/win7p.png/

Output on windows XP

http://imageshack.us/photo/my-images/839/winxpu.png/

I hope someone can help. Thanks.

  • 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-05-30T20:53:57+00:00Added an answer on May 30, 2026 at 8:53 pm

    Turns out it was a combination of WS_EX_COMPOSITED style and GDI+ custom painting. If i enable this flag, nothing is initially drawn on windows XP. Only after resizing, things start appearing.

    After some research i found out its probably a bug. There is a workaround however:

    1. Create a DIB section HBITMAP (or you could try a standard HBITMAP) in memory and select it into an HDC (Look at CreateCompatibleBitmap and CreateCompatibleDC and also
      SelectObject).
    2. Make sure to create the HBITMAP the size of the client window.
    3. Now, use this “memory” HDC when calling:

      Graphics graphics (m_hDC); 
      
    4. When GDI+ is finished drawing to the memory HDC, then call BitBlt to draw the image on the pDC.

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

Sidebar

Related Questions

I'm attempting to display some text in my program using (say) Windows GDI and
I'm attempting to display some text in my program using (say) Windows GDI and
I'm using a third party library to render an image to a GDI DC
im trying to create ball animation using gdi but i can't get it working.
I have an image i.e. drawn using Windows GDI calls (24 bpp) and I
In Windows XP the Win32 API renders the controls using GDI/GDI+. Now I'm on
Summary Using Windows GDI to convert 24-bit color to indexed color, it seems GDI
In the Windows Api and GDI, you can use the default window background color
I'm painting this object in C# using GDI and I need to have precise
I'm developing a graph control in WPF. I have previously developed it using GDI

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.