Example #1
0
//-----------------------------------------------------------------------------
// Name: 
// Desc: 
//-----------------------------------------------------------------------------
HRESULT CDPlay8Client::GetConnectionInfo( TCHAR* strConnectionInfo )
{
    UpdateConnectionInfo();

    _stprintf( strConnectionInfo, 
               TEXT("     Thread Count: Current=%d Avg= %.2f Max=%d\n")      \
               TEXT("     Thread Time:  Avg= %.4f Max=%.4f(s)\n")      \
                                                                        \
               TEXT("     Round Trip Latency MS=%dms\n")                      \
               TEXT("     Throughput BPS: Current=%d Peak=%d\n")              \
                                                                        \
               TEXT("     Messages Received=%d\n")                            \
                                                                        \
               TEXT("     Sent: GB=%d GP=%d NGB=%d NGP=%d\n")                 \
               TEXT("     Received: GB=%d GP=%d NGB=%d NGP=%d\n")             \
                                                                        \
               TEXT("     Messages Transmitted: HP=%d NP=%d LP=%d\n")         \
               TEXT("     Messages Timed Out: HP=%d NP=%d LP=%d\n")           \
                                                                        \
               TEXT("     Retried: GB=%d GP=%d\n")                            \
               TEXT("     Dropped: NGB=%d NGP=%d\n")                          \
                                                                        \
               TEXT("     Send Queue Messages: HP=%d NP=%d LP=%d\n")          \
               TEXT("     Send Queue Bytes: HP=%d NP=%d LP=%d\n"),            \
                                                                        \
                                                                        \
                                                                        \
               m_wActiveThreadCount, m_fAvgThreadCount, m_wMaxThreadCount,
               m_fAvgThreadTime, m_fMaxThreadTime,
               m_dpnConnectionInfo.dwRoundTripLatencyMS, 
               m_dpnConnectionInfo.dwThroughputBPS, 
               m_dpnConnectionInfo.dwPeakThroughputBPS,

               m_dpnConnectionInfo.dwMessagesReceived,

               m_dpnConnectionInfo.dwBytesSentGuaranteed,
               m_dpnConnectionInfo.dwPacketsSentGuaranteed,
               m_dpnConnectionInfo.dwBytesSentNonGuaranteed,
               m_dpnConnectionInfo.dwPacketsSentNonGuaranteed,

               m_dpnConnectionInfo.dwBytesReceivedGuaranteed,
               m_dpnConnectionInfo.dwPacketsReceivedGuaranteed,
               m_dpnConnectionInfo.dwBytesReceivedNonGuaranteed,
               m_dpnConnectionInfo.dwPacketsReceivedNonGuaranteed,

               m_dpnConnectionInfo.dwMessagesTransmittedHighPriority,
               m_dpnConnectionInfo.dwMessagesTransmittedNormalPriority,
               m_dpnConnectionInfo.dwMessagesTransmittedLowPriority,

               m_dpnConnectionInfo.dwMessagesTimedOutHighPriority,
               m_dpnConnectionInfo.dwMessagesTimedOutNormalPriority,
               m_dpnConnectionInfo.dwMessagesTimedOutLowPriority,

               m_dpnConnectionInfo.dwBytesRetried,
               m_dpnConnectionInfo.dwPacketsRetried,

               m_dpnConnectionInfo.dwBytesDropped,
               m_dpnConnectionInfo.dwPacketsDropped,

               m_dwHighPriMessages, m_dwNormalPriMessages, m_dwLowPriMessages, 
               m_dwHighPriBytes, m_dwNormalPriBytes, m_dwLowPriBytes
               );

    return S_OK;
}
Example #2
0
//INT CommandMore (LPTSTR cmd, LPTSTR param)
int main (int argc, char **argv)
{
   SHORT maxx,maxy;
   SHORT line_count=0,ch_count=0;
   DWORD i, last;
   HANDLE hFile = INVALID_HANDLE_VALUE;
   TCHAR szFullPath[MAX_PATH];
    TCHAR szMsg[1024];
   /*reading/writing buffer*/
   TCHAR *buff;

   /*bytes written by WriteFile and ReadFile*/
   DWORD dwRead,dwWritten;

   /*ReadFile() return value*/
   BOOL bRet;


   hStdIn = GetStdHandle(STD_INPUT_HANDLE);
   hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
   hStdErr = GetStdHandle(STD_ERROR_HANDLE);
    hApp = GetModuleHandle(NULL);

   buff=malloc(4096);
   if (!buff)
   {
      ConOutPuts(_T("Error: no memory"));
      return 1;
   }

   if (argc > 1 && _tcsncmp (argv[1], _T("/?"), 2) == 0)
   {
      if (LoadString(hApp, IDS_USAGE, buff, 4096 / sizeof(TCHAR)) < (int)(4096 / sizeof(TCHAR)))
      {
         CharToOem(buff, buff);
         ConOutPuts(buff);
      }

      free(buff);
      return 0;
   }

   hKeyboard = CreateFile (_T("CONIN$"), GENERIC_READ|GENERIC_WRITE,
                           0,NULL,OPEN_ALWAYS,0,0);

   GetScreenSize(&maxx,&maxy);



   FlushConsoleInputBuffer (hKeyboard);

   if(argc > 1)
   {
      GetFullPathNameA(argv[1], MAX_PATH, szFullPath, NULL);
      hFile = CreateFile (szFullPath, 
                            GENERIC_READ,
                           0,
                            NULL,
                            OPEN_EXISTING,
                            0,
                            0);
      if (hFile == INVALID_HANDLE_VALUE)
      {
         if (LoadString(hApp, IDS_FILE_ACCESS, szMsg, sizeof(szMsg) / sizeof(TCHAR)) < (int)(sizeof(szMsg) / sizeof(TCHAR)))
         {
            _stprintf(buff, szMsg, szFullPath);
            CharToOem(buff, buff);
            ConOutPuts(buff);
         }

         free(buff);
         return 0;
      }
   }
   else
   {
      hFile = hStdIn;
   }

    if (!LoadString(hApp, IDS_CONTINUE, szCont, sizeof(szCont) / sizeof(TCHAR)))
    {
        /* Shouldn't happen, so exit */
        return 1;
    }
    szContLength = _tcslen(szCont);



   do
   {
      bRet = ReadFile(hFile,buff,4096,&dwRead,NULL);

      for(last=i=0;i<dwRead && bRet;i++)
      {
         ch_count++;
         if(buff[i] == _T('\n') || ch_count == maxx)
         {
            ch_count=0;
            line_count++;
            if (line_count == maxy)
            {
               line_count = 0;
               WriteFile(hStdOut,&buff[last], i-last+1, &dwWritten, NULL);
               last=i+1;
               FlushFileBuffers (hStdOut);
               WaitForKey ();
            }
         }
      }
      if (last<dwRead && bRet)
         WriteFile(hStdOut,&buff[last], dwRead-last, &dwWritten, NULL);

   }
   while(dwRead>0 && bRet);

   free (buff);
   CloseHandle (hKeyboard);
   if (hFile != hStdIn)
      CloseHandle (hFile);

   return 0;
}
Example #3
0
void CDevCProbe::Update(WndForm* pWnd) {
	TCHAR Temp[50] = {0};

	LockFlightData();
	NMEA_INFO _INFO = GPS_INFO;
	UnlockFlightData();

	LockDeviceData();
	_stprintf(Temp, TEXT("C-Probe - Version: %s"), m_szVersion);
	UnlockDeviceData();

	pWnd->SetCaption(Temp);

	WndProperty* wp;
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpPitch"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f%s"), _INFO.Pitch, MsgToken(2179));
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpHeading"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f%s"), _INFO.MagneticHeading, MsgToken(2179));
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpRoll"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f%s"), _INFO.Roll, MsgToken(2179));
		wp->SetText(Temp);
	}

	wp = (WndProperty*)pWnd->FindByName(TEXT("prpGx"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f"), _INFO.AccelX);
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpGy"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f"), _INFO.AccelY);
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpGz"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f"), _INFO.AccelZ);
		wp->SetText(Temp);
	}

	wp = (WndProperty*)pWnd->FindByName(TEXT("prpTemp"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f %sC"), _INFO.OutsideAirTemperature, MsgToken(2179));
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpRh"));
	if(wp){
		_stprintf(Temp, TEXT("%.2f %%"), _INFO.RelativeHumidity);
		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpDeltaPress"));
	if(wp){
		LockDeviceData();
		_stprintf(Temp, TEXT("%.2f Pa"), m_delta_press);
		UnlockDeviceData();

		wp->SetText(Temp);
	}
	wp = (WndProperty*)pWnd->FindByName(TEXT("prpAbsPress"));
	if(wp){
		LockDeviceData();
		_stprintf(Temp, TEXT("%.2f hPa"), m_abs_press);
		UnlockDeviceData();

		wp->SetText(Temp);
	}
}
Example #4
0
BOOL KG_HttpClient::GetPostBuffer(BYTE **ppbyPostBuffer, DWORD *pdwPostBufferSize)
{
    int nResult = false;
    int  nRetCode = false;
    DWORD dwFileSize = 0;
    DWORD dwReadBytes = 0;
    BYTE *pbyBuffer = NULL;
    BYTE *pbyPostBuffer = NULL;
    DWORD dwPostSize = 0;
    TCHAR szBoundary[] = "-------------------------24822581126073";
    HANDLE hFile = INVALID_HANDLE_VALUE;
    struct POST_BLOCK
    {
        DWORD dwDataSize;
        BYTE *pbyData;
    } PostBlock;

    std::vector<POST_BLOCK> PostBlocksList;

    ZeroMemory(&PostBlock, sizeof(PostBlock));

    KGLOG_PROCESS_ERROR(ppbyPostBuffer);

    for (size_t i = 0; i < m_PostList.size(); ++i)
    {
        switch (m_PostList[i].eType)
        {
        case eNormal:
        {
            PostBlock.dwDataSize = 0;
            PostBlock.pbyData = new BYTE[2 * 1024];

            nRetCode = _stprintf(
                (TCHAR *)PostBlock.pbyData,
                "--%s\r\n"
                "Content-Disposition: form-data; name=\"%s\"\r\n"
                "\r\n%s\r\n",
                szBoundary, m_PostList[i].pParamName, m_PostList[i].pValue
            );
            KGLOG_PROCESS_ERROR(nRetCode > 0);
            
            PostBlock.dwDataSize = nRetCode;
            PostBlocksList.push_back(PostBlock);
            dwPostSize += nRetCode;

            PostBlock.dwDataSize = 0;
            PostBlock.pbyData = NULL;

            break;
        }
        case eBinaryFile:
        {
            hFile = ::CreateFile(
                m_PostList[i].pValue,
                GENERIC_READ,
                FILE_SHARE_READ,
                NULL,
                OPEN_EXISTING,
                FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
                NULL
            );
            KGLOG_PROCESS_ERROR(hFile != INVALID_HANDLE_VALUE);

            dwFileSize = GetFileSize(hFile, NULL);

            PostBlock.dwDataSize = 0;
            PostBlock.pbyData = new BYTE[2 * 1024 + dwFileSize];

            nRetCode = _stprintf(
                (TCHAR *)PostBlock.pbyData,
                "--%s\r\n"
                "Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\n"
                "Content-Type: application/octet-stream\r\n"
                "\r\n",
                szBoundary, m_PostList[i].pParamName, m_PostList[i].pValue
            );
            KGLOG_PROCESS_ERROR(nRetCode > 0);

            PostBlock.dwDataSize += nRetCode;
            dwPostSize += nRetCode;

            pbyBuffer = PostBlock.pbyData + nRetCode;

            nRetCode = ::ReadFile(hFile, pbyBuffer, dwFileSize, &dwReadBytes, NULL);
            KGLOG_PROCESS_ERROR(nRetCode);

            ::CloseHandle(hFile);
            hFile = INVALID_HANDLE_VALUE;

            PostBlock.dwDataSize += dwReadBytes;
            PostBlocksList.push_back(PostBlock);
            dwPostSize += dwReadBytes;

            PostBlock.dwDataSize = 0;
            PostBlock.pbyData = NULL;
            pbyBuffer = NULL;

            break;
        } // case eBinaryFile:
        default:
            KGLOG_PROCESS_ERROR(false);
        }
    }

    pbyPostBuffer = new BYTE[dwPostSize + 2 * 1024];
    pbyBuffer = pbyPostBuffer;
    for (unsigned i = 0; i < PostBlocksList.size(); ++i)
    {
        CopyMemory(pbyBuffer, PostBlocksList[i].pbyData, PostBlocksList[i].dwDataSize);
        pbyBuffer += PostBlocksList[i].dwDataSize;
    }

    CopyMemory(pbyBuffer, "\r\n--", _tcslen("\r\n--"));

    dwPostSize += (DWORD)_tcslen("\r\n--");
    pbyBuffer += (DWORD)_tcslen("\r\n--");

    CopyMemory(pbyBuffer, szBoundary, _tcslen(szBoundary));

    dwPostSize += (DWORD)_tcslen(szBoundary);
    pbyBuffer += (DWORD)_tcslen(szBoundary);

    CopyMemory(pbyBuffer, "--\r\n", _tcslen("--\r\n"));

    dwPostSize +=  (DWORD)_tcslen("--\r\n");
    pbyBuffer = NULL;

    *ppbyPostBuffer = pbyPostBuffer;
    *pdwPostBufferSize = dwPostSize;
    pbyPostBuffer = NULL;

    nResult = true;
Exit0:
    for (unsigned i = 0; i < PostBlocksList.size(); ++i)
    {
        KG_DELETE_ARRAY(PostBlocksList[i].pbyData);
    }

    if (hFile!= INVALID_HANDLE_VALUE)
    {
        ::CloseHandle(hFile);
        hFile = INVALID_HANDLE_VALUE;
    }

    if (!nResult)
    {
        KG_DELETE_ARRAY(pbyPostBuffer);
    }

    return nResult;
}
Example #5
0
void MapWindow::DrawVisualGlide(LKSurface& Surface, const DiagrammStruct& sDia) {

    const RECT& rci = sDia.rc;
    
    unsigned short numboxrows = 1;

#if BUGSTOP
    LKASSERT(Current_Multimap_SizeY < SIZE4);
#endif
    switch (Current_Multimap_SizeY) {
        case SIZE0:
        case SIZE1:
            numboxrows = 3;
            break;
        case SIZE2:
            numboxrows = 2;
            break;
        case SIZE3:
            numboxrows = 1;
            break;
        case SIZE4:
            return;
        default:
            LKASSERT(0);
            break;
    }

    if (!ScreenLandscape) {
        numboxrows++;
        if (numboxrows > 3) numboxrows = 3;
    }

    TCHAR tmpT[30];

    line1Font = LK8VisualTopFont;
    line2Font = LK8VisualBotFont;
    SIZE textSizeTop, textSizeBot;
    Surface.SelectObject(line1Font);
    _stprintf(tmpT, _T("MMMM"));
    Surface.GetTextSize(tmpT, &textSizeTop);
    Surface.SelectObject(line2Font);
    _stprintf(tmpT, _T("55.5%s 79%s%s "), Units::GetDistanceName(), MsgToken(2179), MsgToken(2183));
    Surface.GetTextSize(tmpT, &textSizeBot);

    // we can cut the waypoint name, but not the value data, so we use the second row of data
    // to size the box for everything.
    maxtSizeX = textSizeBot.cx; 

    int a = (rci.right-rci.left) / (textSizeBot.cx+BOXINTERVAL);
    int b = (rci.right-rci.left) - a * (textSizeBot.cx)-(BOXINTERVAL * (a + 1));

    boxSizeX = textSizeBot.cx + (b / (a + 1));
    boxSizeY = textSizeTop.cy + 1; // single line (wp name) + distance from bottombar

    if (numboxrows > 1) {
        boxSizeY += (textSizeBot.cy * (numboxrows - 1)) - NIBLSCALE(2);
        if (numboxrows > 2) boxSizeY -= NIBLSCALE(1);
    }

#if DEBUG_SCR
    StartupStore(_T("boxX=%d boxY=%d  \n"), boxSizeX, boxSizeY);
#endif

#if DEBUG_SCR
    StartupStore(_T("VG AREA LTRB: %d,%d %d,%d\n"), rci.left, rci.top, rci.right, rci.bottom);
#endif

    const auto oldBrush = Surface.SelectObject(LKBrush_White);
    const auto oldPen = Surface.SelectObject(LK_BLACK_PEN);

    BrushReference brush_back;
    if (!INVERTCOLORS) {
        brush_back = LKBrush_Black;
    } else {
        brush_back = LKBrush_Nlight;
    }

    Surface.FillRect(&rci, brush_back);

    POINT center, p1, p2;
    center.y = rci.top + (rci.bottom - rci.top) / 2;
    center.x = rci.left + (rci.right - rci.left) / 2;

    // numSlotX is the number items we can print horizontally.
    unsigned short numSlotX = (rci.right - rci.left) / (boxSizeX + BOXINTERVAL);
    if (numSlotX > MAXBSLOT) numSlotX = MAXBSLOT;
#if BUGSTOP
    LKASSERT(numSlotX > 0);
#endif
    if (numSlotX == 0) return;

    unsigned short boxInterval = ((rci.right - rci.left)-(boxSizeX * numSlotX)) / (numSlotX + 1);
    unsigned short oddoffset = ( (rci.right-rci.left) - (boxSizeX * numSlotX) - boxInterval * (numSlotX + 1)) / 2;

    /*
    #if BUGSTOP
    // not really harmful
    LKASSERT(oddoffset<=boxInterval);
    #endif
     */

#if DEBUG_SCR
    StartupStore(_T("numSlotX=%d ScreenSizeX=%d boxSizeX=%d interval=%d offset=%d\n"), numSlotX, ScreenSizeX, boxSizeX, boxInterval, oddoffset);
#endif

    unsigned int t;

    // The horizontal grid
    unsigned int slotCenterX[MAXBSLOT + 1];
    for (t = 0; t < numSlotX; t++) {
        slotCenterX[t] = (t * boxSizeX) + boxInterval * (t + 1)+(boxSizeX / 2) + oddoffset+rci.left;
#if DEBUG_SCR
        StartupStore(_T("slotCenterX[%d]=%d\n"), t, slotCenterX[t]);
#endif
    }

    // Vertical coordinates of each up/down subwindow, excluding center line
    int upYtop = rci.top;
#if MIDCENTER
    int upYbottom = center.y + (boxSizeY / 2);
    int downYtop = center.y - (boxSizeY / 2);
#else
    int upYbottom = center.y - CENTERYSPACE;
    int downYtop = center.y + CENTERYSPACE;
#endif
    int upSizeY = upYbottom - upYtop - (boxSizeY);
    ;
    int downYbottom = rci.bottom;
    int downSizeY = downYbottom - downYtop - (boxSizeY);
    ;

#if 0
    // Reassign dynamically the vertical scale for each subwindow size
    double vscale = 1000 * (100 - Current_Multimap_SizeY) / 100;
#else
    // Set the vertical range 
    double vscale;
    if (Units::GetUserAltitudeUnit() == unFeet)
        vscale = (1000 / TOFEET);
    else
        vscale = 300.0;
#endif



    Surface.SetBackgroundTransparent();

    RECT trc = rci;

    // Top part of visual rect, target is over us=unreachable=red
    trc.top = rci.top;
    trc.bottom = center.y - 1;
    #ifndef UNDITHER
    RenderSky(Surface, trc, RGB_WHITE, LKColor(150, 255, 150), GC_NO_COLOR_STEPS / 2);
    #else
    RenderSky(Surface, trc, RGB_WHITE, RGB_WHITE, GC_NO_COLOR_STEPS / 2);
    #endif
    // Bottom part, target is below us=reachable=green
    trc.top = center.y + 1;
    trc.bottom = rci.bottom;
    #ifndef UNDITHER
    RenderSky(Surface, trc, LKColor(255, 150, 150), RGB_WHITE, GC_NO_COLOR_STEPS / 2);
    #else
    RenderSky(Surface, trc, RGB_WHITE, RGB_WHITE,GC_NO_COLOR_STEPS / 2);
    #endif

    // Draw center line
    p1.x = rci.left + 1;
    p1.y = center.y;
    p2.x = rci.right - 1;
    p2.y = center.y;
    Surface.SelectObject(LKPen_Black_N1);
    Surface.DrawSolidLine(p1, p2, rci);

#if DEBUG_SCR
    StartupStore(_T("... Center line: Y=%d\n"), center.y);
#endif

    Surface.SelectObject(line1Font);
    Surface.SelectObject(LKPen_Black_N0);

    ResetVisualGlideGlobals();

    short res = GetVisualGlidePoints(numSlotX);

    if (res == INVALID_VALUE) {
#if DEBUG_DVG
        StartupStore(_T("...... GVGP says not ready, wait..\n"));
#endif
        return;
    }
    if (res == 0) {
#if DEBUG_DVG
        StartupStore(_T("...... GVGP says no data available!\n"));
#endif
        return;
    }

    // Print them all!
    int offset = (boxSizeY / 2) + CENTERYSPACE;

    LKBrush bcolor;
    LKColor rgbcolor, textcolor;
    int wp;

    unsigned short zeroslot = 0;
    double minbrgdiff = 999.0;
    double minabrgdiff = 999.0; // absolute never negative
    for (unsigned short n = 0; n < numSlotX; n++) {
        wp = slotWpIndex[n];
        if (!ValidWayPoint(wp)) {
            // empty slot nothing to print
            continue;
        }
        double brgdiff = WayPointCalc[wp].Bearing - DrawInfo.TrackBearing;
        // this check is worthless
        if (brgdiff < -180.0) {
            brgdiff += 360.0;
        } else {
            if (brgdiff > 180.0) brgdiff -= 360.0;
        }
        double abrgdiff = brgdiff;
        if (abrgdiff < 0) abrgdiff *= -1;

        if (abrgdiff < minabrgdiff) {
            zeroslot = n;
            minabrgdiff = abrgdiff;
            minbrgdiff = brgdiff;
        }
    }

    // Draw vertical line
#define DEGRANGE 10	// degrees left and right to perfect target
    if (minabrgdiff < 1) {
        p1.x = slotCenterX[zeroslot];
    } else {
        // set fullscale range
        if (minabrgdiff > DEGRANGE) {
            minabrgdiff = DEGRANGE;
            if (minbrgdiff < 0)
                minbrgdiff = -1 * DEGRANGE;
            else
                minbrgdiff = DEGRANGE;
        }
        // we shift of course in the opposite direction
        p1.x = slotCenterX[zeroslot]-(int) ((boxSizeX / (DEGRANGE * 2)) * minbrgdiff);
    }
    p2.x = p1.x;

    p1.y = rci.top + 1;
    p2.y = rci.bottom - 1;
    Surface.SelectObject(LKPen_Black_N1);
    Surface.DrawSolidLine(p1, p2, rci);



    for (unsigned short n = 0; n < numSlotX; n++) {

        wp = slotWpIndex[n];
        if (!ValidWayPoint(wp)) {
            // empty slot nothing to print
            continue;
        }
#if DEBUG_DVG
        StartupStore(_T("... DVG PRINT [%d]=%d <%s>\n"), n, wp, WayPointList[wp].Name);
#endif

        Sideview_VGWpt[n] = wp;

        double altdiff = WayPointCalc[wp].AltArriv[AltArrivMode];
        int ty;
#if DEBUG_SCR
        StartupStore(_T("... wp=<%s>\n"), WayPointList[wp].Name);
#endif

        // Since terrain can be approximated due to low precision maps, or waypoint position or altitude error,
        // we have a common problem: we get an obstacle to get to the waypoint because it is 
        // positioned "BELOW" the terrain itself. We try to reduce this problem here.
#define SAFETERRAIN	50

        // Positive arrival altitude for the waypoint, upper window
        if (altdiff >= 0) {
            if (altdiff == 0)altdiff = 1;
            double d = vscale / altdiff;
            if (d == 0) d = 1;
            ty = upYbottom - (int) ((double) upSizeY / d)-(boxSizeY / 2);
#if DEBUG_SCR
            StartupStore(_T("... upYbottom=%d upSizeY=%d / (vscale=%f/altdiff=%f = %f) =- %d  ty=%d  offset=%d\n"),
                    upYbottom, upSizeY, vscale, altdiff, d, (int) ((double) upSizeY / d), ty, offset);
#endif
            if ((ty - offset) < upYtop) ty = upYtop + offset;
            if ((ty + offset) > upYbottom) ty = upYbottom - offset;
#if DEBUG_SCR
            StartupStore(_T("... upYtop=%d upYbottom=%d final ty=%d\n"), upYtop, upYbottom, ty);
#endif


            //
            // This is too confusing. We want simple colors, not shaded
            // rgbcolor = MixColors( LKColor(50,255,50), LKColor(230,255,230),  altdiff/(vscale-50));
            //

            if (altdiff <= SAFETERRAIN) {
                rgbcolor = RGB_LIGHTYELLOW;
            } else {
                if (!CheckLandableReachableTerrainNew(&DrawInfo, &DerivedDrawInfo,
                        WayPointCalc[wp].Distance, WayPointCalc[wp].Bearing)) {
                    rgbcolor = RGB_LIGHTRED;
                } else {
#ifdef UNDITHER
                    rgbcolor = RGB_WHITE;
#else
                    rgbcolor = RGB_LIGHTGREEN;
#endif
                }
            }
            bcolor.Create(rgbcolor);

        } else {
            double d = vscale / altdiff;
            if (d == 0) d = -1;
            ty = downYtop - (int) ((double) downSizeY / d)+(boxSizeY / 2); // - because the left part is negative, we are really adding.
            if ((ty - offset) < downYtop) ty = downYtop + offset;
            if ((ty + offset) > downYbottom) ty = downYbottom - offset;

#ifdef UNDITHER
            rgbcolor = RGB_WHITE; // negative part, no need to render dark
#else
            rgbcolor = RGB_LIGHTRED;
#endif
            bcolor.Create(rgbcolor);
        }

        TCHAR line2[40], line3[40];
        TCHAR value[40], unit[30];
        TCHAR name[NAME_SIZE + 1];
        double ar = (WayPointCalc[wp].AltArriv[AltArrivMode] * ALTITUDEMODIFY);
        _tcscpy(name, WayPointList[wp].Name);
        CharUpper(name);

        if (IsSafetyAltitudeInUse(wp))
            textcolor = RGB_DARKBLUE;
        else
            textcolor = RGB_BLACK;

        switch (numboxrows) {
            case 0:
#if BUGSTOP
                LKASSERT(0);
#endif
                return;

            case 1:
                // 1 line: waypoint name
                VGTextInBox(Surface, n, 1, name, NULL, NULL, slotCenterX[n], ty, textcolor, bcolor);
                break;

            case 2:
                // 2 lines: waypoint name + altdiff
                LKFormatAltDiff(wp, false, value, unit);
                // Should we print also the GR?
                if ((ar >= -9999 && ar <= 9999) && (WayPointCalc[wp].GR < MAXEFFICIENCYSHOW)) {
                    if (ar >= -999 && ar <= 999)
                        _stprintf(line2, _T("%s   "), value);
                    else
                        _stprintf(line2, _T("%s  "), value);
                    LKFormatGR(wp, false, value, unit);
                    _tcscat(line2, value);
                } else {
                    _stprintf(line2, _T("%s   ---"), value);
                }

                VGTextInBox(Surface, n, 2, name, line2, NULL, slotCenterX[n], ty, textcolor, bcolor);
                break;

            case 3:
                // 3 lines: waypoint name + dist + altdiff
                LKFormatDist(wp, false, value, unit);
                _stprintf(line2, _T("%s%s"), value, unit);

                LKFormatBrgDiff(wp, false, value, unit);
                _stprintf(tmpT, _T(" %s%s"), value, unit);
                _tcscat(line2, tmpT);

                LKFormatAltDiff(wp, false, value, unit);
                // Should we print also the GR?
                if ((ar >= -9999 && ar <= 9999) && (WayPointCalc[wp].GR < MAXEFFICIENCYSHOW)) {
                    if (ar >= -999 && ar <= 999)
                        _stprintf(line3, _T("%s   "), value);
                    else
                        _stprintf(line3, _T("%s  "), value);
                    LKFormatGR(wp, false, value, unit);
                    _tcscat(line3, value);
                } else {
                    _stprintf(line3, _T("%s   ---"), value);
                }

                VGTextInBox(Surface, n, 3, name, line2, line3, slotCenterX[n], ty, textcolor, bcolor);
                break;
            default:
#if BUGSTOP
                LKASSERT(0);
#endif
                return;
        }

    } // for numSlotX



    // Cleanup and return
    Surface.SelectObject(oldBrush);
    Surface.SelectObject(oldPen);
    return;
}
Example #6
0
void LookupAirfieldDetail(TCHAR *Name, TCHAR *Details) {
  int i;
  TCHAR UName[100];
  TCHAR NameA[100];
  TCHAR NameB[100];
  TCHAR NameC[100];
  TCHAR NameD[100];
  TCHAR TmpName[100];

#ifndef NOLAND_HOME_WP
  bool isHome, isPreferred;
#else
  bool isHome, isPreferred, isLandable;
#endif

  if (!WayPointList) return;

  for(i=NUMRESWP;i<(int)NumberOfWayPoints;i++) {

    #ifndef NOLAND_HOME_WP
      if (((WayPointList[i].Flags & AIRPORT) == AIRPORT) || ((WayPointList[i].Flags & LANDPOINT) == LANDPOINT)) { 
    #endif

	_tcscpy(UName, WayPointList[i].Name);

	CharUpper(UName); // WP name
	CharUpper(Name);  // AIR name  If airfields name was not uppercase it was not recon

	_stprintf(NameA,TEXT("%s A/F"),Name);
	_stprintf(NameB,TEXT("%s AF"),Name);
	_stprintf(NameC,TEXT("%s A/D"),Name);
	_stprintf(NameD,TEXT("%s AD"),Name);

	isHome=false;
	isPreferred=false;
    #ifdef NOLAND_HOME_WP
      isLandable = (((WayPointList[i].Flags & AIRPORT) == AIRPORT) || 
                   ((WayPointList[i].Flags & LANDPOINT) == LANDPOINT));
    #endif

	_stprintf(TmpName,TEXT("%s=HOME"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isHome=true;

  #ifdef NOLAND_HOME_WP
  // Only bother checking whether it's preferred if it's landable.
  if (isLandable) {
  #endif
	_stprintf(TmpName,TEXT("%s=PREF"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isPreferred=true;
	_stprintf(TmpName,TEXT("%s=PREFERRED"),UName);
	if ( (_tcscmp(Name, TmpName)==0) )  isPreferred=true;
  #ifdef NOLAND_HOME_WP
  }
  #endif

	if ( isHome==true ) {
    #ifdef NOLAND_HOME_WP
    if (isLandable)
    #endif
	  WayPointCalc[i].Preferred = true;
	  HomeWaypoint = i;
	  AirfieldsHomeWaypoint = i; // make it survive a reset..
	}
	if ( isPreferred==true ) {
	  WayPointCalc[i].Preferred = true;
	}

	if ((_tcscmp(UName, Name)==0)
	    ||(_tcscmp(UName, NameA)==0)
	    ||(_tcscmp(UName, NameB)==0)
	    ||(_tcscmp(UName, NameC)==0)
	    ||(_tcscmp(UName, NameD)==0)
	    || isHome || isPreferred )
	  {
	    if (_tcslen(Details) >0 ) { // avoid setting empty details
	      if (WayPointList[i].Details) {
		free(WayPointList[i].Details);
	      }
	      WayPointList[i].Details = (TCHAR*)malloc((_tcslen(Details)+1)*sizeof(TCHAR));
	      if (WayPointList[i].Details != NULL) _tcscpy(WayPointList[i].Details, Details);
	    } 
	    return;
	  }

    #ifndef NOLAND_HOME_WP // end of "if airport or landpoint" block
      }
    #endif

    }
}
Example #7
0
void prepare_rpn_result_2(calc_number_t *rpn, TCHAR *buffer, int size, int base)
{
    calc_number_t tmp;
    int    width;

    switch (base) {
    case IDC_RADIO_HEX:
        _stprintf(buffer, TEXT("%I64X"), rpn->i);
        break;
    case IDC_RADIO_DEC:
/*
 * Modified from 17 to 16 for fixing this bug:
 * 14+14+6.3+6.3= 40.5999999 instead of 40.6
 * So, it's probably better to leave the least
 * significant digit out of the display.
 */
#define MAX_LD_WIDTH    16
        /* calculate the width of integer number */
        width = (rpn->f==0) ? 1 : (int)log10(fabs(rpn->f))+1;
        if (calc.sci_out == TRUE || width > MAX_LD_WIDTH || width < -MAX_LD_WIDTH)
            _stprintf(buffer, TEXT("%#e"), rpn->f);
        else {
            TCHAR *ptr, *dst;

            ptr = buffer + _stprintf(buffer, TEXT("%#*.*f"), width, ((MAX_LD_WIDTH-width-1)>=0) ? MAX_LD_WIDTH-width-1 : 0, rpn->f);
            /* format string ensures there is a '.': */
            dst = _tcschr(buffer, TEXT('.'));
            while (--ptr > dst)
                if (*ptr != TEXT('0'))
                    break;

            /* put the string terminator for removing the final '0' (if any) */
            ptr[1] = TEXT('\0');
            /* check if the number finishes with '.' */
            if (ptr == dst)
                /* remove the dot (it will be re-added later) */
                ptr[0] = TEXT('\0');
        }
#undef MAX_LD_WIDTH
        break;
    case IDC_RADIO_OCT:
        _stprintf(buffer, TEXT("%I64o"), rpn->i);
        break;
    case IDC_RADIO_BIN:
        if (rpn->i == 0) {
            buffer[0] = TEXT('0');
            buffer[1] = TEXT('\0');
            break;
        }
        tmp = *rpn;
        buffer[0] = TEXT('\0');
        while (tmp.u) {
            memmove(buffer+1, buffer, (size-1)*sizeof(TCHAR));
            if (tmp.u & 1)
                calc.buffer[0] = TEXT('1');
            else
                calc.buffer[0] = TEXT('0');
            tmp.u >>= 1;
        }
        break;
    }
}
Example #8
0
void HiscoreInit()
{
	Debug_HiscoreInitted = 1;
	
	if (!CheckHiscoreAllowed()) return;
	
	HiscoresInUse = 0;
	
	TCHAR szDatFilename[MAX_PATH];
#ifdef __LIBRETRO__
#ifdef _WIN32
   char slash = '\\';
#else
   char slash = '/';
#endif
	snprintf(szDatFilename, sizeof(szDatFilename), "%s%chiscore.dat", g_rom_dir, slash);
#else
	_stprintf(szDatFilename, _T("%shiscore.dat"), szAppHiscorePath);
#endif

	FILE *fp = _tfopen(szDatFilename, _T("r"));
	if (fp) {
		char buffer[MAX_CONFIG_LINE_SIZE];
		enum { FIND_NAME, FIND_DATA, FETCH_DATA } mode;
		mode = FIND_NAME;

		while (fgets(buffer, MAX_CONFIG_LINE_SIZE, fp)) {
			if (mode == FIND_NAME) {
				if (matching_game_name(buffer, BurnDrvGetTextA(DRV_NAME))) {
					mode = FIND_DATA;
				}
			} else {
				if (is_mem_range(buffer)) {
					if (nHiscoreNumRanges < HISCORE_MAX_RANGES) {
						const char *pBuf = buffer;
					
						HiscoreMemRange[nHiscoreNumRanges].Loaded = 0;
						HiscoreMemRange[nHiscoreNumRanges].nCpu = hexstr2num(&pBuf);
						HiscoreMemRange[nHiscoreNumRanges].Address = hexstr2num(&pBuf);
						HiscoreMemRange[nHiscoreNumRanges].NumBytes = hexstr2num(&pBuf);
						HiscoreMemRange[nHiscoreNumRanges].StartValue = hexstr2num(&pBuf);
						HiscoreMemRange[nHiscoreNumRanges].EndValue = hexstr2num(&pBuf);
						HiscoreMemRange[nHiscoreNumRanges].ApplyNextFrame = 0;
						HiscoreMemRange[nHiscoreNumRanges].Applied = 0;
						HiscoreMemRange[nHiscoreNumRanges].Data = (UINT8*)malloc(HiscoreMemRange[nHiscoreNumRanges].NumBytes);
						memset(HiscoreMemRange[nHiscoreNumRanges].Data, 0, HiscoreMemRange[nHiscoreNumRanges].NumBytes);
					
#if 1 && defined FBA_DEBUG
						bprintf(PRINT_IMPORTANT, _T("Hi Score Memory Range %i Loaded - CPU %i, Address %x, Bytes %02x, Start Val %x, End Val %x\n"), nHiscoreNumRanges, HiscoreMemRange[nHiscoreNumRanges].nCpu, HiscoreMemRange[nHiscoreNumRanges].Address, HiscoreMemRange[nHiscoreNumRanges].NumBytes, HiscoreMemRange[nHiscoreNumRanges].StartValue, HiscoreMemRange[nHiscoreNumRanges].EndValue);
#endif
					
						nHiscoreNumRanges++;
					
						mode = FETCH_DATA;
					} else {
						break;
					}
				} else {
					if (mode == FETCH_DATA) break;
				}
			}
		}
		
		fclose(fp);
	}
	
	if (nHiscoreNumRanges) HiscoresInUse = 1;
	
	TCHAR szFilename[MAX_PATH];
#ifdef __LIBRETRO__
	snprintf(szFilename, sizeof(szFilename), "%s%c%s.hi", g_rom_dir, slash, BurnDrvGetText(DRV_NAME));
#else
	_stprintf(szFilename, _T("%s%s.hi"), szAppHiscorePath, BurnDrvGetText(DRV_NAME));
#endif

	fp = _tfopen(szFilename, _T("r"));
	INT32 Offset = 0;
	if (fp) {
		UINT32 nSize = 0;
		
		while (!feof(fp)) {
			fgetc(fp);
			nSize++;
		}
		
		UINT8 *Buffer = (UINT8*)malloc(nSize);
		rewind(fp);
		
		fgets((char*)Buffer, nSize, fp);
		
		for (UINT32 i = 0; i < nHiscoreNumRanges; i++) {
			for (UINT32 j = 0; j < HiscoreMemRange[i].NumBytes; j++) {
				HiscoreMemRange[i].Data[j] = Buffer[j + Offset];
			}
			Offset += HiscoreMemRange[i].NumBytes;
			
			HiscoreMemRange[i].Loaded = 1;
			
#if 1 && defined FBA_DEBUG
			bprintf(PRINT_IMPORTANT, _T("Hi Score Memory Range %i Loaded from file\n"), i);
#endif
		}
		
		if (Buffer) {
			free(Buffer);
			Buffer = NULL;
		}

		fclose(fp);
	}
	
	nCpuType = -1;
}
Example #9
0
void HiscoreExit()
{
#if defined FBA_DEBUG
	if (!Debug_HiscoreInitted) bprintf(PRINT_ERROR, _T("HiscoreExit called without init\n"));
#endif

	if (!CheckHiscoreAllowed() || !HiscoresInUse) {
		Debug_HiscoreInitted = 0;
		return;
	}
	
	if (nCpuType == -1) set_cpu_type();
	
	TCHAR szFilename[MAX_PATH];
#ifdef __LIBRETRO__
#ifdef _WIN32
   char slash = '\\';
#else
   char slash = '/';
#endif
	snprintf(szFilename, sizeof(szFilename), "%s%c%s.hi", g_rom_dir, slash, BurnDrvGetText(DRV_NAME));
#else
	_stprintf(szFilename, _T("%s%s.hi"), szAppHiscorePath, BurnDrvGetText(DRV_NAME));
#endif

	FILE *fp = _tfopen(szFilename, _T("w"));
	if (fp) {
		for (UINT32 i = 0; i < nHiscoreNumRanges; i++) {
			UINT8 *Buffer = (UINT8*)malloc(HiscoreMemRange[i].NumBytes);
			
			cpu_open(HiscoreMemRange[i].nCpu);
			for (UINT32 j = 0; j < HiscoreMemRange[i].NumBytes; j++) {
				Buffer[j] = cpu_read_byte(HiscoreMemRange[i].Address + j);
			}
			cpu_close();
			
			fwrite(Buffer, 1, HiscoreMemRange[i].NumBytes, fp);
			
			if (Buffer) {
				free(Buffer);
				Buffer = NULL;
			}
		}
	}
	fclose(fp);
	
	nCpuType = -1;
	nHiscoreNumRanges = 0;
	
	for (UINT32 i = 0; i < HISCORE_MAX_RANGES; i++) {
		HiscoreMemRange[i].Loaded = 0;
		HiscoreMemRange[i].nCpu = 0;
		HiscoreMemRange[i].Address = 0;
		HiscoreMemRange[i].NumBytes = 0;
		HiscoreMemRange[i].StartValue = 0;
		HiscoreMemRange[i].EndValue = 0;
		HiscoreMemRange[i].ApplyNextFrame = 0;
		HiscoreMemRange[i].Applied = 0;
		
		free(HiscoreMemRange[i].Data);
		HiscoreMemRange[i].Data = NULL;
	}
	
	Debug_HiscoreInitted = 0;
}
Example #10
0
//
// Called by LKDrawLook8000, this is what happens when we change mapspace mode, advancing through types.
// We paint infopages, nearest, tri, etc.etc.
// Normally there is plenty of cpu available because the map is not even calculated.
// This is why we bring to the Draw thread, in the nearest pages case, also calculations.
//
void MapWindow::DrawMapSpace(LKSurface& Surface,  const RECT& rc) {

  BrushReference hB;

  TextInBoxMode_t TextDisplayMode = {0};
  TCHAR Buffer[LKSIZEBUFFERLARGE*2];
#ifdef DRAWLKSTATUS
  bool dodrawlkstatus=false;
#endif


#ifndef DITHER
  if (MapSpaceMode==MSM_WELCOME) {
	if (INVERTCOLORS)
		hB=LKBrush_Petrol;
	  else
		hB=LKBrush_Mlight;
  } else {
	if (INVERTCOLORS)
	  hB=LKBrush_Mdark;
	else
	  hB=LKBrush_Mlight;

  }
#else
  if (INVERTCOLORS)
      hB=LKBrush_Black;
  else
      hB=LKBrush_White;
#endif

  const auto oldfont = Surface.SelectObject(LKINFOFONT); // save font
  if (MapSpaceMode==MSM_WELCOME) {
      LKBitmap WelcomeBitmap = LoadSplash(_T("LKPROFILE"));
      if(WelcomeBitmap) {
          DrawSplash(Surface, WelcomeBitmap);
      }
  } else {
      Surface.FillRect(&rc, hB);
  }

  // Paint borders in green, but only in nearest pages and welcome, and not in DITHER mode
  // In case we want it in dithered mode, some changes are ready to be used.
  #ifndef DITHER
  if (MapSpaceMode==MSM_WELCOME || (!IsMultiMap() && MapSpaceMode!=MSM_MAP) )
  {
     #ifdef DITHER
     LKPen BorderPen(PEN_SOLID, ScreenThinSize, INVERTCOLORS?RGB_WHITE:RGB_BLACK);
     #else
     LKPen BorderPen(PEN_SOLID, ScreenThinSize, INVERTCOLORS?RGB_GREEN:RGB_DARKGREEN);
     #endif
     auto OldPen = Surface.SelectObject(BorderPen);
     auto OldBrush = Surface.SelectObject(LK_HOLLOW_BRUSH);

     Surface.Rectangle(rc.left, rc.top, rc.right, rc.bottom - BottomSize);

     Surface.SelectObject(OldPen);
     Surface.SelectObject(OldBrush);
  }
  #endif


#ifdef DRAWLKSTATUS
  if (LKevent==LKEVENT_NEWRUN) dodrawlkstatus=true;
#endif

  // We are entering mapspacemodes with no initial check on configured subpages.
  // Thus we need to ensure that the page is really available, or find the first valid.
  // However, this will prevent direct customkey access to pages!
  // Instead, we do it when we call next page from InfoPageChange
  // if (!ConfIP[ModeIndex][CURTYPE]) NextModeType();
  switch (MapSpaceMode) {
	case MSM_WELCOME:
#if 0
		SetModeType(LKMODE_MAP,MP_MOVING);
		RefreshMap();
		break;
#endif
#if (1)
		if (!DrawInfo.NAVWarning) {
		static double firsttime=DrawInfo.Time;
		// delayed automatic exit from welcome mode
		if ( DrawInfo.Time > (firsttime+3.0) ) {
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			LKSound(_T("LK_BEEP1.WAV"));
			RefreshMap();
			break;
		}
		}
#endif
		if(GlobalModelType==MODELTYPE_PNA_MINIMAP)
		{
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			break;
		}

		DrawWelcome8000(Surface, rc);
		break;
	case MSM_MAPTRK:
		SetSideviewPage(IM_HEADING);
		LKDrawMultimap_Asp(Surface,rc);
		break;
	case MSM_MAPWPT:
		#if 0
		// If there is no destination, force jump to the map
		if (GetOvertargetIndex()<0) {
			SetModeType(LKMODE_MAP,MP_MOVING);
			LKevent=LKEVENT_NONE;
			break;
		}
		#endif
		SetSideviewPage(IM_NEXT_WP);
		LKDrawMultimap_Asp(Surface,rc);
		break;
	case MSM_MAPASP:
		SetSideviewPage(IM_NEAR_AS);
		LKDrawMultimap_Asp(Surface,rc);
		break;
	case MSM_MAPRADAR:
		LKDrawMultimap_Radar(Surface,rc);
		break;
	case MSM_VISUALGLIDE:
		SetSideviewPage(IM_VISUALGLIDE);
		LKDrawMultimap_Asp(Surface,rc);
		break;
	case MSM_MAPTEST:
		LKDrawMultimap_Test(Surface,rc);
		break;
	case MSM_LANDABLE:
	case MSM_NEARTPS:
	case MSM_AIRPORTS:
	case MSM_COMMON:
	case MSM_RECENT:
	case MSM_AIRSPACES:
	case MSM_THERMALS:
	case MSM_TRAFFIC:
		DrawNearest(Surface, rc);
		break;
	case MSM_MAP:
		break;
	case MSM_INFO_THERMAL:
	case MSM_INFO_CRUISE:
	case MSM_INFO_TASK:
	case MSM_INFO_AUX:
	case MSM_INFO_TRI:
	case MSM_INFO_HSI:
	case MSM_INFO_TRF:
	case MSM_INFO_TARGET:
	case MSM_INFO_CONTEST:
		DrawInfoPage(Surface,rc, false);
		break;

  default:
    memset((void*)&TextDisplayMode, 0, sizeof(TextDisplayMode));
    TextDisplayMode.Color = RGB_WHITE;
    TextDisplayMode.NoSetFont = 1;
    TextDisplayMode.AlligneCenter = 1;
    Surface.SelectObject(LK8TargetFont);
    _stprintf(Buffer,TEXT("MapSpaceMode=%d"),MapSpaceMode);
    TextInBox(Surface, &rc, Buffer, (rc.right+rc.left)/2, NIBLSCALE(50) , &TextDisplayMode, false);
    break;
  }
#ifdef DRAWLKSTATUS
  // no need to clear dodrawlkstatus, it is already reset at each run
  if (dodrawlkstatus) DrawLKStatus(hdc, rc);
#endif
  Surface.SelectObject(oldfont);
}
Example #11
0
int CVersionStrigList::find(LANGID lang_id, int codepage)
{
  TCHAR Buff[10];
  _stprintf(Buff, _T("%04x"), lang_id);
  return SortedStringListND<struct version_string_list>::find(Buff);
}
Example #12
0
// OUT TCHAR* tFullPath : provided pointer have be at least MAX_PATH TCHAR
// bShowManualSearchDialogIfNotFound : TRUE to show Dialog Box to select dll when dll not found
BOOL CDllFinder::FindDll(TCHAR* ImportingModulePath,TCHAR* tWorkingDirectory,TCHAR* tDllName,OUT TCHAR* tFullPath,BOOL bShowManualSearchDialogIfNotFound)
{
    //The \WINNT\SYSTEM32 directory. 
    //The directory of the executable for the process that is loading the DLL. 
    //The current directory of the process that is loading the DLL. 
    //The \WINNT directory. 
    //A directory listed in the PATH environment variable. 
    
    TCHAR psz[MAX_PATH];
    TCHAR pszDirectory[MAX_PATH];
    TCHAR DllName[MAX_PATH];
    TCHAR* pstr;

    // in case full path is already specified
    if (CDllFinder::DoesFileExists(tDllName))
    {
        _tcscpy(tFullPath,tDllName);
        return TRUE;
    }

    // remove directory if any
    _tcsncpy(DllName,tDllName,MAX_PATH);
    DllName[MAX_PATH-1]=0;
    pstr=_tcsrchr(tDllName,'\\');
    if (pstr)
        _tcscpy(DllName,pstr);

    // check if file exists in SYSTEM32 path
    *pszDirectory=0;
    ::GetSystemDirectory(pszDirectory,MAX_PATH);
    _tcscpy(psz,pszDirectory);
    _tcscat(psz,DllName);
    if (CDllFinder::DoesFileExists(psz))
    {
        _tcscpy(tFullPath,psz);
        return TRUE;
    }

    // check if file exists in WorkingDirectory
    if (tWorkingDirectory)
    {
        // forge full name

        _tcscpy(psz,tWorkingDirectory);
        // if directory doesn't ends with '\' add it
        if (tWorkingDirectory[_tcslen(tWorkingDirectory)-1]!='\\')
            _tcscat(psz,_T("\\"));
        _tcscat(psz,DllName);

        if (CDllFinder::DoesFileExists(psz))
        {
            _tcscpy(tFullPath,psz);
            return TRUE;
        }
    }

    // check if file exists in Windows directory
    *pszDirectory=0;
    GetWindowsDirectory(pszDirectory,MAX_PATH);
    _tcscpy(psz,pszDirectory);
    _tcscat(psz,DllName);
    if (CDllFinder::DoesFileExists(psz))
    {
        _tcscpy(tFullPath,psz);
        return TRUE;
    }

    // check environment path var
    TCHAR* pszEnvPath;
    DWORD size=1024;
    DWORD dwRet;
    pszEnvPath=new TCHAR[size];
    dwRet=GetEnvironmentVariable(_T("Path"),pszEnvPath,size);
    if (dwRet!=0)
    {
        // if buffer is not large enough
        if (dwRet>size)
        {
            // increase buffer size
            size=dwRet;
            delete[] pszEnvPath;
            pszEnvPath=new TCHAR[size];
            // query env path again
            GetEnvironmentVariable(_T("Path"),pszEnvPath,size);
        }

        // for each path in pszEnvPath
        TCHAR* pszPointer;
        TCHAR* pszPointerDir;
        pszPointerDir=pszEnvPath;

        while(pszPointerDir)
        {
            pszPointer=_tcschr(pszPointerDir,';');
            if (pszPointer)
            {
                *pszPointer=0;
                pszPointer++;
            }
            if (*pszPointerDir==0)
                break;

            _tcscpy(psz,pszPointerDir);
            if (pszPointerDir[_tcslen(pszPointerDir)-1]!='\\')
                _tcscat(psz,_T("\\"));
            _tcscat(psz,DllName);
            // check if file exists
            if (CDllFinder::DoesFileExists(psz))
            {
                _tcscpy(tFullPath,psz);
                delete[] pszEnvPath;
                return TRUE;
            }
            // point to the next dir
            pszPointerDir=pszPointer;
        }
    }
    delete[] pszEnvPath;

    // check for Assembly Identities
    // looks for "Retrieve the Assembly Identities from a Manifest using C++" article on CodeProject By marc ochsenmeier (www.winitor.net) 20 Jun 2010
    if (CDllSideBySideAssembyFinder::FindSideBySideAssemby(ImportingModulePath,tWorkingDirectory,tDllName,tFullPath))
        return TRUE;

    // not found
#if (defined(TOOLS_NO_MESSAGEBOX))
    UNREFERENCED_PARAMETER(bShowManualSearchDialogIfNotFound);
#else
    if (bShowManualSearchDialogIfNotFound)
    {
        TCHAR pszTmp[2*MAX_PATH];
        _stprintf(pszTmp,_T("File %s can't be found.\r\nDo you want to search it manually ?"),DllName);
        if (MessageBox(NULL,pszTmp,_T("Warning"),MB_YESNO|MB_ICONWARNING|MB_TOPMOST)==IDYES)
        {
            *psz=0;

            // open dialog
            OPENFILENAME ofn;
            memset(&ofn,0,sizeof (OPENFILENAME));
            ofn.lStructSize=sizeof (OPENFILENAME);
            ofn.hwndOwner=NULL;
            ofn.hInstance=NULL;
            ofn.lpstrFilter=_T("exe, ocx, dll, tlb\0*.exe;*.ocx;*.dll;*.tlb\0All\0*.*\0");
            ofn.nFilterIndex = 1;
            ofn.Flags=OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
            ofn.lpstrFile=DllName;
            ofn.nMaxFile=MAX_PATH;
            ofn.lpstrTitle=_T("Select dll file");

            // get file name
            if (GetOpenFileName(&ofn))
            {
                _tcscpy(tFullPath,DllName);
                return TRUE;
            }
        }
    }
#endif
    return FALSE;
}
Example #13
0
void MapWindow::DrawWindAtAircraft2(LKSurface& Surface, const POINT& Orig, const RECT& rc) {
  int i;
  POINT Start;
  TCHAR sTmp[12];
  static SIZE tsize = {0,0};
  
  if (DerivedDrawInfo.WindSpeed<1) {
    return; // JMW don't bother drawing it if not significant
  }
  
  if (tsize.cx == 0){

    const auto oldFont = Surface.SelectObject(MapWindowBoldFont);
    Surface.GetTextSize(TEXT("99"), 2, &tsize);
    Surface.SelectObject(oldFont);
    tsize.cx = tsize.cx/2;
  }

  int wmag = iround(4.0*DerivedDrawInfo.WindSpeed);
  
  Start.y = Orig.y;
  Start.x = Orig.x;

  int kx = tsize.cx/ScreenScale/2;

  POINT Arrow[7] = { {0,-20}, {-6,-26}, {0,-20}, 
                     {6,-26}, {0,-20}, 
                     {8+kx, -24}, 
                     {-8-kx, -24}};

  for (i=1;i<4;i++)
    Arrow[i].y -= wmag;

  PolygonRotateShift(Arrow, 7, Start.x, Start.y, 
		     DerivedDrawInfo.WindBearing-DisplayAngle);

  //
  // Draw Wind Arrow
  //
  POINT Tail[2] = {{0,-20}, {0,-26-min(20,wmag)*3}};
  double angle = AngleLimit360(DerivedDrawInfo.WindBearing-DisplayAngle);
  for(i=0; i<2; i++) {
    if (ScreenScale>1) {
      Tail[i].x *= ScreenScale;
      Tail[i].y *= ScreenScale;
    }
    protateshift(Tail[i], angle, Start.x, Start.y);
  }
  // optionally draw dashed line for wind arrow
  Surface.DrawLine(PEN_DASH, 1, Tail[0], Tail[1], LKColor(0,0,0), rc);

  // Paint wind value only while circling
  if ( (mode.Is(Mode::MODE_CIRCLING)) ) {

    _stprintf(sTmp, _T("%d"), iround(DerivedDrawInfo.WindSpeed * SPEEDMODIFY));

    TextInBoxMode_t TextInBoxMode = {0};
    TextInBoxMode.AlligneCenter = true;   // { 16 | 32 }; // JMW test {2 | 16};
    TextInBoxMode.WhiteBorder = true;
    if (Arrow[5].y>=Arrow[6].y) {
      TextInBox(Surface, &rc, sTmp, Arrow[5].x-kx, Arrow[5].y, 0, &TextInBoxMode);
    } else {
      TextInBox(Surface, &rc, sTmp, Arrow[6].x-kx, Arrow[6].y, 0, &TextInBoxMode);
    }
  }
  const auto hpOld = Surface.SelectObject(LKPen_Black_N2);
  const auto hbOld = Surface.SelectObject(LKBrush_Grey);
  Surface.Polygon(Arrow,5);

  Surface.SelectObject(hbOld);
  Surface.SelectObject(hpOld);
}
Example #14
0
BOOL CMFCExampleApp::InitInstance ()
{
    new_t         new_array_f         = &(::operator new[]);
    new_dbg_crt_t new_dbg_crt_array_f = &(::operator new[]);

#ifdef _DEBUG
    new_dbg_mfc_t new_dbg_mfc_array_f = &(::operator new[]);
#endif

    new_t         new_f               = &(::operator new );
    new_dbg_crt_t new_dbg_crt_f       = &(::operator new );

#ifdef _DEBUG
    new_dbg_mfc_t new_dbg_mfc_f       = &(::operator new );
#endif

    void *        p1                  = FindRealCode (new_array_f);
    void *        p2                  = FindRealCode (new_dbg_crt_array_f);

#ifdef _DEBUG
    void *        p3                  = FindRealCode (new_dbg_mfc_array_f);
#endif

    void *        p4                  = FindRealCode (new_f);
    void *        p5                  = FindRealCode (new_dbg_crt_f);

#ifdef _DEBUG
    void *        p6                  = FindRealCode (new_dbg_mfc_f);
#endif

#ifdef _DEBUG

#ifndef _UNICODE

#if _MFC_VER == 0x0700       // VS 2003
#define MFCDLLNAME   _T("mfc70d.dll")
#elif _MFC_VER == 0x0800 // VS 2005
#define MFCDLLNAME   _T("mfc80d.dll")
#elif _MFC_VER == 0x0900 // VS 2008
#define MFCDLLNAME   _T("mfc90d.dll")
#elif _MFC_VER == 0x0A00 // VS 2010
#define MFCDLLNAME   _T("mfc100d.dll")
#elif _MFC_VER == 0x0B00 // VS 2012
#define MFCDLLNAME   _T("mfc110d.dll")
#endif

#else

#if _MFC_VER == 0x0700       // VS 2003
#define MFCDLLNAME   _T("mfc70ud.dll")
#elif _MFC_VER == 0x0800 // VS 2005
#define MFCDLLNAME   _T("mfc80ud.dll")
#elif _MFC_VER == 0x0900 // VS 2008
#define MFCDLLNAME   _T("mfc90ud.dll")
#elif _MFC_VER == 0x0A00 // VS 2010
#define MFCDLLNAME   _T("mfc100ud.dll")
#elif _MFC_VER == 0x0B00 // VS 2012
#define MFCDLLNAME   _T("mfc110ud.dll")
#elif _MFC_VER == 0x0C00 // VS 2013
#define MFCDLLNAME   _T("mfc120ud.dll")
#endif

#endif

#else

#ifndef _UNICODE

#if _MFC_VER == 0x0700      // VS 2003
#define MFCDLLNAME   _T("mfc70.dll")
#elif _MFC_VER == 0x0800    // VS 2005
#define MFCDLLNAME   _T("mfc80.dll")
#elif _MFC_VER == 0x0900    // VS 2008
#define MFCDLLNAME   _T("mfc90.dll")
#elif _MFC_VER == 0x0A00    // VS 2010
#define MFCDLLNAME   _T("mfc100.dll")
#elif _MFC_VER == 0x0B00    // VS 2012
#define MFCDLLNAME   _T("mfc110.dll")
#endif

#else

#if _MFC_VER == 0x0700      // VS 2003
#define MFCDLLNAME   _T("mfc70u.dll")
#elif _MFC_VER == 0x0800    // VS 2005
#define MFCDLLNAME   _T("mfc80u.dll")
#elif _MFC_VER == 0x0900    // VS 2008
#define MFCDLLNAME   _T("mfc90u.dll")
#elif _MFC_VER == 0x0A00    // VS 2010
#define MFCDLLNAME   _T("mfc100u.dll")
#elif _MFC_VER == 0x0B00    // VS 2012
#define MFCDLLNAME   _T("mfc110u.dll")
#elif _MFC_VER == 0x0C00    // VS 2013
#define MFCDLLNAME   _T("mfc120u.dll")
#endif

#endif

#endif

    HMODULE       module              = GetModuleHandle (MFCDLLNAME);

    if (NULL == module)
    {
        return FALSE;
    }

    int   o1 = GetProcOrdinal (module, p1);
    int   o2 = GetProcOrdinal (module, p2);

#ifdef _DEBUG
    int   o3 = GetProcOrdinal (module, p3);
#else
    int   o3 = -2;
#endif

    int   o4 = GetProcOrdinal (module, p4);
    int   o5 = GetProcOrdinal (module, p5);

#ifdef _DEBUG
    int   o6 = GetProcOrdinal (module, p6);
#else
    int   o6 = -2;
#endif

    TCHAR msg[256];

    _stprintf (msg, _T ("%d, %d, %d, %d, %d, %d"), o1, o2, o3, o4, o5, o6);
    SetClipboardText (msg);
    MessageBox (NULL, msg, _T ("MFC ordinals"), MB_ICONINFORMATION | MB_OK);

    return FALSE;
}
Example #15
0
void MapWindow::RenderNearAirspace(LKSurface& Surface, const RECT& rci) {
    RECT rc = rci; /* rectangle for sideview */
    RECT rct = rc; /* rectangle for topview */

    rc.top = (int) ((double) (rci.bottom - rci.top) * fSplitFact);
    rct.bottom = rc.top;
    // Expose the topview rect size in use..
    Current_Multimap_TopRect = rct;

    auto hfOldFnt = Surface.SelectObject(LK8PanelUnitFont/* Sender->GetFont()*/);

    int *iSplit = &Multimap_SizeY[Get_Current_Multimap_Type()];

    static double fHeigtScaleFact = 1.0;


    double GPSlat, GPSlon, GPSalt, GPSbrg;
    double calc_terrainalt;
    double calc_altitudeagl;

    // double alt;
    TCHAR text[TBSIZE + 1];
    TCHAR buffer[TBSIZE + 1];

    CAirspaceBase near_airspace;
    CAirspace *found = NULL;
    //  bool bFound = false;
    DiagrammStruct sDia;
    bool bAS_Inside = false;
    int iAS_Bearing = 0;
    int iAS_HorDistance = 15000;
    int iABS_AS_HorDistance = 0;
    int iAS_VertDistance = 0;
    bool bValid;
    static bool bHeightScale = false;
    long wpt_brg = 0;
    POINT line[2];
    POINT TxYPt;
    POINT TxXPt;
    SIZE tsize;
    LKColor GREEN_COL = RGB_GREEN;
    LKColor BLUE_COL = RGB_BLUE;
    LKColor LIGHTBLUE_COL = RGB_LIGHTBLUE;
    BOOL bInvCol = true; //INVERTCOLORS

    unsigned short getsideviewpage = GetSideviewPage();
    LKASSERT(getsideviewpage < 3);

    if (bInvCol)
        Sideview_TextColor = INV_GROUND_TEXT_COLOUR;
    else
        Sideview_TextColor = RGB_WHITE;

    switch (LKevent) {
        case LKEVENT_NEWRUN:
            // CALLED ON ENTRY: when we select this page coming from another mapspace
            bHeightScale = false;
            // fZOOMScale[getsideviewpage] = 1.0;
            fHeigtScaleFact = 1.0;
            if (IsMultimapTopology()) ForceVisibilityScan = true;
            break;
        case LKEVENT_UP:
            // click on upper part of screen, excluding center
            if (bHeightScale)
                fHeigtScaleFact /= ZOOMFACTOR;
            else
                fZOOMScale[getsideviewpage] /= ZOOMFACTOR;

            if (IsMultimapTopology()) ForceVisibilityScan = true;
            break;

        case LKEVENT_DOWN:
            // click on lower part of screen,  excluding center
            if (bHeightScale)
                fHeigtScaleFact *= ZOOMFACTOR;
            else
                fZOOMScale[getsideviewpage] *= ZOOMFACTOR;
            if (IsMultimapTopology()) ForceVisibilityScan = true;
            break;

        case LKEVENT_LONGCLICK:
            if (Sideview_iNoHandeldSpaces) {
                bool bShow = false;
                for (int k = 0; k <= Sideview_iNoHandeldSpaces; k++) {
                    if (Sideview_pHandeled[k].psAS != NULL) {
                        if (PtInRect(&(Sideview_pHandeled[k].rc), startScreen)) {
                            dlgAddMultiSelectListItem((long*) Sideview_pHandeled[k].psAS, 0, IM_AIRSPACE, 0);
                            bShow = true;
                        }
                    }
                }
                if (bShow) {
                    /*
                     * we can't show dialog from Draw thread
                     * instead, new event is queued, dialog will be popup by main thread 
                     */
                    InputEvents::processGlideComputer(GCE_POPUP_MULTISELECT);

                    // reset event, otherwise Distance/height zoom mod are also triggered
                    LKevent = LKEVENT_NONE;
                }
            }

            if (LKevent != LKEVENT_NONE) {
                if (PtInRect(&rc, startScreen)) {
                    bHeightScale = !bHeightScale;
                } else if (PtInRect(&rct, startScreen)) {
                    bHeightScale = false;
                }
            }
            break;

        case LKEVENT_PAGEUP:
#ifdef OFFSET_SETP
            if (bHeightScale)
                fOffset -= OFFSET_SETP;
            else
#endif
            {
                if (*iSplit == SIZE1) *iSplit = SIZE0;
                if (*iSplit == SIZE2) *iSplit = SIZE1;
                if (*iSplit == SIZE3) *iSplit = SIZE2;
            }
            break;
        case LKEVENT_PAGEDOWN:
#ifdef OFFSET_SETP
            if (bHeightScale)
                fOffset += OFFSET_SETP;
            else
#endif
            {
                if (*iSplit == SIZE2) *iSplit = SIZE3;
                if (*iSplit == SIZE1) *iSplit = SIZE2;
                if (*iSplit == SIZE0) *iSplit = SIZE1;
            }
            break;

    }

    LKASSERT(((*iSplit == SIZE0) || (*iSplit == SIZE1) || (*iSplit == SIZE2) || (*iSplit == SIZE3) || (*iSplit == SIZE4)));

    LKevent = LKEVENT_NONE;

    // Current_Multimap_SizeY is global, and must be used by all multimaps!
    // It is defined in Multimap.cpp and as an external in Multimap.h
    // It is important that it is updated, because we should resize terrain
    // only if needed! Resizing terrain takes some cpu and some time.
    // So we need to know when this is not necessary, having the same size of previous
    // multimap, if we are switching.
    // The current implementation is terribly wrong by managing resizing of sideview in
    // each multimap: it should be done by a common layer.
    // CAREFUL:
    // If for any reason DrawTerrain() is called after resizing to 0 (full sideview)
    // LK WILL CRASH with no hope to recover.
    if (Current_Multimap_SizeY != *iSplit) {
        Current_Multimap_SizeY = *iSplit;
        SetSplitScreenSize(*iSplit);
        rc.top = (long) ((double) (rci.bottom - rci.top) * fSplitFact);
        rct.bottom = rc.top;
    }


    if (bInvCol) {
        GREEN_COL = GREEN_COL.ChangeBrightness(0.6);
        BLUE_COL = BLUE_COL.ChangeBrightness(0.6);
        ;
        LIGHTBLUE_COL = LIGHTBLUE_COL.ChangeBrightness(0.4);
        ;
    }

    GPSlat = DrawInfo.Latitude;
    GPSlon = DrawInfo.Longitude;
    GPSalt = DrawInfo.Altitude;
    GPSbrg = DrawInfo.TrackBearing;
    calc_terrainalt = DerivedDrawInfo.TerrainAlt;
    calc_altitudeagl = DerivedDrawInfo.AltitudeAGL;
    GPSalt = DerivedDrawInfo.NavAltitude;

    bValid = false;
    iAS_HorDistance = 5000;
    iAS_Bearing = (int) GPSbrg;
    iAS_VertDistance = 0;
    found = CAirspaceManager::Instance().GetNearestAirspaceForSideview();
    if (found != NULL) {
        near_airspace = CAirspaceManager::Instance().GetAirspaceCopy(found);
        bValid = near_airspace.GetDistanceInfo(bAS_Inside, iAS_HorDistance, iAS_Bearing, iAS_VertDistance);
    }
    iABS_AS_HorDistance = abs(iAS_HorDistance);
    wpt_brg = (long) AngleLimit360(GPSbrg - iAS_Bearing + 90.0);


    // Variables from ASP system here contain the following informations:
    // fAS_HorDistance - always contains horizontal distance from the asp, negative if horizontally inside (This does not mean that we're inside vertically as well!)
    // fAS_Bearing - always contains bearing to the nearest horizontal point
    // bValid - true if bAS_Inside, iAS_HorDistance, iAS_Bearing, iAS_VertDistance contains valid informations
    //          this will be true if the asp border is close enough to be tracked by the warning system
    // bAS_Inside - current position is inside in the asp, calculated by the warning system
    // iAS_HorDistance - horizontal distance to the nearest horizontal border, negative if horizontally inside, calculated by the warning system
    // iAS_Bearing - bearing to the nearest horizontal border, calculated by the warning system
    // iAS_VertDistance - vertical distance to the nearest asp border, negative if the border is above us, positive if the border below us, calculated by the warning system
    // near_airspace.WarningLevel():
    //           awNone - no warning condition exists
    //           awYellow - current position is near to a warning position
    //           awRed - current posisiton is forbidden by asp system, we are in a warning position


    /*********************************************************************
     * calc the horizontal zoom
     *********************************************************************/
    sDia.fXMin = -5000.0;
    sDia.fXMax = 5000.0;
    /* even when invalid the horizontal distance is calculated correctly */


    if (bValid) {
        double fScaleDist = iABS_AS_HorDistance;

        sDia.fXMin = min(-2500.0, fScaleDist * 1.5);
        sDia.fXMax = max(2500.0, fScaleDist * 1.5);

#ifdef NEAR_AS_ZOOM_1000M
        if (((iABS_AS_HorDistance) < 900) && (bValid)) // 1km zoom
        {
            sDia.fXMin = min(-900.0, fScaleDist * 1.5);
            sDia.fXMax = max(900.0, fScaleDist * 1.5);

        }
#endif
#ifdef NEAR_AS_ZOOM_1000FT
        if ((abs(iABS_AS_HorDistance) < 333)) // 1000ft zoom
        {
            sDia.fXMin = min(-333.0, fScaleDist * 1.5);
            sDia.fXMax = max(333.0, fScaleDist * 1.5);
        }
#endif

    }


#define RND_FACT 10.0


    if ((sDia.fXMax * fZOOMScale[getsideviewpage]) > 100000)
        fZOOMScale[getsideviewpage] /= ZOOMFACTOR;

    if ((sDia.fXMax * fZOOMScale[getsideviewpage]) < 500) {
        fZOOMScale[getsideviewpage] *= ZOOMFACTOR;
    }

    double fOldZoomScale = -1;
    if (fZOOMScale[getsideviewpage] != fOldZoomScale) {
        fOldZoomScale = fZOOMScale[getsideviewpage];
        sDia.fXMax = sDia.fXMax * fZOOMScale[getsideviewpage];
        sDia.fXMin = -sDia.fXMax / 5;
    }


    /*********************************************************************
     * calc the vertical zoom
     *********************************************************************/
    sDia.fYMin = max(0.0, GPSalt - 2300);
    sDia.fYMax = max(MAXALTTODAY, GPSalt + 1000);

    if (bValid) {
        double fBottom = near_airspace.Base()->Altitude;
        sDia.fYMin = min(fBottom * 0.8, sDia.fYMin);
        sDia.fYMin = max(0.0, sDia.fYMin);
        if (sDia.fYMin < 300) sDia.fYMin = 0;
        sDia.fYMax = max((fBottom * 1.2f), sDia.fYMax);

        if (abs(iAS_VertDistance) < 250) {
            sDia.fYMax = ((int) ((GPSalt + abs(iAS_VertDistance)) / 400) + 2) *400;
            sDia.fYMin = ((int) ((GPSalt - abs(iAS_VertDistance)) / 400) - 1) *400;
            if (sDia.fYMin - MIN_ALTITUDE < 0) sDia.fYMin = 0;
        }

#ifdef VERTICAL_ZOOM_50
        if (abs(iAS_VertDistance) < 50) {
            sDia.fYMax = ((int) ((GPSalt + abs(iAS_VertDistance)) / 100) + 2) *100;
            sDia.fYMin = ((int) ((GPSalt - abs(iAS_VertDistance)) / 100) - 1) *100;
            if (sDia.fYMin - MIN_ALTITUDE < 0) sDia.fYMin = 0;
        }
#endif
        sDia.fYMin = max((double) 0.0f, (double) sDia.fYMin);

#ifdef OFFSET_SETP
        if ((sDia.fYMax + fOffset) > MAX_ALTITUDE)
            fOffset -= OFFSET_SETP;
        if ((sDia.fYMin + fOffset) < 0.0)
            fOffset += OFFSET_SETP;

        sDia.fYMin += fOffset;
        sDia.fYMax += fOffset;
#endif
        //  if(fHeigtScaleFact * sDia.fYMax > MAX_ALTITUDE )
        //    fHeigtScaleFact /=ZOOMFACTOR;

        if (fHeigtScaleFact * sDia.fYMax < MIN_ALTITUDE)
            fHeigtScaleFact *= ZOOMFACTOR;
        sDia.fYMax *= fHeigtScaleFact;
    }


    /****************************************************************************************************
     * draw topview first
     ****************************************************************************************************/

    if (fSplitFact > 0.0) {
        sDia.rc = rct;
        sDia.rc.bottom -= 1;
        SharedTopView(Surface, &sDia, (double) iAS_Bearing, (double) wpt_brg);

    }

    /****************************************************************************************************
     * draw airspace and terrain elements
     ****************************************************************************************************/
    RECT rcc = rc; /* rc corrected      */
    if (sDia.fYMin < GC_SEA_LEVEL_TOLERANCE)
        rcc.bottom -= SV_BORDER_Y; /* scale witout sea  */
    sDia.rc = rcc;

    RenderAirspaceTerrain(Surface, GPSlat, GPSlon, iAS_Bearing, &sDia);

    const auto hfOld = Surface.SelectObject(LK8InfoNormalFont);
    if (bValid) {
        LKASSERT(_tcslen(near_airspace.Name()) < TBSIZE); // Diagnostic only in 3.1j, to be REMOVED
        LK_tcsncpy(Sideview_szNearAS, near_airspace.Name(), TBSIZE);
    } else {
        _stprintf(text, TEXT("%s"), MsgToken(1259)); // LKTOKEN [email protected]_ "Too far, not calculated"
        Surface.GetTextSize(text, &tsize);
        TxYPt.x = (rc.right - rc.left - tsize.cx) / 2;
        TxYPt.y = (rc.bottom - rc.top) / 2;

        Surface.SetBackgroundTransparent();
        Surface.DrawText(TxYPt.x, TxYPt.y - 20, text);

        _stprintf(Sideview_szNearAS, TEXT("%s"), text);

    }
    Surface.SelectObject(hfOld);
    /****************************************************************************************************
     * draw airspace and terrain elements
     ****************************************************************************************************/

    /****************************************************************************************************
     * draw diagram
     ****************************************************************************************************/
    double xtick = 1.0;
    double fRange = fabs(sDia.fXMax - sDia.fXMin);
    if (fRange > 3.0 * 1000.0) xtick = 2.0;
    if (fRange > 15 * 1000.0) xtick = 5.0;
    if (fRange > 50.0 * 1000.0) xtick = 10.0;
    if (fRange > 100.0 * 1000.0) xtick = 20.0;
    if (fRange > 200.0 * 1000.0) xtick = 25.0;
    if (fRange > 250.0 * 1000.0) xtick = 50.0;
    if (fRange > 500.0 * 1000.0) xtick = 100.0;
    if (fRange > 1000.0 * 1000.0) xtick = 1000.0;

    if (bInvCol) {
        Surface.SelectObject(LK_BLACK_PEN);
        Surface.SelectObject(LKBrush_Black);
    } else {
        Surface.SelectObject(LK_WHITE_PEN);
        Surface.SelectObject(LKBrush_White);
    }

    LKColor txtCol = GROUND_TEXT_COLOUR;
    if (bInvCol)
        if (sDia.fYMin > GC_SEA_LEVEL_TOLERANCE)
            txtCol = INV_GROUND_TEXT_COLOUR;
    Surface.SetBackgroundTransparent();
    Surface.SetTextColor(txtCol);
    Surface.SelectObject(LK8PanelUnitFont);
    _stprintf(text, TEXT("%s"), Units::GetUnitName(Units::GetUserDistanceUnit()));

    switch (GetMMNorthUp(getsideviewpage)) {
        case NORTHUP:
        default:
            DrawXGrid(Surface, rc, xtick / DISTANCEMODIFY, xtick, 0, TEXT_ABOVE_LEFT, RGB_BLACK, &sDia, text);
            break;

        case TRACKUP:
            DrawXGrid(Surface, rci, xtick / DISTANCEMODIFY, xtick, 0, TEXT_ABOVE_LEFT, RGB_BLACK, &sDia, text);
            break;
    }

    Surface.SetTextColor(Sideview_TextColor);

    double fHeight = (sDia.fYMax - sDia.fYMin);
    double ytick = 100.0;
    if (fHeight > 500.0) ytick = 200.0;
    if (fHeight > 1000.0) ytick = 500.0;
    if (fHeight > 2000.0) ytick = 1000.0;
    if (fHeight > 4000.0) ytick = 2000.0;
    if (fHeight > 8000.0) ytick = 4000.0;

    if (Units::GetUserAltitudeUnit() == unFeet)
        ytick = ytick * FEET_FACTOR;

    _stprintf(text, TEXT("%s"), Units::GetUnitName(Units::GetUserAltitudeUnit()));
    if (sDia.fYMin < GC_SEA_LEVEL_TOLERANCE)
        rc.bottom -= SV_BORDER_Y; /* scale witout sea  */
    DrawYGrid(Surface, rc, ytick / ALTITUDEMODIFY, ytick, 0, TEXT_UNDER_RIGHT, Sideview_TextColor, &sDia, text);


    Surface.SetBkColor(RGB_WHITE);

    if (!bInvCol)
        Surface.SetBackgroundOpaque();
    /****************************************************************************************************
     * draw AGL
     ****************************************************************************************************/
    if (calc_altitudeagl - sDia.fYMin > 500) {
        Surface.SetTextColor(LIGHTBLUE_COL);
        Units::FormatUserAltitude(calc_altitudeagl, buffer, 7);
        LK_tcsncpy(text, MsgToken(1742), TBSIZE - _tcslen(buffer)); // AGL:
        _tcscat(text, buffer);
        Surface.GetTextSize(text, &tsize);
        TxYPt.x = CalcDistanceCoordinat(0, &sDia) - tsize.cx / 2;
        TxYPt.y = CalcHeightCoordinat((calc_terrainalt + calc_altitudeagl)*0.8, &sDia);
        if ((tsize.cy) < (CalcHeightCoordinat(calc_terrainalt, &sDia) - TxYPt.y)) {
            Surface.DrawText(TxYPt.x + IBLSCALE(1), TxYPt.y, text);
        }
    }

    Surface.SetBackgroundTransparent();

    /****************************************************************************************************
     * Print current Elevation
     ****************************************************************************************************/
    Surface.SetTextColor(RGB_BLACK);
    int x, y;
    if ((calc_terrainalt - sDia.fYMin) > 0) {
        Units::FormatUserAltitude(calc_terrainalt, buffer, 7);
        LK_tcsncpy(text, MsgToken(1743), TBSIZE - _tcslen(buffer)); // ELV:
        _tcscat(text, buffer);
        Surface.GetTextSize(text, &tsize);
        x = CalcDistanceCoordinat(0, &sDia) - tsize.cx / 2;
        y = CalcHeightCoordinat(calc_terrainalt, &sDia);
        if ((ELV_FACT * tsize.cy) < abs(rc.bottom - y)) {
            Surface.DrawText(x, rc.bottom - (int) (ELV_FACT * tsize.cy), text);
        }
    }


    /****************************************************************************************************
     * draw side elements
     ****************************************************************************************************/
    Surface.SetTextColor(Sideview_TextColor);
    Surface.SetBackgroundOpaque();
    const auto hfOld2 = Surface.SelectObject(LK8InfoNormalFont);

    //  DrawTelescope      ( hdc, iAS_Bearing-90.0, rc.right  - NIBLSCALE(13),  rc.top   + NIBLSCALE(58));

    Surface.SelectObject(hfOld2);
    Surface.SetBackgroundTransparent();

    Surface.SelectObject(hfOld);
    Surface.SetTextColor(GROUND_TEXT_COLOUR);
    if (bInvCol)
        if (sDia.fYMin > GC_SEA_LEVEL_TOLERANCE)
            Surface.SetTextColor(INV_GROUND_TEXT_COLOUR);



    /****************************************************************************************************/
    /****************************************************************************************************/
    /****************************************************************************************************
     * draw distances to next airspace
     ****************************************************************************************************/
    /****************************************************************************************************/
    /****************************************************************************************************/
    if (bValid) {

        /****************************************************************************************************
         * draw horizontal distance to next airspace
         ****************************************************************************************************/
        Surface.SetTextColor(Sideview_TextColor);
        Surface.SetBackgroundOpaque();
        const auto hfOldU = Surface.SelectObject(LK8InfoNormalFont);
        // horizontal distance
        line[0].x = CalcDistanceCoordinat(0, &sDia);
        line[0].y = CalcHeightCoordinat(GPSalt, &sDia);
        line[1].x = CalcDistanceCoordinat(iABS_AS_HorDistance, &sDia);
        line[1].y = line[0].y;
        Surface.DrawDashLine(THICK_LINE, line[0], line[1], Sideview_TextColor, rc);
        if (iAS_HorDistance < 0) {
            line[0].y = CalcHeightCoordinat(GPSalt - (double) iAS_VertDistance, &sDia);
            line[1].y = line[0].y;

            Surface.DrawDashLine(THICK_LINE, line[0], line[1], Sideview_TextColor, rc);
        }

        bool bLeft = false;
        if (line[0].x < line[1].x)
            bLeft = false;
        else
            bLeft = true;

        Units::FormatUserDistance(iABS_AS_HorDistance, buffer, 7);
        _stprintf(text, _T(" %s"), buffer);
        Surface.GetTextSize(text, &tsize);

        if ((GPSalt - sDia.fYMin /*-calc_terrainalt */) < 300)
            TxXPt.y = CalcHeightCoordinat(GPSalt, &sDia) - tsize.cy;
        else
            TxXPt.y = CalcHeightCoordinat(GPSalt, &sDia) + NIBLSCALE(3);


        if (tsize.cx > (line[1].x - line[0].x))
            TxXPt.x = CalcDistanceCoordinat(iABS_AS_HorDistance, &sDia) - tsize.cx - NIBLSCALE(3);
        else
            TxXPt.x = CalcDistanceCoordinat(iABS_AS_HorDistance / 2.0, &sDia) - tsize.cx / 2;
        Surface.DrawText(TxXPt.x, TxXPt.y, text);



        /****************************************************************************************************
         * draw vertical distance to next airspace
         ****************************************************************************************************/
        line[0].x = CalcDistanceCoordinat(iABS_AS_HorDistance, &sDia);
        line[0].y = CalcHeightCoordinat(GPSalt, &sDia);
        line[1].x = line[0].x;
        line[1].y = CalcHeightCoordinat(GPSalt - (double) iAS_VertDistance, &sDia);

        Surface.DrawDashLine(THICK_LINE, line[0], line[1], Sideview_TextColor, rc);
        Units::FormatUserAltitude((double) abs(iAS_VertDistance), buffer, 7);
        _stprintf(text, _T(" %s"), buffer);
        Surface.GetTextSize(text, &tsize);

        if (bLeft)
            TxYPt.x = CalcDistanceCoordinat(iABS_AS_HorDistance, &sDia) - tsize.cx - NIBLSCALE(3);
        else
            TxYPt.x = CalcDistanceCoordinat(iABS_AS_HorDistance, &sDia) + NIBLSCALE(5);
        if (abs(line[0].y - line[1].y) > tsize.cy)
            TxYPt.y = CalcHeightCoordinat(GPSalt - (double) iAS_VertDistance / 2.0, &sDia) - tsize.cy / 2;
        else
            TxYPt.y = min(line[0].y, line[1].y) - tsize.cy;
        Surface.DrawText(TxYPt.x, TxYPt.y, text);
        Surface.SelectObject(hfOldU);
    }

    /****************************************************************************************************
     * draw plane sideview at least
     ****************************************************************************************************/
    RenderPlaneSideview(Surface, 0.0, GPSalt, wpt_brg, &sDia);

    hfOldFnt = Surface.SelectObject(LK8InfoNormalFont/* Sender->GetFont()*/);

    DrawMultimap_SideTopSeparator(Surface, rct);

    /****************************************************************************************************
     * draw selection frame
     ****************************************************************************************************/
    if (bHeightScale)
        DrawSelectionFrame(Surface, rc);
#ifdef TOP_SELECTION_FRAME
    else
        DrawSelectionFrame(hdc, rci);
#endif
    Surface.SelectObject(hfOldFnt/* Sender->GetFont()*/);
    Surface.SetBackgroundTransparent();
    Surface.SelectObject(hfOldFnt/* Sender->GetFont()*/);
}
Example #16
0
static int ConfigParseFile(TCHAR* pszFilename)
{
#define INSIDE_NOTHING (0xFFFF & (1 << ((sizeof(TCHAR) * 8) - 1)))

	TCHAR szLine[1024];
	TCHAR* s;
	TCHAR* t;
	int nLen;

	int nLine = 0;
	TCHAR nInside = INSIDE_NOTHING;

	CheatInfo* pCurrentCheat = NULL;

	FILE* h = _tfopen(pszFilename, _T("rt"));
	if (h == NULL) {
		return 1;
	}

	while (1) {
		if (_fgetts(szLine, sizeof(szLine), h) == NULL) {
			break;
		}

		nLine++;

		nLen = _tcslen(szLine);
		// Get rid of the linefeed at the end
		while (szLine[nLen - 1] == 0x0A || szLine[nLen - 1] == 0x0D) {
			szLine[nLen - 1] = 0;
			nLen--;
		}

		s = szLine;													// Start parsing

		if (s[0] == _T('/') && s[1] == _T('/')) {					// Comment
			continue;
		}

		if ((t = LabelCheck(s, _T("include"))) != 0) {				// Include a file
			s = t;

			TCHAR szFilename[MAX_PATH] = _T("");

			// Read name of the cheat file
			TCHAR* szQuote = NULL;
			QuoteRead(&szQuote, NULL, s);

			_stprintf(szFilename, _T("%s%s.dat"), szAppCheatsPath, szQuote);

			if (ConfigParseFile(szFilename)) {
				_stprintf(szFilename, _T("%s%s.ini"), szAppCheatsPath, szQuote);
				if (ConfigParseFile(szFilename)) {
					CheatError(pszFilename, nLine, NULL, _T("included file doesn't exist"), szLine);
				}
			}

			continue;
		}

		if ((t = LabelCheck(s, _T("cheat"))) != 0) {				// Add new cheat
			s = t;

			// Read cheat name
			TCHAR* szQuote = NULL;
			TCHAR* szEnd = NULL;

			QuoteRead(&szQuote, &szEnd, s);

			s = szEnd;

			if ((t = LabelCheck(s, _T("advanced"))) != 0) {			// Advanced cheat
				s = t;
			}

			SKIP_WS(s);

			if (nInside == _T('{')) {
				CheatError(pszFilename, nLine, pCurrentCheat, _T("missing closing bracket"), NULL);
				break;
			}
#if 0
			if (*s != _T('\0') && *s != _T('{')) {
				CheatError(pszFilename, nLine, NULL, _T("malformed cheat declaration"), szLine);
				break;
			}
#endif
			nInside = *s;

			// Link new node into the list
			CheatInfo* pPreviousCheat = pCurrentCheat;
			pCurrentCheat = (CheatInfo*)malloc(sizeof(CheatInfo));
			if (pCheatInfo == NULL) {
				pCheatInfo = pCurrentCheat;
			}

			memset(pCurrentCheat, 0, sizeof(CheatInfo));
			pCurrentCheat->pPrevious = pPreviousCheat;
			if (pPreviousCheat) {
				pPreviousCheat->pNext = pCurrentCheat;
			}

			// Fill in defaults
			pCurrentCheat->nType = 0;								// Default to cheat type 0 (apply each frame)
			pCurrentCheat->nStatus = -1;							// Disable cheat

			memcpy(pCurrentCheat->szCheatName, szQuote, QUOTE_MAX);

			continue;
		}

		if ((t = LabelCheck(s, _T("type"))) != 0) {					// Cheat type
			if (nInside == INSIDE_NOTHING || pCurrentCheat == NULL) {
				CheatError(pszFilename, nLine, pCurrentCheat, _T("rogue cheat type"), szLine);
				break;
			}
			s = t;

			// Set type
			pCurrentCheat->nType = _tcstol(s, NULL, 0);

			continue;
		}

		if ((t = LabelCheck(s, _T("default"))) != 0) {				// Default option
			if (nInside == INSIDE_NOTHING || pCurrentCheat == NULL) {
				CheatError(pszFilename, nLine, pCurrentCheat, _T("rogue default"), szLine);
				break;
			}
			s = t;

			// Set default option
			pCurrentCheat->nDefault = _tcstol(s, NULL, 0);

			continue;
		}

		int n = _tcstol(s, &t, 0);
		if (t != s) {				   								// New option

			if (nInside == INSIDE_NOTHING || pCurrentCheat == NULL) {
				CheatError(pszFilename, nLine, pCurrentCheat, _T("rogue option"), szLine);
				break;
			}

			// Link a new Option structure to the cheat
			if (n < CHEAT_MAX_OPTIONS) {
				s = t;

				// Read option name
				TCHAR* szQuote = NULL;
				TCHAR* szEnd = NULL;
				if (QuoteRead(&szQuote, &szEnd, s)) {
					CheatError(pszFilename, nLine, pCurrentCheat, _T("option name omitted"), szLine);
					break;
				}
				s = szEnd;

				if (pCurrentCheat->pOption[n] == NULL) {
					pCurrentCheat->pOption[n] = (CheatOption*)malloc(sizeof(CheatOption));
				}
				memset(pCurrentCheat->pOption[n], 0, sizeof(CheatOption));

				memcpy(pCurrentCheat->pOption[n]->szOptionName, szQuote, QUOTE_MAX * sizeof(TCHAR));

				int nCurrentAddress = 0;
				bool bOK = true;
				while (nCurrentAddress < CHEAT_MAX_ADDRESS) {
					int nCPU = 0, nAddress = 0, nValue = 0;

					if (SkipComma(&s)) {
						nCPU = _tcstol(s, &t, 0);		// CPU number
						if (t == s) {
							CheatError(pszFilename, nLine, pCurrentCheat, _T("CPU number omitted"), szLine);
							bOK = false;
							break;
						}
						s = t;

						SkipComma(&s);
						nAddress = _tcstol(s, &t, 0);	// Address
						if (t == s) {
							bOK = false;
							CheatError(pszFilename, nLine, pCurrentCheat, _T("address omitted"), szLine);
							break;
						}
						s = t;

						SkipComma(&s);
						nValue = _tcstol(s, &t, 0);		// Value
						if (t == s) {
							bOK = false;
							CheatError(pszFilename, nLine, pCurrentCheat, _T("value omitted"), szLine);
							break;
						}
					} else {
						if (nCurrentAddress) {			// Only the first option is allowed no address
							break;
						}
						if (n) {
							bOK = false;
							CheatError(pszFilename, nLine, pCurrentCheat, _T("CPU / address / value omitted"), szLine);
							break;
						}
					}

					pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nCPU = nCPU;
					pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nAddress = nAddress;
					pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nValue = nValue;
					nCurrentAddress++;
				}

				if (!bOK) {
					break;
				}

			}

			continue;
		}

		SKIP_WS(s);
		if (*s == _T('}')) {
			if (nInside != _T('{')) {
				CheatError(pszFilename, nLine, pCurrentCheat, _T("missing opening bracket"), NULL);
				break;
			}

			nInside = INSIDE_NOTHING;
		}

		// Line isn't (part of) a valid cheat
#if 0
		if (*s) {
			CheatError(pszFilename, nLine, NULL, _T("rogue line"), szLine);
			break;
		}
#endif

	}

	if (h) {
		fclose(h);
	}

	return 0;
}
Example #17
0
LRESULT CALLBACK MainWndMsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_POWERBROADCAST:
		{
			SYSTEMTIME st;
			GetSystemTime(&st);

			switch(wParam)
			{
			/* Power status has changed. */
			case PBT_APMPOWERSTATUSCHANGE:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMPOWERSTATUSCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("1"), MB_OK);

					break;
				}
			/* Operation is resuming automatically from a low-power state. */
			/* This message is sent every time the system resumes. */
			case PBT_APMRESUMEAUTOMATIC:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMEAUTOMATIC %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("2"), MB_OK);

					break;
				}
			/* Operation is resuming from a low-power state. */
			/* This message is sent after PBT_APMRESUMEAUTOMATIC if the resume is triggered by user input, such as pressing a key. */
			case PBT_APMRESUMESUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMESUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("3"), MB_OK);

					break;
				}
			/* System is suspending operation. */
			case PBT_APMSUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("4"), MB_OK);

					break;
				}
			/* A power setting change event has been received. */
			case PBT_POWERSETTINGCHANGE:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_POWERSETTINGCHANGE %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("5"), MB_OK);

					break;
				}
			/* Battery power is low. In Windows Server 2008 and Windows Vista, use PBT_APMPOWERSTATUSCHANGE instead. */
			case PBT_APMBATTERYLOW:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMBATTERYLOW %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("6"), MB_OK);

					break;
				}
			/* OEM-defined event occurred. 
			/* In Windows Server 2008 and Windows Vista, this event is not available because these operating systems support only ACPI; 
			/* APM BIOS events are not supported. */
			case PBT_APMOEMEVENT:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMOEMEVENT %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("7"), MB_OK);

					break;
				}
			/* Request for permission to suspend. In Windows Server 2008 and Windows Vista, use the SetThreadExecutionState function instead. */
			case PBT_APMQUERYSUSPEND:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMQUERYSUSPEND %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("8"), MB_OK);

					break;
				}
			/* Suspension request denied. In Windows Server 2008 and Windows Vista, use SetThreadExecutionState instead. */
			case PBT_APMQUERYSUSPENDFAILED:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMQUERYSUSPENDFAILED %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("9"), MB_OK);

					break;
				}
			/* Operation resuming after critical suspension. In Windows Server 2008 and Windows Vista, use PBT_APMRESUMEAUTOMATIC instead. */
			case PBT_APMRESUMECRITICAL:
				{
					TCHAR szTime[MAX_PATH] = { 0 };
					_stprintf(szTime, TEXT("PBT_APMRESUMECRITICAL %d-%d-%d %d:%d:%d"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond);

					MessageBox(hWnd, szTime, TEXT("10"), MB_OK);

					break;
				}
			default:
				{
					break;
				}
			}
			return 0;
			break;
		}
	case WM_COMMAND:
		{
			if (HIWORD(wParam) == BN_CLICKED) {
				//SendMessage(hWndSpeedMultipleComboBox, CB_SHOWDROPDOWN, (WPARAM) TRUE, 0);
			}

			if ( HIWORD(wParam) == CBN_SELCHANGE) {               
				LRESULT  sel = SendMessage(hWndSpeedMultipleComboBox, CB_GETCURSEL, 0, 0);
				//SetWindowText(hwndStatic, items[sel]);
				//SetFocus(hwnd);
			}

			break;
		}
	case WM_CREATE:
		{
			/* 为窗口添加扩展风格 WS_EX_LAYERED,从而为实现窗口透明做准备 */
			LONG lExStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
			lExStyle = lExStyle | WS_EX_LAYERED;
			SetWindowLong(hWnd, GWL_EXSTYLE, lExStyle);

			/* 实现窗口透明 - 设置窗口透明度为 220 */
			SetLayeredWindowAttributes(hWnd, 0, WND_TRANSPARENCY, LWA_ALPHA);


			InitSpeedMultipleComboBox(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化 Tracker Bar */
			InitSpeedMultipleTrackBar(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化按钮 */
			InitButton(((LPCREATESTRUCT)lParam)->hInstance, hWnd);


			/* 初始化速度未改变的进程列表框 */
			InitNotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 初始化速度已改变的进程列表框 */
			InitHasSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance, hWnd);

			/* 绑定数据到速度未改变的进程列表框 */
			BindData2NotSpeedMultipleListView(((LPCREATESTRUCT)lParam)->hInstance);

			break;
		}
	case WM_CTLCOLORSTATIC:
		{
			/* 使得静态文本框使用透明背景色 */
			return (DWORD)GetStockObject(NULL_BRUSH);
		}
		/*case WM_COMMAND:
		{
		switch (wParam)
		{
		case ID_BUTTON_INSERT_PROCESS:
		{
		DestroyWindow(hWnd);

		break;
		}
		case ID_BUTTON_REMOVE_PROCESS:
		{
		break;
		}
		case ID_BUTTON_REFRESH_PROCESS:
		{
		break;
		}
		default:
		{
		break;
		}
		}
		break;
		}*/
	case WM_CLOSE:
		{
			DestroyWindow(hWnd);

			break;
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0);

			break;
		}
	default:
		{
			break;
		}
	}

	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
