ShowWindowLevelDlg example for C++ Builder

void __fastcall TForm1::ShowWindowLevelDlg1Click(TObject *Sender)
{
   unsigned i; 

   LEADImage1->GrayScale ( 12 ); /*make image 12-bit grayscale*/
   LEADImage1->ForceRepaint ( ); 

   LEADDlgColor1->WindowLevelStartColor = clRed; 
   LEADDlgColor1->WindowLevelEndColor = clBlue; 
   LEADDlgColor1->LEADImage = LEADImage1; /*assign the main control for processing*/
   LEADDlgColor1->DlgFlags = DLG_WINDOWLEVEL_SHOW_PREVIEW +
                            DLG_WINDOWLEVEL_SHOW_TOOL_ZOOMLEVEL +
                            DLG_WINDOWLEVEL_SHOW_RANGE; 
   LEADImage1->GetMinMaxBits();
   LEADImage1->GetMinMaxVal();

   LEADDlgColor1->WindowLevelLowBit = LEADImage1->MinBit; 
   LEADDlgColor1->WindowLevelHighBit = LEADImage1->MaxBit; 
   LEADDlgColor1->WindowLevelLow = LEADImage1->MinVal; 
   LEADDlgColor1->WindowLevelHigh = LEADImage1->MaxVal; 
   LEADDlgColor1->WindowLevelFactor = 10; 
   LEADDlgColor1->WindowLevelFlags = FILLLUT_INSIDE + FILLLUT_LOGARITHMIC; 

   int nRet= LEADDlgColor1->ShowWindowLevelDlg ( this ); 
   if ( nRet == SUCCESS_DLG_OK ) 
   {
      LEADImage1->WindowLevelBitmap= false; 
      LEADImage1->LevelLowBit= LEADDlgColor1->WindowLevelLowBit
      LEADImage1->LevelHighBit= LEADDlgColor1->WindowLevelHighBit
      for ( i= 0; i < LEADDlgColor1->WindowLevelLUTLength; i ++ ) 
      {
         LEADImage1->LevelLUT[i]= (TColor)LEADDlgColor1->WindowLevelLUT [i]; 
      }
      LEADImage1->WindowLevel ( ); 
   }
}