- Messages
- 51
- Country

Hello.
Thanks to n4gix, I have a working template for GDI.
I created a new subgauge and want to display a simple string on a rectangular bitmap.
For some reason, I can't get to display this string and I can't find the error...
Is this a problem if PELEMENT_STATIC_IMAGE, Graphics... have the same name in different sub-gauges ?
Here's the whole code :
I'm the kind of guy that spend 2 days searching for a missing coma so help is welcome ! ^^
Thanks
Thanks to n4gix, I have a working template for GDI.
I created a new subgauge and want to display a simple string on a rectangular bitmap.
For some reason, I can't get to display this string and I can't find the error...
Is this a problem if PELEMENT_STATIC_IMAGE, Graphics... have the same name in different sub-gauges ?
Here's the whole code :
Code:
[COLOR="DarkGreen"]char test_gauge_name[] = GAUGE_NAME;
extern PELEMENT_HEADER test_list;
extern MOUSERECT test_mouse_rect[];
GAUGE_CALLBACK Update;
GAUGE_HEADER_FS700( GAUGE_W, test_gauge_name, &test_list, \
test_mouse_rect, 0, 0, 0, 0 );
/////////////////////////////////////////////////////////////////////////////
MAKE_STATIC
(
test_image,
BMP_ECRAN,
NULL,
NULL,
IMAGE_USE_ERASE|IMAGE_USE_BRIGHT|IMAGE_CREATE_DIBSECTION,
0,
0,0
)
PELEMENT_HEADER test_next[] = { &test_image.header, NULL };
MAKE_STATIC
(
test_background,
BMP_ECRAN,
test_next,
0,
IMAGE_USE_TRANSPARENCY,
0,
0, 0
)
PELEMENT_HEADER test_list = &test_background.header;
/////////////////////////////////////////////////////////////////////////////
MOUSE_BEGIN( test_mouse_rect, HELP_NONE, 0, 0 )
MOUSE_END
//////////////////////AFFICHAGE GDI///////////////////////////////////////////
void FSAPI Update ( PGAUGEHDR pgauge, SINT32 service_id, UINT32 extra_data )
{
switch (service_id)
{
case PANEL_SERVICE_CONNECT_TO_WINDOW:
gdiPlusUsers++;
if(!init_gdiPlus)
{
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
init_gdiPlus = true;
}
break;
case PANEL_SERVICE_PRE_INITIALIZE:
break;
case PANEL_SERVICE_PRE_INSTALL:
break;
case PANEL_SERVICE_PRE_DRAW:
{ PELEMENT_STATIC_IMAGE pelement = (PELEMENT_STATIC_IMAGE)(pgauge->elements_list[0]->next_element[0]);
if (pelement)
{
HDC hdc = pelement->hdc;
PIXPOINT dim = pelement->image_data.final->dim;
if (hdc)
{
Graphics graphics(hdc);
dx = dim.x / 448;
dy = dim.y / 141;
graphics.ScaleTransform(dx,dy); //scale/resize ONCE only!
set_render_quality(&graphics);
SolidBrush whiteBrush(Color(255, (255*brt)/100, (255*brt)/100, (255*brt)/100));
//NOTE: you could also simply apply brt to the Alpha instead of each color!
//NOTE: for multi-gauge creation, it would be better to declare the Brushes, Pens,
//and Fonts used in the master .cpp file, then create them as need in each gauge.
Color Black(0,0,0);
graphics.Clear(Black);
FontFamily Quartz(L"Quartz");
Font LargeNumbers(&Quartz, 33, FontStyleBoldItalic, UnitPixel);
PointF pointPower(1, 1);
WCHAR string[] = L"Hello World";
swprintf(string, L"");
graphics.DrawString(string, -1, &LargeNumbers, pointPower, &whiteBrush);
} //end gauge_draw else clause
}
SET_OFF_SCREEN (pelement); //This is the command that sends the final drawing to the gauge display
}
break;
case PANEL_SERVICE_PRE_KILL:
break;
case PANEL_SERVICE_DISCONNECT:
gdiPlusUsers--;
if (init_gdiPlus && gdiPlusUsers == 0)
{
GdiplusShutdown(gdiplusToken);
init_gdiPlus = false;
}
break;
}
}
/////////////////////////////////////////////////////////////////////////////
#undef GAUGE_NAME
#undef GAUGEHDR_VAR_NAME
#undef GAUGE_W[/COLOR]
I'm the kind of guy that spend 2 days searching for a missing coma so help is welcome ! ^^
Thanks



