На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
[!] Как относитесь к модерированию на этом форуме? Выскажите свое мнение здесь
  
> Картинка для компонента
    Немогу сообразить, как сделать свою картинку для своего компонента?
      Графический редактор?
        Нет, картинку-то я могу сделать, только как сделать, чтобы эта картинка (моя картинка)
        отображалась на понеле компонентов, т.е. сейчас отображается картинка от унаследованного
        класса, а как ее заменить?
          Ох и намучеешся ты...
          Картинку лучше встввлять заранее

          Перво-наперво ее надо нарисовать.
          Для этого открой Image Editor (Входит в состав Builderа).
          Создай файл ресурса. File|New|Component Resurce File (.dcr)
          затем Recurce|New|Bitmap
          размер должен быть 24x24. Другой не сработает.

          Имя рисунка Должно Совпадать С Именем КОМПОНЕНТА. (например (TSuperPuperEdit)
          А имя .dcr файла - с именем файла модуля (SuperPuperEdit.dcr). И лежать должен в том же каталоге.

          Затем подключвешь .dcr к проекту компонента. и нажимаешь Build.
          Если файл ресурса уже есть (а он есть обязательно в уже созданном компоненте, как у тебя) то нужно его заменить новым.

          Готов поспорить, не получится. В свое время у меня получилось раза с четвертого.
          А еще, купи себе хорошую дорогую и толстую книжку. Там это все есть.
          Желаю удачи.
            2 lsv-X

            RTFM "C++Builder 6 Developer's Guide"
            Цитата

            Creating a bitmap for a component

            When you create a new component, you can define your own bitmaps for custom components.

            1 Choose Tools|Image Editor.

            2 In the Image Editor dialog box, choose File|New|Component Resource File (.dcr).

            3 In the untitled1.dcr dialog box, right-click Contents. Choose New|Bitmap.

            4 In the Bitmaps Properties dialog box, change both the Width and Height to 24 pixels. Make sure VGA (16 colors) is checked. Click OK.

            5 Bitmap and Bitmap1 appear below Contents. Select Bitmap1, right-click, and choose Rename. Give the bitmap the same name as the class name for your new component, including the T, using all uppercase letters. For example, if your new class name is going to be TMyNewButton, name the bitmap TMYNEWBUTTON.

            Note You must name all uppercase letters, no matter how you spell the class name in the New Component dialog box.

            6 Double-click TMYNEWBUTTON to display a dialog box with an empty bitmap.

            7 Use the color palette at the bottom of the Image Editor to design your icon.

            8 Choose File|Save As and give the resource file (.dcr or .res) the same base name as the unit you want the component class declared in. For example, name the resource file MyNewButton.dcr.

            9 Choose Component|New Component. Follow the instructions for creating a new component using the Component wizard on page 45-9. Make sure that the component source, MyNewButton.cpp, is in the same directory as MyNewButton.dcr. The Component wizard, for a class named TMyNewButton, names the component source, or unit, MyNewButton.cpp with a default placement in the LIB directory. Click the Browse button to find the new location for the generated component unit.

            Note If you are using a .res file for the bitmap rather than a .dcr file, then add a reference to the component source to bind the resource. For example, if your .res file is named MyNewButton.res, after ensuring thatthe .cpp and .res are in the same directory, add the following in MyNewButton.cpp:

            #pragma resource ".dcr"

            or

            #pragma resource ".res"

            10 Choose Component|Install Component to install your component into a new or existing package. Click OK. Your new package is built and then installed. The bitmap representing your new component appears on the Component palette page you designated in the Component wizard.


            Поделал это на BCB5 и BCB6 для *.dcr и *.res. Получилось.


            2 Stclover.

            > Ох и намучеешся ты...
            > Картинку лучше встввлять заранее
            >:( Зачем шутите?

            > Готов поспорить, не получится. В свое время у меня получилось раза с четвертого.
            Спорю.

            Специально создал компонент TMyEdit на основе TEdit.
            Установил его на закладку Samples.
            Убедился, что у него значок от TEdit.
            Удалил компонент с закладки Samples.
            Нарисовал значок, как сказано в п.1 - п.8
            Добавил в MyEdit.cpp
            ExpandedWrap disabled
              <br>...<br>#pragma package(smart_init)<br>#pragma resource "*.res"              // <-- добавленная строка<br>//---------------------------------------------------------------------------<br>// ValidCtrCheck is used to assure that the components created do not have<br>// any pure virtual functions.<br>//<br><br>static inline void ValidCtrCheck(TMyEdit *)<br>{<br>...<br>

            Пересобрал Pakage с компонентом.
            Установил на закладку Samples.
            Значок новый.
            Получилось с первого раза.
            Вы проспорили.  :P
            0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)
            0 пользователей:


            Рейтинг@Mail.ru
            [ Script execution time: 0,0202 ]   [ 16 queries used ]   [ Generated: 2.05.24, 01:51 GMT ]