Solved

Delphi ToolBar Problem

Posted on 2008-10-27
2
1,657 Views
Last Modified: 2013-11-23
I am making my application as resolution indepandant but toolbuttons are not calculated depends on my formula for resolution which is applying for other components

Below is mycode

for idx := 0 to -1 + self.ComponentCount do
  begin
    if Components[idx] is TControl then
    begin
      ctrl := TControl(Components[idx]) ;
      if (ctrl.Name = 'LEADImage1') or (ctrl.Name = 'OutputImage') then  continue;
      ctrl.Top := ctrl.Top * longint(screen.Height) div
                  ScreenHeight;
      ctrl.Height := ctrl.Height  * longint(screen.Height) div
                  ScreenHeight;
      ctrl.Left := ctrl.Left  * longint(screen.Width) div
                  ScreenWidth;
      ctrl.Width := ctrl.Width * longint(screen.Width) div
                  ScreenWidth;
      if GetPropInfo(ClassInfo, 'font')<>nil then
               Font.Size := (GetSystemMetrics(0)  div ScreenWidth)
                           *font.Size;
    end;
  end;
0
Comment
Question by:inampudi1
2 Comments
 
LVL 4

Accepted Solution

by:
dprochownik earned 500 total points
ID: 22810913
Toolbar button are specific component which don't decide about their size. You have to change button size for TToolBar component, which contains Toolbuttons

You can simply change yours procedure like this:


for idx := 0 to -1 + self.ComponentCount do

  begin

    if Components[idx] is TToolBar then

    begin

      TToolBar(Components[idx]).ButtonHeight := TToolBar(Components[idx]).ButtonHeight  * longint(screen.Height) div

                  ScreenHeight;

      TToolBar(Components[idx]).ButtonWidth := TToolBar(Components[idx]).ButtonWidth * longint(screen.Width) div

                  ScreenWidth;

    end

    else if Components[idx] is TControl then

    begin

      ctrl := TControl(Components[idx]) ;

      if (ctrl.Name = 'LEADImage1') or (ctrl.Name = 'OutputImage') then  continue;

      ctrl.Top := ctrl.Top * longint(screen.Height) div

                  ScreenHeight;

      ctrl.Height := ctrl.Height  * longint(screen.Height) div

                  ScreenHeight;

      ctrl.Left := ctrl.Left  * longint(screen.Width) div

                  ScreenWidth;

      ctrl.Width := ctrl.Width * longint(screen.Width) div

                  ScreenWidth;

      if GetPropInfo(ClassInfo, 'font')<>nil then

               Font.Size := (GetSystemMetrics(0)  div ScreenWidth)

                           *font.Size;

    end;

  end;

Open in new window

0
 

Author Closing Comment

by:inampudi1
ID: 31510222
thanks a lot for your assistance in solving my problem
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

912 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

21 Experts available now in Live!

Get 1:1 Help Now