hi...
well i've managed to get it to compile now... so the last thread about this seems no longer fitting
yet, although it compiles alright, some functions seem to have no effect... particularly those that involve brushes and fonts...
functions such as "textOut" and my variant of it "textFltData" are working correctly, as i can see their output on the display....
"SelectObject" and some others, still refuse to yield proper results...
so i figure i might as well post up my code for you to see if you have any thoughts on why any of this wouldn't work
this is the struct i'm using to collect my GDI-related stuff, only the final three handles are being put to use so far...
this sits in a DVC-specific header file... no problems so far...
the following, is the last part of the clbkLoadVC function...
i'm not getting any errors from here either, nor any "fail" message shows in my debug console...
now, on to the final part, the actual drawing of the panel, in the clbkVCRedrawEvent function
it appears my fonts brushes and pens simply aren't working... they fail silently, leaving me to post here for any insight... this makes very little sense... why would the other functions work and not these?
thanks in advance for any advice :tiphat:
cheerz
well i've managed to get it to compile now... so the last thread about this seems no longer fitting
yet, although it compiles alright, some functions seem to have no effect... particularly those that involve brushes and fonts...
functions such as "textOut" and my variant of it "textFltData" are working correctly, as i can see their output on the display....
"SelectObject" and some others, still refuse to yield proper results...
so i figure i might as well post up my code for you to see if you have any thoughts on why any of this wouldn't work
this is the struct i'm using to collect my GDI-related stuff, only the final three handles are being put to use so far...
Code:
///////////////////////////
//
// things used by GDI functions for painting the displays...
static struct
{
HBRUSH greenBrush;
HPEN greenPen;
HBRUSH yellowBrush;
HPEN yellowPen;
HBRUSH redBrush;
HPEN redPen;
HBRUSH whiteBrush;
HPEN whitePen;
HBRUSH bkgdBrush;
HPEN nullPen;
HFONT fontSmall;
} sysmfd_GDI;
this sits in a DVC-specific header file... no problems so far...
the following, is the last part of the clbkLoadVC function...
Code:
//
//
SURFHANDLE sysmfd_t1;
//
sysmfd_t1 = oapiGetTextureHandle(mdl_dvc, 5);
oapiVCRegisterArea(DVC_SYSMFD_1, _R(0,0,256,256), PANEL_REDRAW_ALWAYS, PANEL_MOUSE_IGNORE, PANEL_MAP_NONE, sysmfd_t1);
// setup GDI thingz
//
sysmfd_GDI.bkgdBrush = CreateSolidBrush (RGB(0,0,0));
sysmfd_GDI.nullPen = CreatePen (PS_NULL, 0, RGB(0,0,0));
HDC hDC = GetDC (NULL);
long fontH12 = -MulDiv(10, GetDeviceCaps (hDC, LOGPIXELSY), 72);
ReleaseDC (NULL, hDC);
sysmfd_GDI.fontSmall = CreateFont(fontH12, 0, 0, 0, FW_NORMAL, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Courier New"));
//
if (!sysmfd_GDI.fontSmall)
{
cout << "SYSMFD font FAIL!" << endl;
}
i'm not getting any errors from here either, nor any "fail" message shows in my debug console...
now, on to the final part, the actual drawing of the panel, in the clbkVCRedrawEvent function
Code:
bool DGa2::clbkVCRedrawEvent (int id, int ev, SURFHANDLE surf)
{
HDC hDC = oapiGetDC(surf);
switch (id)
{
//
case DVC_SYSMFD_1:
SelectObject (hDC, sysmfd_GDI.nullPen);
SelectObject (hDC, sysmfd_GDI.bkgdBrush);
Rectangle (hDC, 0,0, 256,256); // rectangle shows up all white...
RECT r = _R(10,10,25,25);
FillRect (hDC, &r, sysmfd_GDI.bkgdBrush); // also white...
SetTextColor (hDC, RGB(255,220,0));
SetBkColor (hDC, RGB(0,0,0)); // these work, text changes color
HFONT restoreFont = (HFONT)SelectObject (hDC, sysmfd_GDI.fontSmall);
// this doesn't... still getting the same default font
TextOut(hDC, 150,90, TEXT("MAIN | INT"), 10);
TextOut(hDC, 150,105, TEXT("RD OPEN"), 7);
TextOut(hDC, 150,120, TEXT("FS OPEN"), 7); // these work as expected...
SetTextColor (hDC, RGB(0,255,0));
TextOut(hDC, 50, 15, TEXT("APU OffLine"), 11);
double mainfuel = GetFuelMass ();
txtFltData (hDC, 60, 150, TEXT("Fuel Main: "), mainfuel);
//
double fuelPct = (mainfuel / GetMaxFuelMass())*100;
txtFltData (hDC, 60, 165, TEXT("Fuel Pct: "), fuelPct);
//
// also working...
SelectObject(hDC, restoreFont); // no effect apparently
oapiReleaseDC (surf, hDC);
return true;
}
//
return false;
}
it appears my fonts brushes and pens simply aren't working... they fail silently, leaving me to post here for any insight... this makes very little sense... why would the other functions work and not these?
thanks in advance for any advice :tiphat:
cheerz