Here's three sliders controlling the dialog color.
Code: Select all
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////START PROG PARAMS///////////////////////////////
//Save settings file name
Let>SettingsFile=%temp_dir%~LastColorSliderSettings.txt
//Programmer Configurable parameters ...1
//Slider upper left X,Y position in Dialog
Let>SliderXstart...1=100
Let>SliderYstart...1=100
//Slider size
//"SliderTall" is actually the slider range in pixels
Let>SliderWide...1=40
Let>SliderTall...1=255
//Dialog button size, needs to be spec'ed here to calculate max/min locations
Let>ButtonWide...1=30
Let>ButtonTall...1=6
//Slider Thickness
Let>SliderThick...1=2
//Programmer Configurable parameters ...2
//Slider upper left X,Y position in Dialog
Let>SliderXstart...2=200
Let>SliderYstart...2=100
//Slider size
//"SliderTall" is actually the slider range in pixels
Let>SliderWide...2=40
Let>SliderTall...2=255
//Dialog button size, needs to be spec'ed here to calculate max/min locations
Let>ButtonWide...2=30
Let>ButtonTall...2=6
//Slider Thickness
Let>SliderThick...2=2
//Programmer Configurable parameters ...3
//Slider upper left X,Y position in Dialog
Let>SliderXstart...3=300
Let>SliderYstart...3=100
//Slider size
//"SliderTall" is actually the slider range in pixels
Let>SliderWide...3=40
Let>SliderTall...3=255
//Dialog button size, needs to be spec'ed here to calculate max/min locations
Let>ButtonWide...3=30
Let>ButtonTall...3=6
//Slider Thickness
Let>SliderThick...3=2
Let>Dialog_Window_Name=Slider Sample
//////////////////////////////END PROG PARAMS////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////DO NOT ALTER///////////////////////////////////
//Calculated parameters ...1
Let>Initial_Location...1={round(%SliderTall...1%/2)}
Let>SliderTall...1=%SliderTall...1%+ButtonTall...1
Let>SliderYcenter...1={round(%SliderYstart...1%+(%SliderTall...1%/2))}
Let>ButtonX...1={%SliderXstart...1%-(round(%ButtonWide...1%/2))}
Let>ButtonY...1={round(%SliderYcenter...1%-(%ButtonTall...1%/2))}
Let>SliderXnegComp...1={%SliderXstart...1%-(round(%SliderWide...1%/2))}
Let>SliderYposComp...1=%SliderYstart...1%+%SliderTall...1%
Let>ButtonXW...1=%ButtonX...1%+%SliderWide...1%
Let>ButtonYH...1=%SliderYposComp...1%-%ButtonTall...1%
Let>penlocation...1={round(%ButtonTall...1%/2)}
//Calculated parameters ...2
Let>Initial_Location...2={round(%SliderTall...2%/2)}
Let>SliderTall...2=%SliderTall...2%+ButtonTall...2
Let>SliderYcenter...2={round(%SliderYstart...2%+(%SliderTall...2%/2))}
Let>ButtonX...2={%SliderXstart...2%-(round(%ButtonWide...2%/2))}
Let>ButtonY...2={round(%SliderYcenter...2%-(%ButtonTall...2%/2))}
Let>SliderXnegComp...2={%SliderXstart...2%-(round(%SliderWide...2%/2))}
Let>SliderYposComp...2=%SliderYstart...2%+%SliderTall...2%
Let>ButtonXW...2=%ButtonX...2%+%SliderWide...2%
Let>ButtonYH...2=%SliderYposComp...2%-%ButtonTall...2%
Let>penlocation...2={round(%ButtonTall...2%/2)}
//Calculated parameters ...3
Let>Initial_Location...3={round(%SliderTall...3%/2)}
Let>SliderTall...3=%SliderTall...3%+ButtonTall...3
Let>SliderYcenter...3={round(%SliderYstart...3%+(%SliderTall...3%/2))}
Let>ButtonX...3={%SliderXstart...3%-(round(%ButtonWide...3%/2))}
Let>ButtonY...3={round(%SliderYcenter...3%-(%ButtonTall...3%/2))}
Let>SliderXnegComp...3={%SliderXstart...3%-(round(%SliderWide...3%/2))}
Let>SliderYposComp...3=%SliderYstart...3%+%SliderTall...3%
Let>ButtonXW...3=%ButtonX...3%+%SliderWide...3%
Let>ButtonYH...3=%SliderYposComp...3%-%ButtonTall...3%
Let>penlocation...3={round(%ButtonTall...3%/2)}
//Acquire prior settings if they exist
IfFileExists>%SettingsFile%
ReadIniFile>%SettingsFile%,Settings,Location1,Initial_Location...1
ReadIniFile>%SettingsFile%,Settings,Location2,Initial_Location...2
ReadIniFile>%SettingsFile%,Settings,Location3,Initial_Location...3
Let>ButtonY...1=%Initial_Location...1%+%SliderYstart...1%
Let>ButtonY...2=%Initial_Location...2%+%SliderYstart...2%
Let>ButtonY...3=%Initial_Location...3%+%SliderYstart...3%
Else
WriteLn>%SettingsFile%,wres,[Settings]
WriteLn>%SettingsFile%,wres,Location1=%Initial_Location...1%
WriteLn>%SettingsFile%,wres,Location2=%Initial_Location...2%
WriteLn>%SettingsFile%,wres,Location3=%Initial_Location...3%
EndIf
//One time only acquire title bar size
Dialog>TitleBarSizeCalculation
Button=1,0,0,75,25,0
EndDialog>TitleBarSizeCalculation
Let>WIN_USEHANDLE=1
GetWindowPos>TitleBarSizeCalculation.msButton1.handle,OffSetX,OffSetY
Let>WIN_USEHANDLE=0
RGB>%Initial_Location...1%,%Initial_Location...2%,%Initial_Location...3%,color
//////////////////////////////DO NOT ALTER///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//Sample dialog configurable to taste except for the sliders section
//Make sure the dialog is big enough to accomodate the slider
Dialog>Dialog1
Caption=%Dialog_Window_Name%
Width=550
Height=450
Top=100
Left=20
Label=%Initial_Location...1%,80,50,True
Label=%Initial_Location...2%,180,50,True
Label=%Initial_Location...3%,280,50,True
Label=%color%,380,50,True
/////// PLACE NO BUTTONS OR PROGRESS BARS ABOVE THIS LINE //////
/////////////////////////////////////////////////////////////////////////////
///////////SLIDER OBJECT DO NOT ALTER. SET PARAMS AT TOP OF SCRIPT///////////
//Vertical line for slider "object" construction
ProgressBar=msProgressBar1,%SliderXstart...1%,%SliderYstart...1%,%SliderThick...1%,%SliderTall...1%,0
//Top horizontal line for slider "object" construction
ProgressBar=msProgressBar2,%SliderXnegComp...1%,%SliderYstart...1%,%SliderWide...1%,%SliderThick...1%,0
//Center horizontal line for slider "object" construction
//ProgressBar=msProgressBar3,%SliderXnegComp...1%,%SliderYcenter...1%,%SliderWide...1%,%SliderThick...1%,0
//Bottom horizontal line for slider "object" construction
ProgressBar=msProgressBar4,%SliderXnegComp...1%,%SliderYposComp...1%,%SliderWide...1%,%SliderThick...1%,0
//Button used for slider
Button=.,%ButtonX...1%,%ButtonY...1%,%ButtonWide...1%,%ButtonTall...1%,0
////////////////////END SLIDER OBJECT DO NOT ALTER///////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///////////SLIDER OBJECT DO NOT ALTER. SET PARAMS AT TOP OF SCRIPT///////////
//Vertical line for slider "object" constructio
ProgressBar=msProgressBar5,%SliderXstart...2%,%SliderYstart...2%,%SliderThick...2%,%SliderTall...2%,0
//Top horizontal line for slider "object" construction
ProgressBar=msProgressBar6,%SliderXnegComp...2%,%SliderYstart...2%,%SliderWide...2%,%SliderThick...2%,0
//Center horizontal line for slider "object" construction
//ProgressBar=msProgressBar7,%SliderXnegComp...2%,%SliderYcenter...2%,%SliderWide...2%,%SliderThick...2%,0
//Bottom horizontal line for slider "object" construction
ProgressBar=msProgressBar8,%SliderXnegComp...2%,%SliderYposComp...2%,%SliderWide...2%,%SliderThick...2%,0
//Button used for slider
Button=.,%ButtonX...2%,%ButtonY...2%,%ButtonWide...2%,%ButtonTall...2%,0
////////////////////END SLIDER OBJECT DO NOT ALTER///////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///////////SLIDER OBJECT DO NOT ALTER. SET PARAMS AT TOP OF SCRIPT///////////
//Vertical line for slider "object" construction
ProgressBar=msProgressBar9,%SliderXstart...3%,%SliderYstart...3%,%SliderThick...3%,%SliderTall...3%,0
//Top horizontal line for slider "object" construction
ProgressBar=msProgressBar10,%SliderXnegComp...3%,%SliderYstart...3%,%SliderWide...3%,%SliderThick...3%,0
//Center horizontal line for slider "object" construction
//ProgressBar=msProgressBar11,%SliderXnegComp...3%,%SliderYcenter...3%,%SliderWide...3%,%SliderThick...3%,0
//Bottom horizontal line for slider "object" construction
ProgressBar=msProgressBar12,%SliderXnegComp...3%,%SliderYposComp...3%,%SliderWide...3%,%SliderThick...3%,0
//Button used for slider
Button=.,%ButtonX...3%,%ButtonY...3%,%ButtonWide...3%,%ButtonTall...3%,0
////////////////////END SLIDER OBJECT DO NOT ALTER///////////////////////////
/////////////////////////////////////////////////////////////////////////////
Button=Save To%CRLF%Clipboard,385,140,100,35,100
Label=Red,90,35,True
Label=Green,186,35,True
Label=Blue,290,35,True
EndDialog>Dialog1
Show>dialog1
OnEvent>DIALOG_EVENT,Dialog1,100,Save
OnEvent>WINDOW_NOTOPEN,%Dialog_Window_Name%,2,Exit
OnEvent>KEY_DOWN,VK1,0,SliderMove
Let>VertSliderMoveFlag...1=0
Let>StopMoving...1=0
Let>VertSliderMoveFlag...2=0
Let>StopMoving...2=0
Let>VertSliderMoveFlag...3=0
Let>StopMoving...3=0
SetDialogObjectColor>Dialog1,,color
Label>Loop
If>VertSliderMoveFlag...1>0
Add>VertSliderMoveFlag...1,1
If>VertSliderMoveFlag...1>5
Let>VertSliderMoveFlag...1=0
Let>StopMoving...1=0
EndIf
EndIf
If>VertSliderMoveFlag...2>0
Add>VertSliderMoveFlag...2,1
If>VertSliderMoveFlag...2>5
Let>VertSliderMoveFlag...2=0
Let>StopMoving...2=0
EndIf
EndIf
If>VertSliderMoveFlag...3>0
Add>VertSliderMoveFlag...3,1
If>VertSliderMoveFlag...3>5
Let>VertSliderMoveFlag...3=0
Let>StopMoving...3=0
EndIf
EndIf
GoSub>Contrast
Wait>0.01
Goto>Loop
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////SUBROUTINES////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////DO NOT ALTER///////////////////////////////////
SRT>SliderMove
GetCursorPos>CurX,CurY
GetWindowPos>%Dialog_Window_Name%,WinX,WinY
Add>WinY,%OffsetY%
Sub>CurX,%WinX%
Sub>CurY,%WinY%
Sub>cury,%penlocation...1%
If>{(%VertSliderMoveFlag...1%>0)or((%CurX%>%ButtonX...1%)and(%CurX%<%ButtonXW...1%)and(%CurY%>%SliderYstart...1%)and(%CurY%<%ButtonYH...1%))}
GoSub>SliderMove...1
EndIf
If>{(%VertSliderMoveFlag...2%>0)or((%CurX%>%ButtonX...2%)and(%CurX%<%ButtonXW...2%)and(%CurY%>%SliderYstart...2%)and(%CurY%<%ButtonYH...2%))}
GoSub>SliderMove...2
EndIf
If>{(%VertSliderMoveFlag...3%>0)or((%CurX%>%ButtonX...3%)and(%CurX%<%ButtonXW...3%)and(%CurY%>%SliderYstart...3%)and(%CurY%<%ButtonYH...3%))}
GoSub>SliderMove...3
EndIf
RGB>%Dialog1.msLabel1%,%Dialog1.msLabel2%,%Dialog1.msLabel3%,color
SetDialogObjectColor>Dialog1,,color
END>SliderMove
//This subroutine controls the slider movement
//Don't make any changes unless you have a backup
SRT>SliderMove...1
Let>VertSliderMoveFlag...1=1
If>%CurY%<%SliderYstart...1%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton1.handle%,%ButtonX...1%,%SliderYstart...1%
Let>WIN_USEHANDLE=0
Let>StopMoving...1=1
EndIf
If>%CurY%>%ButtonYH...1%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton1.handle%,%ButtonX...1%,%ButtonYH...1%
Let>WIN_USEHANDLE=0
Let>StopMoving...1=1
EndIf
If>StopMoving...1=0
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton1.handle%,%ButtonX...1%,%CurY%
Let>WIN_USEHANDLE=0
Else
Let>StopMoving...1=0
EndIf
Let>WIN_USEHANDLE=1
GetWindowPos>%dialog1.msbutton1.handle%,SomeX,ButtonY...1
Let>WIN_USEHANDLE=0
//The next line is the usable output of the slider
//In this case the output is being set to the variable "Dialog1.msLabel1"
Let>Dialog1.msLabel1={%ButtonY...1%-%SliderYstart...1%-%WinY%}
RGB>%Dialog1.msLabel1%,%Dialog1.msLabel2%,%Dialog1.msLabel3%,color
Let>Dialog1.msLabel4=%color%
SetDialogObjectColor>Dialog1,,color
ResetDialogAction>Dialog1
END>SliderMove...1
/////////////////////////////////////////////////////////////////////////////
//////////////////////////////DO NOT ALTER///////////////////////////////////
//This subroutine controls the slider movement
//Don't make any changes unless you have a backup
SRT>SliderMove...2
Let>VertSliderMoveFlag...2=1
If>%CurY%<%SliderYstart...2%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton2.handle%,%ButtonX...2%,%SliderYstart...2%
Let>WIN_USEHANDLE=0
Let>StopMoving...2=1
EndIf
If>%CurY%>%ButtonYH...2%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton2.handle%,%ButtonX...2%,%ButtonYH...2%
Let>WIN_USEHANDLE=0
Let>StopMoving...2=1
EndIf
If>StopMoving...2=0
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton2.handle%,%ButtonX...2%,%CurY%
Let>WIN_USEHANDLE=0
Else
Let>StopMoving...2=0
EndIf
Let>WIN_USEHANDLE=1
GetWindowPos>%dialog1.msbutton2.handle%,SomeX,ButtonY...2
Let>WIN_USEHANDLE=0
//The next line is the usable output of the slider
//In this case the output is being set to the variable "Dialog1.msLabel1"
Let>Dialog1.msLabel2={%ButtonY...2%-%SliderYstart...2%-%WinY%}
RGB>%Dialog1.msLabel1%,%Dialog1.msLabel2%,%Dialog1.msLabel3%,color
SetDialogObjectColor>Dialog1,,color
Let>Dialog1.msLabel4=%color%
ResetDialogAction>Dialog1
END>SliderMove...2
//This subroutine controls the slider movement
//Don't make any changes unless you have a backup
SRT>SliderMove...3
Let>VertSliderMoveFlag...3=1
If>%CurY%<%SliderYstart...3%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton3.handle%,%ButtonX...3%,%SliderYstart...3%
Let>WIN_USEHANDLE=0
Let>StopMoving...3=1
EndIf
If>%CurY%>%ButtonYH...3%
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton3.handle%,%ButtonX...3%,%ButtonYH...3%
Let>WIN_USEHANDLE=0
Let>StopMoving...3=1
EndIf
If>StopMoving...3=0
Let>WIN_USEHANDLE=1
MoveWindow>%dialog1.msbutton3.handle%,%ButtonX...3%,%CurY%
Let>WIN_USEHANDLE=0
Else
Let>StopMoving...3=0
EndIf
EndIf
Let>WIN_USEHANDLE=1
GetWindowPos>%dialog1.msbutton3.handle%,SomeX,ButtonY...3
Let>WIN_USEHANDLE=0
//The next line is the usable output of the slider
//In this case the output is being set to the variable "Dialog1.msLabel1"
Let>Dialog1.msLabel3={%ButtonY...3%-%SliderYstart...3%-%WinY%}
RGB>%Dialog1.msLabel1%,%Dialog1.msLabel2%,%Dialog1.msLabel3%,color
SetDialogObjectColor>Dialog1,,color
Let>Dialog1.msLabel4=%color%
ResetDialogAction>Dialog1
END>SliderMove...3
SRT>Exit
EditIniFile>%SettingsFile%,Settings,Location1,Dialog1.msLabel1
EditIniFile>%SettingsFile%,Settings,Location2,Dialog1.msLabel2
EditIniFile>%SettingsFile%,Settings,Location3,Dialog1.msLabel3
Exit>0
END>Exit
SRT>Save
RGB>%Dialog1.msLabel1%,%Dialog1.msLabel2%,%Dialog1.msLabel3%,color
PutClipBoard>Color
Let>Dialog1.msLabel4=%color%%CRLF% Saved to%CRLF% Clipboard
ResetDialogAction>Dialog1
END>Save
SRT>Contrast
//Set slider button and label text color to be different from the background
Let>TextRed=%Dialog1.msLabel1%+130
Let>TextGrn=%Dialog1.msLabel2%+130
Let>TextBlu=%Dialog1.msLabel3%+130
RGB>TextRed,TextGrn,TextBlu,TextColor
GoSub>DrawLine,%dialog1.msbutton1.handle%,ButtonTall...1,TextColor,0,penlocation...1,ButtonWide...1,penlocation...1
GoSub>DrawLine,%dialog1.msbutton2.handle%,ButtonTall...2,TextColor,0,penlocation...2,ButtonWide...2,penlocation...2
GoSub>DrawLine,%dialog1.msbutton3.handle%,ButtonTall...3,TextColor,0,penlocation...3,ButtonWide...3,penlocation...3
SetDialogObjectFont>Dialog1,msLabel1,Arial,18,0,TextColor
SetDialogObjectFont>Dialog1,msLabel2,Arial,18,0,TextColor
SetDialogObjectFont>Dialog1,msLabel3,Arial,18,0,TextColor
SetDialogObjectFont>Dialog1,msLabel4,Arial,18,0,TextColor
SetDialogObjectFont>Dialog1,msLabel5,Arial,9,1,TextColor
SetDialogObjectFont>Dialog1,msLabel6,Arial,9,1,TextColor
SetDialogObjectFont>Dialog1,msLabel7,Arial,9,1,TextColor
END>Contrast
//DrawLine Usage:
//GoSub>DrawLine,WindowHandle,PenSize,PenColor,XStart,YStart,XEnd,YEnd
SRT>DrawLine
LibFunc>user32,GetDC,HDC,%DrawLine_var_1%
LibFunc>gdi32,CreatePen,Penres,0,%DrawLine_var_2%,%DrawLine_var_3%
LibFunc>gdi32,SelectObject,SOPres,hdc,Penres
Libfunc>gdi32,MoveToEx,mtres,HDC,%DrawLine_var_4%,%DrawLine_var_5%,0
LibFunc>gdi32,LineTo,ltres,hdc,%DrawLine_var_6%,%DrawLine_var_7%
LibFunc>gdi32,DeleteObject,DOres,Penres
LibFunc>user32,ReleaseDC,RDCres,HDC_1,HDC
END>DrawLine
//////////////////////////////DO NOT ALTER///////////////////////////////////
/////////////////////////////////////////////////////////////////////////////