Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows splash screen using GDI+
    primarykey
    data
    text
    <p>The eventual aim of this is to have a splash screen in windows that uses transparency but that's not what I'm stuck on right now.</p> <p>In order to create a transparent window, I'm first trying to composite the splash screen and text on an off screen buffer using GDI+. </p> <p>Currently, I'm just trying to composite the buffer and display it in response to a 'WM_PAINT' message. This isn't working out at the moment; all I see is a black window.</p> <p>I imagine I've misunderstood something with regards to setting up render targets in GDI+ and then rendering them (I'm trying to render the screen using straight forward GDI blit)</p> <p>Anyway, here's the code so far:</p> <pre><code>//my window initialisation code void MyWindow::create_hwnd(HINSTANCE instance, const SIZE &amp;dim) { DWORD ex_style = WS_EX_LAYERED ; //eventually I'll be making use of this layerd flag m_hwnd = CreateWindowEx( ex_style, szFloatingWindowClass , L"", WS_POPUP , 0, 0, dim.cx, dim.cy, null, null, instance, null); m_display_dc = GetDC(NULL); //This was sanity check test code - just loading a standard HBITMAP and displaying it in WM_PAINT. It worked fine //HANDLE handle= LoadImage(NULL , L"c:\\test_image2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_gdip_offscreen_bm = new Gdiplus::Bitmap(dim.cx, dim.cy); m_gdi_dc = Gdiplus::Graphics::FromImage(m_gdip_offscreen_bm);//new Gdiplus::Graphics(m_splash_dc );//window_dc ;m_splash_dc //this draws the conents of my splash screen - this works if I create a GDI+ context for the window, rather than for an offscreen bitmap. //For all I know, it might actually be working but when I try to display the contents on screen, it shows a black image draw_all(); //this is just to show that drawing something simple on the offscreen bit map seems to have no effect Gdiplus::Pen pen(Gdiplus::Color(255, 0, 0, 255)); m_gdi_dc-&gt;DrawLine(&amp;pen, 0,0,100,100); DWORD last_error = GetLastError(); //returns '0' at this stage } </code></pre> <p>And here's the snipit that handles the WM_PAINT message:</p> <pre><code>---8&lt;----------------------- //Paint message snippit case WM_PAINT: { BITMAP bm; PAINTSTRUCT ps; HDC hdc = BeginPaint(vg-&gt;m_hwnd, &amp;ps); //get the HWNDs DC HDC hdcMem = vg-&gt;m_gdi_dc-&gt;GetHDC(); //get the HDC from our offscreen GDI+ object unsigned int width = vg-&gt;m_gdip_offscreen_bm-&gt;GetWidth(); //width and height seem fine at this point unsigned int height = vg-&gt;m_gdip_offscreen_bm-&gt;GetHeight(); BitBlt(hdc, 0, 0, width, height, hdcMem, 0, 0, SRCCOPY); //this blits a black rectangle DWORD last_error = GetLastError(); //this was '0' vg-&gt;m_gdi_dc-&gt;ReleaseHDC(hdcMem); EndPaint(vg-&gt;m_hwnd, &amp;ps); //end paint return 1; } ---8&lt;----------------------- </code></pre> <p>My apologies for the long post. Does anybody know what I'm not quite understanding regarding how you write to an offscreen buffer using GDI+ (or GDI for that matter)and then display this on screen?</p> <p>Thank you for reading.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload