' Снимок

Sub Obj.Snap(param As Integer)
	Select Case param
		Case 1000,1003
			bmp=CreateCopyImageDesktop()
		Case 1001,1004
			bmp=CreateCopyImageWindow(GetForegroundWindow)
		Case 1002,1005
			If SaveLoad.Hide=1 Then
				SaveLoad.Hide=0
				HideWindow(SelectHwnd,0)
				Exit Sub
			Else
				GetWindowRect(SelectHwnd,@SaveLoad.Trect)
				Tbmp=CreateCopyImageDesktop()
				bmp=Grab_Image(Tbmp,SaveLoad.Trect.left+7,SaveLoad.Trect.top+21,WindowClientWidth(a.SelectHwnd)-15,WindowClientHeight(a.SelectHwnd)-30)
				Free_Image(Tbmp)
			EndIf
	End Select

	If param<>1003 And param<>1004 And param<>1005 Then
		If SaveLoad.real=0 Then
			bmp=Resize_image(bmp,SaveLoad.Width,SaveLoad.height)
		EndIf
		If SaveLoad.Format<>".ico" Then
			If SaveLoad.rewrite Then
				SAVE_image(bmp,SaveLoad.path & "\newSnap" & SaveLoad.Format)
			Else
				SAVE_image(bmp,SaveLoad.path & "\" & replacestring(Date,"-","",,1) & replacestring(Time,":","",,1) & SaveLoad.Format)
			EndIf
		Else
			SaveLoad.ico=CreateIconOrCursorFromBitmap(bmp)
			If SaveLoad.rewrite Then
				SaveIconOrCursor(SaveLoad.ico,SaveLoad.path & "\newSnap.ico")
			Else
				SaveIconOrCursor(SaveLoad.ico,	SaveLoad.path & "\" & replacestring(Date,"-","",,1) & replacestring(Time,":","",,1) & ".ico")
			EndIf
			deleteobject(SaveLoad.ico)
		EndIf
	Else		
		SaveLoad.temppath=SaveFileRequester("","C:\",_
		"Файлы BMP (*.bmp)" + Chr(0) + "*.bmp" + Chr(0)+_
		"Файлы PNG (*.png)" + Chr(0) + "*.png" + Chr(0)+_
		"Файлы JPG (*.jpg)" + Chr(0) + "*.jpg" + Chr(0)+_
		"Файлы JPEG (*.jpeg)" + Chr(0) + "*.jpeg" + Chr(0)+_
		"Файлы TIFF (*.tiff)" + Chr(0) + "*.tiff" + Chr(0)+_
		"Файлы ICO (*.ico)" + Chr(0) + "*.ico" + Chr(0)+_
		"Файлы GIF (*.gif)" + Chr(0) + "*.gif" + Chr(0),1)
		ResizeSnap()
		If LCase(Right(SaveLoad.temppath,3))="ico" Then
			SaveLoad.ico=CreateIconOrCursorFromBitmap(bmp)
			SaveIconOrCursor(SaveLoad.ico,SaveLoad.temppath)
			deleteobject(SaveLoad.ico)
		Else
			SAVE_image(bmp,SaveLoad.temppath)
		EndIf
	EndIf
	Free_Image(bmp)
End Sub