Example #18
0
static int ConfigParseMAMEFile()
{

#define AddressInfo()	\
	int k = (flags >> 20) & 3;	\
	for (int i = 0; i < k+1; i++) {	\
		pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nCPU = 0;	\
		pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nAddress = nAddress + i;	\
		pCurrentCheat->pOption[n]->AddressInfo[nCurrentAddress].nValue = (nValue >> ((k*8)-(i*8))) & 0xff;	\
		nCurrentAddress++;	\
	}	\

#define OptionName(a)	\
	if (pCurrentCheat->pOption[n] == NULL) {						\
		pCurrentCheat->pOption[n] = (CheatOption*)malloc(sizeof(CheatOption));		\
	}											\
	memset(pCurrentCheat->pOption[n], 0, sizeof(CheatOption));				\
	_tcsncpy (pCurrentCheat->pOption[n]->szOptionName, a, QUOTE_MAX * sizeof(TCHAR));	\

#define tmpcpy(a)	\
	_tcsncpy (tmp, szLine + c0[a] + 1, c0[a+1] - (c0[a]+1));	\
	tmp[c0[a+1] - (c0[a]+1)] = '\0';				\

	TCHAR szFileName[MAX_PATH] = _T("");
	_stprintf(szFileName, _T("%scheat.dat"), szAppCheatsPath);
	
	FILE *fz = _tfopen(szFileName, _T("rt"));
	if (fz == NULL) {
		return 1;
	}

	TCHAR tmp[256];
	TCHAR gName[64];
	TCHAR szLine[1024];

	int nLen;
	int n = 0;
	int menu = 0;
	int nFound = 0;
	int nCurrentAddress = 0;
	unsigned int flags = 0;
	unsigned int nAddress = 0;
	unsigned int nValue = 0;

	CheatInfo* pCurrentCheat = NULL;
	_stprintf(gName, _T(":%s:"), BurnDrvGetText(DRV_NAME));

	while (1)
	{
		if (_fgetts(szLine, 1024, fz) == NULL)
			break;

		nLen = lstrlen (szLine);

		if (szLine[0] == ';') continue;

		if (_tcsncmp (szLine, gName, lstrlen(gName))) {
			if (nFound) break;
			else continue;
		}

		nFound = 1;

		int c0[16], c1 = 0;					// find colons / break
		for (int i = 0; i < nLen; i++)
			if (szLine[i] == ':' || szLine[i] == '\n')
				c0[c1++] = i;

		tmpcpy(1);						// control flags
		_stscanf (tmp, _T("%x"), &flags);

		tmpcpy(2);						// cheat address
		_stscanf (tmp, _T("%x"), &nAddress);

		tmpcpy(3);						// cheat value
		_stscanf (tmp, _T("%x"), &nValue);

		tmpcpy(5);						// cheat name

		if (flags & 0x80007f00) continue;			// skip various cheats

		// controls how many bytes we're going to patch (only allow single bytes for now)
	//	if (flags & 0x00300000) continue;
	//	nValue &= 0x000000ff;			// only use a single byte

		if ( flags & 0x00008000 || (flags & 0x0001000 && !menu)) {
			if (nCurrentAddress < CHEAT_MAX_ADDRESS) {
				AddressInfo();
			}

			continue;
		}

		if (~flags & 0x00010000) {
			n = 0;
			menu = 0;
			nCurrentAddress = 0;

			// Link new node into the list
			CheatInfo* pPreviousCheat = pCurrentCheat;
			pCurrentCheat = (CheatInfo*)malloc(sizeof(CheatInfo));
			if (pCheatInfo == NULL) {
				pCheatInfo = pCurrentCheat;
			}

			memset(pCurrentCheat, 0, sizeof(CheatInfo));
			pCurrentCheat->pPrevious = pPreviousCheat;
			if (pPreviousCheat) {
				pPreviousCheat->pNext = pCurrentCheat;
			}

			// Fill in defaults
			pCurrentCheat->nType = 0;							// Default to cheat type 0 (apply each frame)
			pCurrentCheat->nStatus = -1;							// Disable cheat
			pCurrentCheat->nDefault = 0;							// Set default option

			_tcsncpy (pCurrentCheat->szCheatName, tmp, QUOTE_MAX);

			if (lstrlen(tmp) <= 0 || flags == 0x60000000) {
				n++;
				continue;
			}

			OptionName(_T("Disabled"));

			if (nAddress) {
				n++;

				OptionName(tmp);	
				AddressInfo();
			} else {
				menu = 1;
			}

			continue;
		}

		if ( flags & 0x00010000 && menu) {
			n++;
			nCurrentAddress = 0;

			OptionName(tmp);
			AddressInfo();
			
			continue;
		}
	}

	fclose (fz);

	return 0;
}
Example #19
0
void updateConsole()
{
	_TCHAR szText[64 * sizeof(_TCHAR)];
	int y = 0;
	console->print(Advanced2D::Engine::getVersionText().c_str(), y++);
	y++;
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText),
	            TEXT("SCREEN : %f ms ( %f fps)"),
	            static_cast<float>(1000.0f / g_engine->getFrameRate_real()),
	            static_cast<float>(g_engine->getFrameRate_real()));
