ShowWindowLevelDlg Example for Visual Basic

 
Private Sub WindowLevel_Click()
	Dim RasterColorDlg As New LEADRasterDlgClr_U
	Dim RasterKrnDlg As New LEADRasterDlgKrn_U

	RasterKrnDlg.InitDlg 0
	RasterColorDlg.LowBit = LEAD1.MinBit
	RasterColorDlg.HighBit = LEAD1.MaxBit
	RasterColorDlg.WindowLevelLow = LEAD1.MinVal
	RasterColorDlg.WindowLevelHigh = LEAD1.MaxVal

	Select Case LEAD1.IsGrayscale
	Case GRAY_ORDEREDNORMAL
		 RasterColorDlg.StartColor = RGB(0, 0, 0)
		 RasterColorDlg.EndColor = RGB(255, 255, 255)
	Case GRAY_ORDEREDINVERSE
		 RasterColorDlg.StartColor = RGB(255, 255, 255)
		 RasterColorDlg.EndColor = RGB(0, 0, 0)
	Case GRAY_NOTORDERED
		 RasterColorDlg.StartColor = RGB(0, 0, 0)
		 RasterColorDlg.EndColor = RGB(255, 255, 255)
	Case Else
	  MsgBox "Window Level is not supported for this bitmap order"
	  Exit Sub
	End Select

	RasterColorDlg.Bitmap = LEAD1.Bitmap
	RasterColorDlg.WindowLevelFlags = FILL_LUT_OUTSIDE Or FILL_LUT_LINEAR
	RasterColorDlg.UIFlags = WINDOWLEVEL_SHOW_PREVIEW Or _
							  WINDOWLEVEL_SHOW_TOOL_ZOOMLEVEL Or _
							  WINDOWLEVEL_SHOW_RANGE Or _
							  WINDOWLEVEL_AUTOPROCESS

	RasterColorDlg.ShowWindowLevelDlg hWnd
	RasterKrnDlg.FreeDlg
End Sub