Solved

changing icons on the DBNavigator1

Posted on 2004-04-23
6
522 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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