Solved

changing icons on the DBNavigator1

Posted on 2004-04-23
6
513 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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

747 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now