PDA

View Full Version : آموزش: ذخیره و بازیابی Color Dialog CustomColors



ROSTAM2
دوشنبه 01 مهر 1392, 09:55 صبح
تعیرف یک ثابت با مقدار یک آدرس در رجیستری:

Public Const CustomColorKey As String = "Software\CustomColors"


پراپرتی برای مدیریت کلید رجیستری

Private CustomColorsRegValue As RegistryKey
Public ReadOnly Property CustomColorsReg() As RegistryKey
Get
CustomColorsRegValue = Registry.CurrentUser.OpenSubKey(CustomColorKey, True)
Return CustomColorsRegValue
End Get
End Property


دستور ColorDialog در یک رویداد:


Dim CDlg As New ColorDialog, x%, CustomColors%(15)
With CDlg
.AnyColor = True
.Color = Panel1.BackColor
x = 0
With CustomColorsReg
For Each C$ In .GetValueNames
If C.Length = 0 Then GoTo XX
CustomColors(x) = CInt(.GetValue(C))
x += 1
XX:
Next
End With

.CustomColors = CustomColors
If .ShowDialog(Me) = Windows.Forms.DialogResult.Cancel Then Exit Sub
Panel1.BackColor = .Color
x = 0
For Each C% In .CustomColors
CustomColorsReg.SetValue("Color " + x.ToString, C.ToString)
x += 1
Next
End With