if (NS_NewImageManager(&gImageManager) != NS_OK || gImageManager->Init() != NS_OK) { ::MessageBox(NULL, "Can't initialize the image library", class1Name, MB_OK); } gImageManager->SetCacheSize(1024*1024);
{ nsresult result; gImageManager = do_GetService(kImageManagerCID, &result); if ((NS_FAILED(result)) || gImageManager->Init() != NS_OK) { ::MessageBox(NULL, "Can't initialize the image library",class1Name, MB_OK); } else gImageManager->SetCacheSize(1024*1024); }
WndProc(HWND hWnd, UINT msg, WPARAM param, LPARAM lparam){  HMENU hMenu;  switch (msg) {    case WM_COMMAND:      hMenu = GetMenu(hWnd);      switch (LOWORD(param)) {        case TIMER_OPEN:         {            char szFile[256];            if (!OpenFileDialog(szFile, 256))                return 0L;            MyLoadImage(szFile);            break;        }        case TIMER_EXIT:            ::DestroyWindow(hWnd);            exit(0);        default:            break;      }      break;    case WM_CREATE:      // Initialize image library      if (NS_NewImageManager(&gImageManager) != NS_OK ||          gImageManager->Init() != NS_OK) {            ::MessageBox(NULL, "Can't initialize the image library",                         class1Name, MB_OK);      }	        gImageManager->SetCacheSize(1024*1024);      break;    case WM_DESTROY:      MyInterrupt();      MyReleaseImages();      if (gImageGroup != nsnull) {          NS_RELEASE(gImageGroup);      }      if (gImageManager != nsnull) {          NS_RELEASE(gImageManager);      }      PostQuitMessage(0);      break;    default:      break;  }  return DefWindowProc(hWnd, msg, param, lparam);}