Solved

changing icons on the DBNavigator1

Posted on 2004-04-23
6
525 Views
Last Modified: 2008-02-01
hi i have a DBNavigator1 and i would like to change icons on it
i have a resource file already and i am using
this code but id oen't work it doesn't even replace the basic icons with the caption nor the image s

dould anybody help


procedure TFrame1.FormActivate(Sender: TObject);
var c:
Integer;
begin
with DBNavigator1 do
    for c := 0 to ControlCount -1 do
      if Controls[c] is TNavButton then
        with TNavButton(Controls[c]) do
        begin
          Glyph := nil;
          Font.Style := [fsBold];
          case TNavigateBtn(c) of
            nbInsert :begin
                           Caption := 'Add';
                           Glyph.LoadFromResourceName(HInstance, 'ADD');

                          end;
            nbDelete : begin
                             Caption := 'Delete';
                             Glyph.LoadFromResourceName(HInstance, 'DELETE');
                            end;

            nbPost   :begin
                           Caption := 'Post';
                            Glyph.LoadFromResourceName(HInstance, 'POST');
                          end;
            nbCancel :begin
                            Caption := 'Remove';
                           Glyph.LoadFromResourceName(HInstance, 'REMOVE');
                           end;
            end;
         end;

end;
0
Comment
Question by:magma_george
6 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 10904077
Have you declared the resource file name ?

implementation
{$R Frame1.RES}  
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10904116

    create empty TXT file and save it as Frame1.rc
    write inside

    ADD             RT_BITMAP              Add.bmp
    DELETE        RT_BITMAP              Delete.bmp
    .....
    and so on..

    You Borland Command line resource compiles brcc32 found in Delphi/Bin folder

    type
           brcc32 -v Frame1.rc

    and you will have Frame1.res file in the directory.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10904133

   Sorry, my mistake.... If your form is called Frame1 then name the RC file something else, for example DBNavButtons.rc and do the steps described above.

   Then after {$R Frame1.res} add {$R DBNavButtons.res}
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:magma_george
ID: 10904566
i did
what's next

0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 10904579

  compile the code about

  procedure TFrame1.FormActivate(Sender: TObject);
  .....
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 500 total points
ID: 10904947
They were not showing cause you didn't describe your DBImages.res file corectly, it fixed it for you and emailed it to you.

Also, because each button (generated at runtime) is assigned nil initially, you wont see anything on the Buttons until you get the Glyphs from the Resource file working properly.


Also, you needed to add the rest of your buttons to the runtime code.....

var I: Integer;
begin
with DBNavigator1 do
for I := 0 to ControlCount -1 do
 if Controls[I] is TNavButton then
  with TNavButton(Controls[I]) do
  begin
   Glyph := nil;
   Font.Style := [fsBold];
   Layout:= blGlyphTop;
   case TNavigateBtn(I) of

    nbInsert :begin
               Caption := 'Add';
               Glyph.LoadFromResourceName(HInstance, 'ADD');
              end;
    nbDelete : begin
                Caption := 'Delete';
                Glyph.LoadFromResourceName(HInstance, 'DELETE');
               end;

     nbPost   :begin
                Caption := 'Post';
                Glyph.LoadFromResourceName(HInstance, 'POST');
               end;
     nbCancel :begin
                Caption := 'Cancel';
                Glyph.LoadFromResourceName(HInstance, 'CANCEL');
               end;
     nbFirst :begin
               Caption := 'First';
               Glyph.LoadFromResourceName(HInstance, 'FIRST');
              end;
     nbLast :begin
               Caption := 'Last';
               Glyph.LoadFromResourceName(HInstance, 'LAST');
              end;
     nbNext :begin
               Caption := 'Next';
               Glyph.LoadFromResourceName(HInstance, 'NEXT');
              end;
     nbRefresh :begin
                       Caption := 'Next';
                       Glyph.LoadFromResourceName(HInstance, 'REFRESH');
              end;
     end;
  end;
end;


Shane
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question