summaryrefslogtreecommitdiff
path: root/src/msvc6/testrunner/ResourceLoaders.cpp
blob: 17f48951ec944ab99422ffbc4580dd8fa1b82b0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "stdafx.h"

#include "ResourceLoaders.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif



extern HINSTANCE g_testRunnerResource;

CString loadCString(UINT stringId)
{
  CString string;
  
  HRSRC stringRes = ::FindResource( g_testRunnerResource, 
                                   MAKEINTRESOURCE( (stringId>>4) + 1),
                                   RT_STRING );
  if ( stringRes )
  {
    int stringLen = ::SizeofResource( g_testRunnerResource, 
                                      stringRes) / sizeof(TCHAR);
    if (stringLen > 0)
    {
      LPTSTR stringBuffer = string.GetBuffer( stringLen+2 );
      int realStringLen = ::LoadString( g_testRunnerResource, 
                                        stringId, 
                                        stringBuffer, 
                                        (stringLen+1)*2 );
      string.ReleaseBuffer( realStringLen );

      ASSERT(realStringLen > 0);
    }
  }

  ASSERT( !string.IsEmpty() );
  return string;
}