Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > VB6 > Сохранение цвета в базу данных


Автор: Nephrit 3.9.2007, 17:35
Вопрос звучит следующим образом.
У меня есть кнопка. Так же есть CommonDialog ,которому я присвоил - Color.
Теперь при нажатии на кнопку у меня появляется диалог с выбором любого цвета. 
Потом я выбираю нужный мне цвет и кнопка окрашивается в него.

И теперь я хочу, что бы этот цвет сохранился в базе данных.
Что бы при следующей загрузке кнопка принимала нужный мне цвет.
Кто нибудь, что либо знает как это сделать.

Предположение:
Нужен код который будет вытягивать из цвета его значения в RGB или ещё как-то, что бы их можно было сохранять.

Автор: Akina 3.9.2007, 18:45
Цитата

Using the RGB function or the intrinsic constants to define color are indirect methods. They are indirect because Visual Basic interprets them into the single approach it uses to represent color. If you understand how colors are represented in Visual Basic, you can assign numbers to color properties and arguments that specify color directly. In most cases, it’s much easier to enter these numbers in hexadecimal.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF&). Each color setting (property or argument) is a 4-byte integer. The high byte of a number in this range equals 0. The lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF).

Consequently, you can specify a color as a hexadecimal number using this syntax:

&HBBGGRR&

The BB specifies the amount of blue, GG the amount of green, and RR the amount of red. Each of these fragments is a two-digit hexadecimal number from 00 to FF. The median value is 80. Thus, the following number specifies gray, which has the median amount of all three colors:

&H808080&

Setting the most significant bit to 1 changes the meaning of the color value: It no longer represents an RGB color, but an environment-wide color specified through the Windows Control Panel. The values that correspond to these system-wide colors range from &H80000000 to &H80000015.

Note   Although you can specify over 16 million different colors, not all systems are capable of displaying them accurately. For more information on how Windows represents colors, see "Working with 256 Colors" later in this chapter.
Так что это обычный long
Цитата

RGB Function

Returns a Long whole number representing an RGB color value.

Syntax
RGB(red, green, blue)


Автор: bom 3.9.2007, 23:41
Цитата(Nephrit @  3.9.2007,  20:35 Найти цитируемый пост)
Потом я выбираю нужный мне цвет и кнопка окрашивается в него

Свойству кнопки BackColor можешь присвоить значение цвета, а сохранить это же значение - не можешь. Как это понимать?


Автор: kapbepucm 4.9.2007, 11:07
Может лучше в фаил? А то для одного значения Long делать базу данных... Хотя надо видеть ситуацию (может я ошибаюсь).

Автор: Akina 4.9.2007, 11:11
Цитата(kapbepucm @  4.9.2007,  12:07 Найти цитируемый пост)
Может лучше в фаил? А то одно значение Long хранить в базе данных... 

ДЛя этих целей заводится служебная таблица, хранящая параметры. А то и группы параметров - эдакий аналог файлов настроек. Это разумнее отдельного файла - не надо заморачиваться на контроль валидности, парсинг и пр., плюс одна технология работы.

Автор: Nephrit 4.9.2007, 19:09
Наверное меня не так поняли.
Я имел ввиду, вот что. К примеру я применяю к шрифту Тексбокса нужный мне цвет. Я хочу что бы он сохранился в базе данных.
Что бы когда я обратился к базе данных с помощью поиска текст который вновь отобразится в окошке был того цвета, который я ему задал при сохранении.
Такое возможно?

Автор: Akina 4.9.2007, 19:44
Nephrit, Замени TextBox на RichTextBox и забудь о проблеме.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)