Fl_Window* winTest = NULL;
const char* strSplash[] = { "Code by Raphael Kim, (C)2018, Copyright\n",
"Programming FLTK is funny !\n",
"Thank you." };
int main (int argc, char ** argv)
{
Fl_RGB_Image* imgBg = new Fl_PNG_Image( "testbg.png" );
if ( imgBg == NULL )
return 0;
int img_w = imgBg->w();
int img_h = imgBg->h();
winTest = new Fl_Window( img_w, img_h, "Splash Test" );
if ( winTest != NULL )
{
winTest->color( 0 );
winTest->end();
winTest->show();
// Make window layered splash for Windows32.
HWND hWnd = fl_xid( winTest );
HDC hDC = GetDC( hWnd );
POINT ptPos = {0,0};
SIZE sizeWnd = { winTest->w(), winTest->h() };
SetWindowLong( hWnd, GWL_EXSTYLE,
GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
HDC hdcMem = CreateCompatibleDC( hDC );
HBITMAP hbmp = GetHBMPfromFlRGBImg( imgBg );
fl_begin_offscreen( hbmp );
imgBg->draw( 0, 0 );
fl_font( FL_HELVETICA_ITALIC, 18 );
fl_color( 0xFFFFFFFF );
int tput_x = imgBg->w() / 10;
int tput_y = imgBg->h() / 2;
for( int cnt=0; cnt<3; cnt++ )
{
fl_draw( strSplash[cnt], tput_x, tput_y );
tput_y += 20;
}
fl_end_offscreen();
HGDIOBJ oldBitmap = SelectObject(hdcMem, hbmp);
BLENDFUNCTION blend = {0};
blend.BlendOp = AC_SRC_OVER;
blend.SourceConstantAlpha = 255;
blend.AlphaFormat = AC_SRC_ALPHA;
UpdateLayeredWindow( hWnd, NULL,
&ptPos, &sizeWnd,
hdcMem, &ptPos,
0, /// RGB(255,255,255),
&blend,
ULW_ALPHA );
RedrawWindow( hWnd,
NULL, NULL,
RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN );
SelectObject( hdcMem, oldBitmap );
DeleteObject( hbmp );
}
return Fl::run();
}