#else
	_stprintf(szText, TEXT("SCREEN : %f ms ( %f fps)"),
	          static_cast<float>(1000.0f / g_engine->getFrameRate_real()),
	          static_cast<float>(g_engine->getFrameRate_real()));
#endif
	console->print(szText, y++);
	y++;
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText),
	            TEXT("CORE : %f ms ( %f fps)"),
	            static_cast<float>(1000.0f / g_engine->getFrameRate_core()),
	            static_cast<float>(g_engine->getFrameRate_core()));
#else
	_stprintf(szText, TEXT("CORE : %f ms ( %f fps)"),
	          static_cast<float>(1000.0f / g_engine->getFrameRate_core()),
	          static_cast<float>(g_engine->getFrameRate_core()));
#endif
	console->print(szText, y++);
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText),
	            TEXT("Processor throttling: %i"),
	            g_engine->getMaximizeProcessor());
#else
	_stprintf(szText, TEXT("Processor throttling: %i"),
	          g_engine->getMaximizeProcessor());
#endif
	console->print(szText, y++);
	y++;
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText), TEXT("Screen: %i"),
	            Advanced2D::Engine::getColorDepth());
#else
	_stprintf(szText, TEXT("Screen: %i"), Advanced2D::Engine::getColorDepth());
#endif
	console->print(szText, y++);
	y++;
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText), TEXT("Entities: %i"),
	            static_cast<int>(g_engine->getEntityList()->size()));
#else
	_stprintf(szText, TEXT("Entities: %i"),
	          static_cast<int>(g_engine->getEntityList()->size()));
#endif
	console->print(szText, y++);
#if _MSC_VER > 1310
	_stprintf_s(szText, sizeof(szText) / sizeof(*szText), TEXT("Collisions: %i"),
	            collisions);
#else
	_stprintf(szText, TEXT("Collisions: %i"), collisions);
#endif
	console->print(szText, y++);
	y++;
	console->print(TEXT("Press F2 to toggle Processor Throttling"), y);
}
Example #20
0
BOOL DbgPrint(__in LPCTSTR lpszFormatString, ...)
{
    BOOL    bResult = TRUE;

    va_list VAList;
    va_start(VAList, lpszFormatString);

    if (g_bSaveLogFile)
    {
#if defined(DBG_THREADSAFE)
        OS_CAutoLock lock(s_mtxEntry);
#endif
        if (!s_bLogPathInit)
        {
            SYSTEMTIME stime = {0};
            GetLocalTime(&stime);
#if defined(UNDER_CE)
            _stprintf(s_szLogFile, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#else
            _stprintf_s(s_szLogFile, MAX_PATH, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#endif
            s_bLogPathInit = true;
        }

        FILE* pFile = _tfopen(s_szLogFile, _T("a"));
        if (pFile != NULL)
        {
            fseek(pFile,SEEK_END,0);
            long cbSize = ftell(pFile);
            if (cbSize > MAX_LOG_FILE_SIZE)
            {
                fclose(pFile);
                {
                    SYSTEMTIME stime = {0};
                    GetLocalTime(&stime);
#if defined(UNDER_CE)
                    _stprintf(s_szLogFile, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#else
                    _stprintf_s(s_szLogFile, MAX_PATH, _T("%s\\log_%04d%02d%02d_%d.log"), g_bLogSavePath, stime.wYear, stime.wMonth, stime.wDay, GetTickCount());
#endif
                    s_bLogPathInit = true;
                }
                pFile = _tfopen(s_szLogFile, _T("a"));
                if (pFile == NULL)
                {
                    return FALSE;
                }
            }
            _vftprintf(pFile, lpszFormatString, VAList);
            fflush(pFile);
            fclose(pFile);
            pFile = NULL;
        }
    }
    else
    {
#if defined(UNDER_CE)
        _vtprintf(lpszFormatString, VAList);
#else
        TCHAR szBuf[MAX_PATH * 2] = {0};
        _vstprintf_s(szBuf, MAX_PATH, lpszFormatString, VAList);
        OutputDebugString(szBuf);
#endif
    }
    va_end(VAList);

    return bResult;
}
Example #21
0
/*****************************************************************************
 * Manage: manage main thread messages
 *****************************************************************************
 * In this function, called approx. 10 times a second, we check what the
 * main program wanted to tell us.
 *****************************************************************************/
void Timer::Notify( void )
{
    vlc_value_t val;
    char *shortname;

    /* Update the input */
    if( p_intf->p_sys->p_input == NULL )
    {
        p_intf->p_sys->p_input =
            (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
                                               FIND_ANYWHERE );

        /* Show slider */
        if( p_intf->p_sys->p_input )
        {
            ShowWindow( p_main_interface->hwndSlider, SW_SHOW );
            ShowWindow( p_main_interface->hwndLabel, SW_SHOW );
            ShowWindow( p_main_interface->hwndVol, SW_SHOW );

            // only for local file, check if works well with net url
            input_item_t *p_item =input_GetItem(p_intf->p_sys->p_input);
            shortname = strrchr( input_item_GetURL(p_item), '\\' );
            if (! shortname)
                shortname = input_item_GetURL(p_item);
            else shortname++;
 
            SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
                         (WPARAM) 0, (LPARAM)_FROMMB(shortname) );

            p_main_interface->TogglePlayButton( PLAYING_S );
            i_old_playing_status = PLAYING_S;
        }
    }
    else if( p_intf->p_sys->p_input->b_dead )
    {
        /* Hide slider */
        ShowWindow( p_main_interface->hwndSlider, SW_HIDE);
        ShowWindow( p_main_interface->hwndLabel, SW_HIDE);
        ShowWindow( p_main_interface->hwndVol, SW_HIDE);

        p_main_interface->TogglePlayButton( PAUSE_S );
        i_old_playing_status = PAUSE_S;

        SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
                     (WPARAM) 0, (LPARAM)(LPCTSTR) TEXT(""));

        vlc_object_release( p_intf->p_sys->p_input );
        p_intf->p_sys->p_input = NULL;
    }

    if( p_intf->p_sys->p_input )
    {
        input_thread_t *p_input = p_intf->p_sys->p_input;

        if( vlc_object_alive (p_input) )
        {
            /* New input or stream map change */
            p_intf->p_sys->b_playing = 1;

            /* Manage the slider */
            if( /*p_input->stream.b_seekable &&*/ p_intf->p_sys->b_playing )
            {
                /* Update the slider if the user isn't dragging it. */
                if( p_intf->p_sys->b_slider_free )
                {
                    vlc_value_t pos;
                    char psz_time[ MSTRTIME_MAX_SIZE ];
                    vlc_value_t time;
                    mtime_t i_seconds;

                    /* Update the value */
                    var_Get( p_input, "position", &pos );
                    if( pos.f_float >= 0.0 )
                    {
                        p_intf->p_sys->i_slider_pos =
                            (int)(SLIDER_MAX_POS * pos.f_float);

                        SendMessage( p_main_interface->hwndSlider, TBM_SETPOS,
                                     1, p_intf->p_sys->i_slider_pos );

                        var_Get( p_intf->p_sys->p_input, "time", &time );
                        i_seconds = time.i_time / 1000000;
                        secstotimestr ( psz_time, i_seconds );

                        SendMessage( p_main_interface->hwndLabel, WM_SETTEXT,
                                     (WPARAM)1, (LPARAM)_FROMMB(psz_time) );
                    }
                }
            }

            /* Take care of the volume, etc... */
            p_main_interface->Update();

            /* Manage Playing status */
            var_Get( p_input, "state", &val );
            if( i_old_playing_status != val.i_int )
            {
                if( val.i_int == PAUSE_S )
                {
                    p_main_interface->TogglePlayButton( PAUSE_S );
                }
                else
                {
                    p_main_interface->TogglePlayButton( PLAYING_S );
                }
                i_old_playing_status = val.i_int;
            }

            /* Manage Speed status */
            var_Get( p_input, "rate", &val );
            if( i_old_rate != val.i_int )
            {
                TCHAR psz_text[15];
                _stprintf( psz_text + 2, _T("x%.2f"), 1000.0 / val.i_int );
                psz_text[0] = psz_text[1] = _T('\t');

                SendMessage( p_main_interface->hwndSB, SB_SETTEXT,
                             (WPARAM) 1, (LPARAM)(LPCTSTR) psz_text );

                i_old_rate = val.i_int;
            }
        }
    }
    else if( p_intf->p_sys->b_playing && vlc_object_alive( p_intf ) )
    {
        p_intf->p_sys->b_playing = 0;
        p_main_interface->TogglePlayButton( PAUSE_S );
        i_old_playing_status = PAUSE_S;
    }

    if( !vlc_object_alive( p_intf ) )
    {
        /* Prepare to die, young Skywalker */
/*        p_main_interface->Close(TRUE);*/
        return;
    }
}
Example #22
0
static int OnRemoteUpdate(void)
{
int Idx=0;
  if(RadioPara.Changed)
  {
    RadioPara.Changed =FALSE;
    TCHAR Name[250];
    if(_tcscmp(_T("        "), RadioPara.ActiveName ) == 0)
      Idx = SearchStation(RadioPara.ActiveFrequency);
    if(Idx !=0)
    {
        _stprintf(RadioPara.ActiveName,_T("%s"),WayPointList[Idx].Name);
        ActiveRadioIndex = Idx;
        if( HoldOff ==0)
        {
          HoldOff = HOLDOFF_TIME;
          devPutFreqActive(devA(), RadioPara.ActiveFrequency, WayPointList[Idx].Name);
          devPutFreqActive(devB(), RadioPara.ActiveFrequency, WayPointList[Idx].Name);
        }
    }
    _stprintf(Name,_T("[%s]"),RadioPara.ActiveName);
    if(wpnewActive)
      wpnewActive->SetCaption(Name);
    _stprintf(Name,_T("%6.03f"),RadioPara.ActiveFrequency);
    if(wpnewActiveFreq)
      wpnewActiveFreq->SetCaption(Name);


    if(_tcscmp(_T("        "), RadioPara.PassiveName ) == 0)
    Idx = SearchStation(RadioPara.PassiveFrequency);
    if(Idx !=0)
    {
        _stprintf(RadioPara.PassiveName,_T("%s"),WayPointList[Idx].Name);
        PassiveRadioIndex = Idx;
        if( HoldOff ==0)
        {
          HoldOff = HOLDOFF_TIME;
          devPutFreqStandby(devA(), RadioPara.PassiveFrequency, WayPointList[Idx].Name);
          devPutFreqStandby(devB(), RadioPara.PassiveFrequency, WayPointList[Idx].Name);
        }
    }
    _stprintf(Name,_T("[%s]"),RadioPara.PassiveName);
    if(wpnewPassive)
     wpnewPassive->SetCaption(Name);
    _stprintf(Name,_T("%6.03f"),RadioPara.PassiveFrequency);
    if(wpnewPassiveFreq)
     wpnewPassiveFreq->SetCaption(Name);
/*
        if( lSquelch !=  RadioPara.Squelch)
        {
              VolMode = SQL;
              SqCnt =0;
        }
*/
        if( lVolume !=  RadioPara.Volume)
              VolMode = VOL;
        lSquelch =  RadioPara.Squelch;
        lVolume =  RadioPara.Volume;
        if(wpnewVol)
        {
      if(VolMode == VOL)
            _stprintf(Name,_T("V[%i]"),RadioPara.Volume);
      else
        _stprintf(Name,_T("S [%i]"),RadioPara.Squelch);
          wpnewVol->SetCaption(Name);
        }

        if(RadioPara.Dual)
          _stprintf(Name,_T("[Dual Off]"));
        else
          _stprintf(Name,_T("[Dual On]"));
        if(wpnewDual)
              wpnewDual->SetCaption(Name);
      return 1;
    }
    return 0;
}
Example #23
0
int KG_HttpClient::RequestPost(
   const TCHAR cszAgent[], 
   const TCHAR cszAddress[], 
   const TCHAR cszVerb[],
   int nPort
)
{
    int nResult = false;
    int nRetCode = false;
    LPCSTR clpAcceptTypeArray[] = {"*/*", NULL};
    BYTE *pbyBuffer = NULL;
    DWORD dwBufferSize = 0;
    DWORD dwBytesWrite = 0;
    DWORD dwBytesRead = 0;
    DWORD dwBytesToRead = 0;
    INTERNET_BUFFERS InternetBuffer;
    LPCSTR clpContent = TEXT("Content-Type: multipart/form-data; boundary=-------------------------24822581126073\r\n");
    TCHAR szContentLength[64];

    KG_DELETE_ARRAY(m_pResponseBuffer);

    m_hInternetSession = ::InternetOpen(
        cszAgent,
        INTERNET_OPEN_TYPE_PRECONFIG,
        NULL,
        NULL,
        0
    );
    KGLOG_PROCESS_ERROR(m_hInternetSession);

    m_hInternetConnection = ::InternetConnect(
        m_hInternetSession,
        cszAddress,
        (INTERNET_PORT)nPort,
        NULL,
        NULL,
        INTERNET_SERVICE_HTTP,
        INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE,
        0
    );
    KGLOG_PROCESS_ERROR(m_hInternetConnection);

    m_hHttpRequest = ::HttpOpenRequest(
        m_hInternetConnection,
        "POST",
        cszVerb,
        HTTP_VERSION,
        NULL,
        clpAcceptTypeArray,
        INTERNET_FLAG_KEEP_CONNECTION | INTERNET_FLAG_NO_CACHE_WRITE | INTERNET_FLAG_FORMS_SUBMIT,
        0
    );
    KGLOG_PROCESS_ERROR(m_hHttpRequest);

    nRetCode = GetPostBuffer(&pbyBuffer, &dwBufferSize);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = ::HttpAddRequestHeaders(m_hHttpRequest, "Accept: */*\r\n", (DWORD)_tcslen("Accept: */*\r\n"), HTTP_ADDREQ_FLAG_REPLACE);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = ::HttpAddRequestHeaders(m_hHttpRequest, clpContent, (DWORD)_tcslen(clpContent), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
    KGLOG_PROCESS_ERROR(nRetCode);

    _stprintf(szContentLength, "Content-Length: %d\r\n", dwBufferSize);

    nRetCode = ::HttpAddRequestHeaders(m_hHttpRequest, szContentLength,(DWORD) _tcslen(szContentLength), HTTP_ADDREQ_FLAG_ADD_IF_NEW);
    KGLOG_PROCESS_ERROR(nRetCode);

    memset(&InternetBuffer, 0, sizeof(InternetBuffer));

    InternetBuffer.dwStructSize = sizeof(InternetBuffer);

    nRetCode = ::HttpSendRequestEx(m_hHttpRequest, &InternetBuffer, NULL, HSR_INITIATE, 0);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = ::InternetWriteFile(m_hHttpRequest, pbyBuffer, dwBufferSize, &dwBytesWrite);
    KGLOG_PROCESS_ERROR(nRetCode);

    nRetCode = ::HttpEndRequest(m_hHttpRequest, NULL, HSR_INITIATE, 0);
    KGLOG_PROCESS_ERROR(nRetCode);

    dwBufferSize = (DWORD)sizeof(szContentLength);

    nRetCode = ::HttpQueryInfo(m_hHttpRequest, HTTP_QUERY_CONTENT_LENGTH, szContentLength, &dwBufferSize, NULL);
    KGLOG_PROCESS_ERROR(nRetCode);

    dwBytesToRead = atoi(szContentLength);

    KG_DELETE_ARRAY(m_pResponseBuffer);

    m_pResponseBuffer = new BYTE[dwBytesToRead + 1];
    ZeroMemory(m_pResponseBuffer, dwBytesToRead + 1);

    nRetCode = ::InternetReadFile(m_hHttpRequest, m_pResponseBuffer, dwBytesToRead, &dwBytesRead);
    KGLOG_PROCESS_ERROR(nRetCode);

    m_pResponseBuffer[dwBytesToRead] = '\0';

    m_dwBufferSize = dwBytesRead;

    nResult = true;
Exit0:
    if (!nResult)
    {
        KG_DELETE_ARRAY(m_pResponseBuffer);
    }

    KG_DELETE_ARRAY(pbyBuffer);

    KG_INTERNET_HANDLE_CLOSE(m_hHttpRequest);
    KG_INTERNET_HANDLE_CLOSE(m_hInternetConnection);
    KG_INTERNET_HANDLE_CLOSE(m_hInternetSession);

    for (size_t i = 0; i < m_PostList.size(); ++i)
    {
        KG_DELETE_ARRAY(m_PostList[i].pParamName);
        KG_DELETE_ARRAY(m_PostList[i].pValue);
    }
    m_PostList.clear();

    return nResult;
}
Example #24
0
static int OnUpdate(void) {
TCHAR Name[250];

    if((ValidWayPoint(ActiveRadioIndex)) &&0)
    {
        if( ActiveRadioIndex > RESWP_END)
        {
          _stprintf(Name,_T("%s"),WayPointList[ActiveRadioIndex].Name);
          if(wpnewActive)
            wpnewActive->SetCaption(Name);
          _stprintf(Name,_T("%s"),WayPointList[ActiveRadioIndex].Freq);
          if(wpnewActiveFreq)
            wpnewActiveFreq->SetCaption(Name);
        }
    }
    else
    {
        _stprintf(Name,_T("%s"),RadioPara.ActiveName);
        if(wpnewActive)
          wpnewActive->SetCaption(Name);
        _stprintf(Name,_T("%7.3f"),RadioPara.ActiveFrequency);
        if(wpnewActiveFreq)
          wpnewActiveFreq->SetCaption(Name);        
    }


    if((ValidWayPoint(PassiveRadioIndex)) && 0)
    {
        if( PassiveRadioIndex > RESWP_END )        
        {
          _stprintf(Name,_T("%s"),WayPointList[PassiveRadioIndex].Name);
          if(wpnewPassive)
            wpnewPassive->SetCaption(Name);
          _stprintf(Name,_T("%s"),WayPointList[PassiveRadioIndex].Freq);
          if(wpnewPassiveFreq)
            wpnewPassiveFreq->SetCaption(Name);
        }
    }
    else
    {
        _stprintf(Name,_T("%s"),RadioPara.PassiveName);
        if(wpnewPassive)
          wpnewPassive->SetCaption(Name);
        _stprintf(Name,_T("%7.3f"),RadioPara.PassiveFrequency);
        if(wpnewPassiveFreq)
          wpnewPassiveFreq->SetCaption(Name);        
    }


    if(wpnewVol)
    {
        if(VolMode == VOL)   {
           _stprintf(Name,_T("V%i"),lVolume);
           wpnewVol->SetCaption(Name);
        }    else      {
        _stprintf(Name,_T("S%i"),lSquelch);
          wpnewVol->SetCaption(Name);
        }
    }
return 0;
}
Example #25
0
void MapWindow::DrawMapScale(HDC hDC, const RECT rc /* the Map Rect*/, 
                             const bool ScaleChangeFeedback)
{
    static short terrainwarning=0;
    static POINT lineOneStart, lineOneEnd,lineTwoStart,lineTwoEnd,lineThreeStart,lineThreeEnd;
    static POINT lineTwoStartB,lineThreeStartB;
    static bool flipflop=true;

    if (DoInit[MDI_DRAWMAPSCALE]) {
	lineOneStart.x = rc.right-NIBLSCALE(6); 
	lineOneEnd.x   = rc.right-NIBLSCALE(6);
	lineOneStart.y = rc.bottom-BottomSize-NIBLSCALE(4);
	lineOneEnd.y = lineOneStart.y - NIBLSCALE(42);

	lineTwoStart.x = rc.right-NIBLSCALE(11); 
	lineTwoEnd.x = rc.right-NIBLSCALE(6);
	lineTwoEnd.y = lineOneStart.y;
	lineTwoStart.y = lineOneStart.y;

	lineThreeStart.y = lineTwoStart.y - NIBLSCALE(42);
	lineThreeEnd.y = lineThreeStart.y;
	lineThreeStart.x = lineTwoStart.x;
	lineThreeEnd.x = lineTwoEnd.x;

	lineTwoStartB=lineTwoStart;
	lineTwoStartB.x++;
	lineThreeStartB=lineThreeStart;
	lineThreeStartB.x++;

	DoInit[MDI_DRAWMAPSCALE]=false;
    }

    TCHAR Scale[200];
    TCHAR Scale1[200];
    TCHAR Scale2[200];
    TCHAR TEMP[20];

    HPEN hpOld = (HPEN)SelectObject(hDC, hpMapScale2);

    DrawSolidLine(hDC,lineOneStart,lineOneEnd, rc);
    DrawSolidLine(hDC,lineTwoStart,lineTwoEnd, rc);
    DrawSolidLine(hDC,lineThreeStart,lineThreeEnd, rc);

    SelectObject(hDC, LKPen_White_N0);
    DrawSolidLine(hDC,lineOneStart,lineOneEnd, rc);
    DrawSolidLine(hDC,lineTwoStartB,lineTwoEnd, rc);
    DrawSolidLine(hDC,lineThreeStartB,lineThreeEnd, rc);

    SelectObject(hDC, hpOld);

    flipflop=!flipflop;

    _tcscpy(Scale2,TEXT(""));

    bool inpanmode= (!mode.Is(Mode::MODE_TARGET_PAN) && mode.Is(Mode::MODE_PAN));

    if (inpanmode) {
	if (DerivedDrawInfo.TerrainValid) {
		_stprintf(Scale2, _T(" %.0f%s "),ALTITUDEMODIFY*RasterTerrain::GetTerrainHeight(GetPanLatitude(), GetPanLongitude()),
		Units::GetUnitName(Units::GetUserAltitudeUnit()));
	}
	double pandistance, panbearing;
	DistanceBearing(DrawInfo.Latitude,DrawInfo.Longitude,GetPanLatitude(),GetPanLongitude(),&pandistance,&panbearing);
	_stprintf(Scale, _T(" %.1f%s %.0f%s "), pandistance*DISTANCEMODIFY, Units::GetDistanceName(), panbearing,_T(DEG) );
	_tcscat(Scale2,Scale);
	goto _skip1;
    }

    //
    // This stuff is not painted while panning, to save space on screen
    //

    // warn about missing terrain
    if (!DerivedDrawInfo.TerrainValid) {
	if (terrainwarning < 120) {
		// LKTOKEN [email protected]_ " TERRAIN?"
		_tcscat(Scale2, MsgToken(1335));
		terrainwarning++;
	} else  {
		// LKTOKEN [email protected]_ " T?"
		_tcscat(Scale2, MsgToken(1336));
		terrainwarning=120;
	}
    } else terrainwarning=0;

    if (ActiveMap) {
      _tcscat(Scale2, MsgToken(1661)); // ACT
    }
    if (UseTotalEnergy) {
      _tcscat(Scale2, TEXT("[TE]")); // Total Energy indicator
    }
    if (zoom.AutoZoom()) {
		// LKTOKEN [email protected]_ " AZM"
      _tcscat(Scale2, MsgToken(1337));
    }

_skip1:

    //
    // Back painting stuff even in PAN mode
    //

    if (mode.AnyPan()) {
		// LKTOKEN [email protected]_ " PAN"
      _tcscat(Scale2, MsgToken(1338));
    }

    if (DrawBottom) {
	switch(BottomMode) {
		case BM_TRM:
				// LKTOKEN [email protected]_ " TRM0"
      			_tcscat(Scale2, MsgToken(1340));
			break;
		case BM_CRU:
				// LKTOKEN [email protected]_ " NAV1"
      			_tcscat(Scale2, MsgToken(1341));
			break;
		case BM_HGH:
				// LKTOKEN [email protected]_ " ALT2"
      			_tcscat(Scale2, MsgToken(1342));
			break;
		case BM_AUX:
				// LKTOKEN [email protected]_ " STA3"
      			_tcscat(Scale2, MsgToken(1343));
			break;
		case BM_TSK:
				// LKTOKEN [email protected]_ " TSK4"
      			_tcscat(Scale2, MsgToken(1344));
			break;
		case BM_ALT:
				// LKTOKEN [email protected]_ " ATN5"
      			_tcscat(Scale2, MsgToken(1345));
			break;
		case BM_SYS:
				// LKTOKEN [email protected]_ " SYS6"
      			_tcscat(Scale2, MsgToken(1346));
			break;
		case BM_CUS2:
				// LKTOKEN [email protected]_ " CRU7"
      			_tcscat(Scale2, MsgToken(1347));
			break;
		case BM_CUS3:
				// LKTOKEN [email protected]_ " FIN8"
      			_tcscat(Scale2, MsgToken(1348));
			break;
		case BM_CUS:
				// LKTOKEN [email protected]_ " AUX9"
      			_tcscat(Scale2, MsgToken(1349));
			break;
		default:
			break;
	}
    }

    if (inpanmode) goto _skip2;

    if (ReplayLogger::IsEnabled()) {
	_stprintf(Scale,_T("%s %.0fX"),
		MsgToken(1350), // " REPLAY"
		ReplayLogger::TimeScale);
      _tcscat(Scale2, Scale);
    }
    if (BallastTimerActive) {
		// LKTOKEN [email protected]_ " BALLAST"
      _stprintf(TEMP,TEXT("%s %3.0fL"), MsgToken(1351), WEIGHTS[2]*BALLAST);
      _tcscat(Scale2, TEMP);
    }

_skip2:

    _tcscpy(Scale,TEXT(""));
    _tcscpy(Scale1,TEXT(""));

    //if (SIMMODE && (!mode.Is(Mode::MODE_TARGET_PAN) && mode.Is(Mode::MODE_PAN)) ) {
    if (inpanmode) {

	TCHAR sCoordinate[32]={0};
	Units::CoordinateToString(GetPanLongitude(), GetPanLatitude(), sCoordinate, sizeof(sCoordinate)-1);
	_tcscat(Scale, sCoordinate);
	_tcscat(Scale, _T(" "));
    }
    double mapScale=Units::ToSysDistance(zoom.Scale()*1.4);	// 1.4 for mapscale symbol size on map screen
    // zoom.Scale() gives user units, but FormatUserMapScale() needs system distance units
    Units::FormatUserMapScale(NULL, mapScale, Scale1, sizeof(Scale1)/sizeof(Scale1[0]));
    _tcscat(Scale,Scale1);

    SIZE tsize;

    SetBkMode(hDC,TRANSPARENT);
    HFONT oldFont = (HFONT)SelectObject(hDC, MapWindowFont);
    HPEN  oldPen=(HPEN)SelectObject(hDC, GetStockObject(BLACK_PEN));
    HBRUSH oldBrush=(HBRUSH)SelectObject(hDC, GetStockObject(BLACK_BRUSH));

    GetTextExtentPoint(hDC, Scale, _tcslen(Scale), &tsize);
    COLORREF mapscalecolor=OverColorRef;
    if (mapscalecolor==RGB_SBLACK) mapscalecolor=RGB_WHITE;

    LKWriteText(hDC, Scale, rc.right-NIBLSCALE(11)-tsize.cx, lineThreeEnd.y+NIBLSCALE(3), 0, WTMODE_OUTLINED, WTALIGN_LEFT, mapscalecolor, true); 

    GetTextExtentPoint(hDC, Scale2, _tcslen(Scale2), &tsize);

    if (!DerivedDrawInfo.TerrainValid) {
	if (terrainwarning>0 && terrainwarning<120) mapscalecolor=RGB_RED;
    }

    if (mapscalecolor!=RGB_RED) {
	if (ActiveMap) {
		if (flipflop)
			mapscalecolor=RGB_YELLOW;
		else
			mapscalecolor=RGB_RED;
	}
    }
		
    LKWriteText(hDC, Scale2, rc.right-NIBLSCALE(11)-tsize.cx, lineThreeEnd.y+NIBLSCALE(3)+tsize.cy, 
	0, WTMODE_OUTLINED, WTALIGN_LEFT, mapscalecolor, true); 

    SelectObject(hDC, oldPen);
    SelectObject(hDC, oldBrush);
    SelectObject(hDC,oldFont);

}
Example #26
0
BOOL EWMicroRecorderDeclare(PDeviceDescriptor_t d, Declaration_t *decl, unsigned errBufferLen, TCHAR errBuffer[])
{
  const WAYPOINT *wp;
  nDeclErrorCode = 0;

  // Must have at least two, max 12 waypoints
  if(decl->num_waypoints < 2) {
    // LKTOKEN  [email protected]_ = "Not enough waypoints!" 
    _sntprintf(errBuffer, errBufferLen, gettext(_T("[email protected]_")));
    return FALSE;
  }
  if(decl->num_waypoints > 12) {
    // LKTOKEN  [email protected]_ = "Too many waypoints!" 
    _sntprintf(errBuffer, errBufferLen, gettext(_T("[email protected]_")));
    return FALSE;
  }
  
  d->Com->StopRxThread();

  d->Com->SetRxTimeout(500);                     // set RX timeout to 500[ms]
  
  const unsigned BUFF_LEN = 128;
  TCHAR buffer[BUFF_LEN];

  // LKTOKEN  [email protected]_ = "Task declaration" 
  // LKTOKEN  [email protected]_ = "Testing connection" 
  _sntprintf(buffer, BUFF_LEN, _T("%s: %s..."), gettext(_T("[email protected]_")), gettext(_T("[email protected]_")));
  CreateProgressDialog(buffer);
  if (!EWMicroRecorderTryConnect(d)) {
    // LKTOKEN  [email protected]_ = "Device not connected!" 
    _sntprintf(errBuffer, errBufferLen, gettext(_T("[email protected]_")));
    return FALSE;
  }
  
  // LKTOKEN  [email protected]_ = "Task declaration" 
  // LKTOKEN  [email protected]_ = "Sending  declaration"
  _sntprintf(buffer, BUFF_LEN, _T("%s: %s..."), gettext(_T("[email protected]_")), gettext(_T("[email protected]_")));
  CreateProgressDialog(buffer);
  d->Com->WriteString(TEXT("\x18"));         // start to upload file
  d->Com->WriteString(user_data);

  TCHAR EWRecord[128];
  _stprintf(EWRecord, TEXT("Pilot Name:     %s\r\n"), decl->PilotName);
  d->Com->WriteString(EWRecord);
  _stprintf(EWRecord, TEXT("Competition ID: %s\r\n"), decl->CompetitionID);
  d->Com->WriteString(EWRecord);
  _stprintf(EWRecord, TEXT("Aircraft Type:  %s\r\n"), decl->AircraftType);
  d->Com->WriteString(EWRecord);
  _stprintf(EWRecord, TEXT("Aircraft ID:    %s\r\n"), decl->AircraftRego);
  d->Com->WriteString(EWRecord);

  d->Com->WriteString(TEXT("Description:      Declaration\r\n"));

  for (int i = 0; i < 11; i++) {
    wp = decl->waypoint[i];
    if (i == 0) {
      EWMicroRecorderWriteWayPoint(d, wp, TEXT("Take Off LatLong: "));
      EWMicroRecorderWriteWayPoint(d, wp, TEXT("Start LatLon:     "));
    } else if (i + 1 < decl->num_waypoints) {
      EWMicroRecorderWriteWayPoint(d, wp, TEXT("TP LatLon:        "));
    } else {
      d->Com->WriteString(TEXT("TP LatLon:        0000000N00000000E TURN POINT\r\n"));
    }
  }

  wp = decl->waypoint[decl->num_waypoints - 1];
  EWMicroRecorderWriteWayPoint(d, wp, TEXT("Finish LatLon:    "));
  EWMicroRecorderWriteWayPoint(d, wp, TEXT("Land LatLon:      "));
  
  d->Com->WriteString(TEXT("\x03"));         // finish sending user file

  if (!ExpectStringWait(d, TEXT("uploaded successfully"))) {
    // error!
    // LKTOKEN  [email protected]_ = "Declaration not accepted!" 
    _sntprintf(errBuffer, errBufferLen, gettext(_T("[email protected]_")));
    nDeclErrorCode = 1;
  }

  // LKTOKEN  [email protected]_ = "Task declaration" 
  // LKTOKEN  [email protected]_ = "Disabling declaration mode" 
  _sntprintf(buffer, BUFF_LEN, _T("%s: %s..."), gettext(_T("[email protected]_")), gettext(_T("[email protected]_")));
  CreateProgressDialog(buffer);
  d->Com->WriteString(TEXT("!!\r\n"));         // go back to NMEA mode

  d->Com->SetRxTimeout(RXTIMEOUT);                       // clear timeout
  d->Com->StartRxThread();                       // restart RX thread

  return(nDeclErrorCode == 0);                    // return() TRUE on success
}
Example #27
0
/*******************************************************************************************
 * 功能     :	打开串口
 * port     :	串口号, 如_T("COM1:")
 * baud_rate:	波特率
 * date_bits:	数据位(有效范围4~8)
 * stop_bit :	停止位
 * parity   :	奇偶校验。默认为无校验。NOPARITY 0; ODDPARITY 1;EVENPARITY 2;MARKPARITY 3;SPACEPARITY 4
 ********************************************************************************************/
BOOL CSerial::OpenSerialPort(TCHAR* port,UINT baud_rate,BYTE date_bits,BYTE stop_bit,BYTE parity){
	//打开串口
	m_hComm = CreateFile(port,GENERIC_READ|GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);//独占方式打开串口

	TCHAR err[512];

	if(m_hComm == INVALID_HANDLE_VALUE){
		_stprintf(err,_T("打开串口%s 失败,请查看该串口是否已被占用"),port);
		MessageBox(NULL,err,_T("提示"),MB_OK);
		return FALSE;
	}	

	//MessageBox(NULL,_T("打开成功"),_T("提示"),MB_OK);

	//获取串口默认配置
	DCB dcb;
	if(!GetCommState(m_hComm,&dcb)){
		MessageBox(NULL,_T("获取串口当前属性参数失败"),_T("提示"),MB_OK);
	}

	//配置串口参数
	dcb.BaudRate = baud_rate;	//波特率
	dcb.fBinary = TRUE;			//二进制模式。必须为TRUE
	dcb.ByteSize = date_bits;	//数据位。范围4-8
	dcb.StopBits = ONESTOPBIT;	//停止位

	if(parity == NOPARITY){
		dcb.fParity = FALSE;	//奇偶校验。无奇偶校验
		dcb.Parity = parity;	//校验模式。无奇偶校验
	}else{
		dcb.fParity = TRUE;		//奇偶校验。
		dcb.Parity = parity;	//校验模式。无奇偶校验
	}

	dcb.fOutxCtsFlow = FALSE;	//CTS线上的硬件握手
	dcb.fOutxDsrFlow = FALSE;	//DST线上的硬件握手
	dcb.fDtrControl = DTR_CONTROL_ENABLE; //DTR控制
	dcb.fDsrSensitivity = FALSE;
	dcb.fTXContinueOnXoff = FALSE;//
	dcb.fOutX = FALSE;			//是否使用XON/XOFF协议
	dcb.fInX = FALSE;			//是否使用XON/XOFF协议
	dcb.fErrorChar = FALSE;		//是否使用发送错误协议
	dcb.fNull = FALSE;			//停用null stripping
	dcb.fRtsControl = RTS_CONTROL_ENABLE;//
	dcb.fAbortOnError = FALSE;	//串口发送错误,并不终止串口读写

	//设置串口参数
	if (!SetCommState(m_hComm,&dcb)){
		MessageBox(NULL,_T("设置串口参数失败"),_T("提示"),MB_OK);
		return FALSE;
	}

	//设置串口事件
	SetCommMask(m_hComm,EV_RXCHAR); //在缓存中有字符时产生事件
	SetupComm(m_hComm,16384,16384);

	//设置串口读写时间
	COMMTIMEOUTS CommTimeOuts;
	GetCommTimeouts(m_hComm,&CommTimeOuts);
	CommTimeOuts.ReadIntervalTimeout = MAXDWORD;
	CommTimeOuts.ReadTotalTimeoutMultiplier = 0;
	CommTimeOuts.ReadTotalTimeoutConstant = 0;
	CommTimeOuts.WriteTotalTimeoutMultiplier = 10;
	CommTimeOuts.WriteTotalTimeoutConstant = 1000;

	if(!SetCommTimeouts(m_hComm,&CommTimeOuts)){
		MessageBox(NULL,_T("设置串口时间失败"),_T("提示"),MB_OK);
		return FALSE;
	}

	//创建线程,读取数据
	HANDLE hReadCommThread = (HANDLE) _beginthreadex(NULL,0,(PTHREAD_START) CommProc,(LPVOID) this,0,NULL);

	return TRUE;
}
Example #28
0
int caps_loadimage (struct zfile *zf, int drv, int *num_tracks)
{
    static int notified;
    struct CapsImageInfo ci;
    int len, ret;
    uae_u8 *buf;
    TCHAR s1[100];
    struct CapsDateTimeExt *cdt;
    int type;

    if (!caps_init ())
        return 0;
    caps_unloadimage (drv);
    zfile_fseek (zf, 0, SEEK_END);
    len = zfile_ftell (zf);
    zfile_fseek (zf, 0, SEEK_SET);
    if (len <= 0)
        return 0;
    buf = xmalloc (uae_u8, len);
    if (!buf)
        return 0;
    if (zfile_fread (buf, len, 1, zf) == 0)
        return 0;
    type = -1;
    if (pCAPSGetImageTypeMemory) {
        type = pCAPSGetImageTypeMemory(buf, len);
        if (type == citError || type == citUnknown) {
            write_log(_T("caps: CAPSGetImageTypeMemory() returned %d\n"), type);
            return 0;
        }
        if (type == citKFStream || type == citDraft) {
            write_log(_T("caps: CAPSGetImageTypeMemory() returned unsupported image type %d\n"), type);
            return 0;
        }
    }
    ret = pCAPSLockImageMemory (caps_cont[drv], buf, len, 0);
    xfree (buf);
    if (ret != imgeOk) {
        if (ret == imgeIncompatible || ret == imgeUnsupported) {
            if (!notified)
                notify_user (NUMSG_OLDCAPS);
            notified = 1;
        }
        write_log (_T("caps: CAPSLockImageMemory() returned %d\n"), ret);
        return 0;
    }
    caps_locked[drv] = 1;
    ret = pCAPSGetImageInfo(&ci, caps_cont[drv]);
    *num_tracks = (ci.maxcylinder - ci.mincylinder + 1) * (ci.maxhead - ci.minhead + 1);

    if (cvi.release < 4) { // pre-4.x bug workaround
        struct CapsTrackInfoT1 cit;
        cit.type = 1;
        if (pCAPSLockTrack ((PCAPSTRACKINFO)&cit, caps_cont[drv], 0, 0, caps_flags) == imgeIncompatible) {
            if (!notified)
                notify_user (NUMSG_OLDCAPS);
            notified = 1;
            caps_unloadimage (drv);
            return 0;
        }
        pCAPSUnlockAllTracks (caps_cont[drv]);
    }

    ret = pCAPSLoadImage(caps_cont[drv], caps_flags);
    caps_revolution_hack[drv] = type == citCTRaw;
    cdt = &ci.crdt;
    _stprintf (s1, _T("%d.%d.%d %d:%d:%d"), cdt->day, cdt->month, cdt->year, cdt->hour, cdt->min, cdt->sec);
    write_log (_T("caps: type:%d imagetype:%d date:%s rel:%d rev:%d\n"), ci.type, type, s1, ci.release, ci.revision);
    return 1;
}