Ignore:
Timestamp:
Jul 7, 2010, 4:31:10 PM (14 years ago)
Author:
Kevin Toppenberg
Message:

Upgrade to version 27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cprs/trunk/CPRS-Lib/ORFn.pas

    r456 r829  
    66
    77uses SysUtils, Windows, Messages, Classes, Controls, StdCtrls, ExtCtrls, ComCtrls, Forms,
    8      Graphics, Menus, RichEdit;
     8     Graphics, Menus, RichEdit, Buttons;
    99
    1010const
     
    1313  BOOLCHAR: array[Boolean] of Char = ('0', '1');
    1414  UM_STATUSTEXT = (WM_USER + 302);               // used to send update status msg to main form
    15   COLOR_CREAM   = $F0FBFF;
     15
     16var
     17  ScrollBarHeight: integer = 0;
    1618
    1719type
     
    6668function DelimCount(const Str, Delim: string): integer;
    6769procedure QuickCopy(AFrom, ATo: TObject);
     70procedure QuickAdd(AFrom, ATo: TObject);
     71procedure FastAssign(source, destination: TStrings);
     72procedure FastAddStrings(source, destination: TStrings);
    6873function ValidFileName(const InitialFileName: string): string;
    6974
     
    8489procedure ResizeFormToFont(AForm: TForm);
    8590procedure ResizeAnchoredFormToFont( AForm: TForm);
     91procedure AdjustForWindowsXPStyleTitleBar(AForm: TForm);
    8692function ResizeWidth( OldFont: TFont; NewFont: TFont; OldWidth: integer): integer;
    8793function ResizeHeight( OldFont: TFont; NewFont: TFont; OldHeight: integer): integer;
     
    96102function PopupComponent(Sender: TObject; PopupMenu: TPopupMenu): TComponent;
    97103procedure ReformatMemoParagraph(AMemo: TCustomMemo);
    98 function ReadOnlyColor: TColor;
     104
     105function BlackColorScheme: Boolean;
     106function NormalColorScheme: Boolean;
     107function Get508CompliantColor(Color: TColor): TColor;
     108procedure UpdateColorsFor508Compliance(control: TControl; InputEditControl: boolean = FALSE);
     109procedure UpdateReadOnlyColorScheme(Control: TControl; ReadOnly: boolean);
    99110
    100111{ ListBox Grid functions }
     
    116127function TabIsPressed : Boolean;
    117128function ShiftTabIsPressed : Boolean;
     129function EnterIsPressed : Boolean;
    118130
    119131implementation  // ---------------------------------------------------------------------------
    120132
    121133uses
    122   ORCtrls, Grids, Chart, CheckLst;
     134  ORCtrls, Grids, Chart, CheckLst, VAUtils;
    123135
    124136const
     
    606618function Piece(const S: string; Delim: char; PieceNum: Integer): string;
    607619{ returns the Nth piece (PieceNum) of a string delimited by Delim }
    608 var
    609   i: Integer;
    610   Strt, Next: PChar;
    611 begin
    612   i := 1;
    613   Strt := PChar(S);
    614   Next := StrScan(Strt, Delim);
    615   while (i < PieceNum) and (Next <> nil) do
    616   begin
    617     Inc(i);
    618     Strt := Next + 1;
    619     Next := StrScan(Strt, Delim);
    620   end;
    621   if Next = nil then Next := StrEnd(Strt);
    622   if i < PieceNum then Result := '' else SetString(Result, Strt, Next - Strt);
     620begin
     621  Result := VAUtils.Piece(S, Delim, PieceNum);
    623622end;
    624623
    625624function Pieces(const S: string; Delim: char; FirstNum, LastNum: Integer): string;
    626 { returns several contiguous pieces }
    627 var
    628   PieceNum: Integer;
    629 begin
    630   Result := '';
    631   for PieceNum := FirstNum to LastNum do Result := Result + Piece(S, Delim, PieceNum) + Delim;
    632   if Length(Result) > 0 then Delete(Result, Length(Result), 1);
     625begin
     626  Result := VAUtils.Pieces(S, Delim, FirstNum, LastNum);
    633627end;
    634628
     
    779773    if obj is TListBox then
    780774      str[idx] := TListBox(obj).Items
     775    else
     776    if obj is TORComboBox then
     777      str[idx] := TORComboBox(obj).Items
     778    else
     779    if obj is TComboBox then
     780      str[idx] := TComboBox(obj).Items
    781781    else
    782782    if obj is TRichEdit then
     
    815815  if fix[0] then TRichEdit(AFrom).PlainText := FALSE;
    816816  if fix[1] then TRichEdit(ATo).PlainText := FALSE;
     817  if ATo is TRichEdit then
     818    TRichEdit(ATo).SelStart := Length(TRichEdit(ATo).Lines.Text); //CQ: 16461
     819end;
     820
     821type
     822  QuickAddError = class(Exception);
     823
     824procedure QuickAdd(AFrom, ATo: TObject);
     825var
     826  ms: TMemoryStream;
     827  idx: integer;
     828  str: array[0..1] of TStrings;
     829  fix: array[0..1] of boolean;
     830
     831  procedure GetStrings(obj: TObject);
     832  begin
     833    if (CompareText(obj.ClassName, 'TRichEditStrings') = 0) then
     834      raise QuickCopyError.Create('You must pass the TRichEdit object into QuickAdd, NOT it''s Lines property.');
     835    if obj is TStrings then
     836      str[idx] := TStrings(obj)
     837    else
     838    if obj is TMemo then
     839      str[idx] := TMemo(obj).Lines
     840    else
     841    if obj is TORListBox then
     842      str[idx] := TORListBox(obj).Items
     843    else
     844    if obj is TListBox then
     845      str[idx] := TListBox(obj).Items
     846    else
     847    if obj is TORComboBox then
     848      str[idx] := TORComboBox(obj).Items
     849    else
     850    if obj is TComboBox then
     851      str[idx] := TComboBox(obj).Items
     852    else
     853    if obj is TRichEdit then
     854    begin
     855      with TRichEdit(obj) do
     856      begin
     857        str[idx] := Lines;
     858        if not PlainText then
     859        begin
     860          fix[idx] := TRUE;
     861          PlainText := TRUE;
     862        end;
     863      end;
     864    end
     865    else
     866      raise QuickAddError.Create('Unsupported object type (' + obj.ClassName +
     867                                  ') passed into QuickAdd.');
     868    inc(idx);
     869  end;
     870
     871
     872begin
     873  fix[0] := FALSE;
     874  fix[1] := FALSE;
     875  idx := 0;
     876  GetStrings(AFrom);
     877  GetStrings(ATo);
     878  ms := TMemoryStream.Create;
     879  try
     880    str[1].SaveToStream(ms);
     881    ms.Seek(0, soFromEnd);
     882    str[0].SaveToStream(ms);
     883    ms.Seek(0, soFromBeginning);
     884    str[1].Clear;
     885    str[1].LoadFromStream(ms);
     886  finally
     887    ms.Free;
     888  end;
     889  if fix[0] then TRichEdit(AFrom).PlainText := FALSE;
     890  if fix[1] then TRichEdit(ATo).PlainText := FALSE;
     891end;
     892
     893procedure FastAssign(source, destination: TStrings);
     894// do not use this with RichEdit Lines unless source is RichEdit with PlainText
     895var
     896  ms: TMemoryStream;
     897begin
     898  destination.Clear;
     899  if (source is TStringList) and (destination is TStringList) then
     900    destination.Assign(source)
     901  else
     902  if (CompareText(source.ClassName, 'TRichEditStrings') = 0) then
     903    destination.Assign(source)
     904  else
     905  begin
     906    ms := TMemoryStream.Create;
     907    try
     908      source.SaveToStream(ms);
     909      ms.Seek(0, soFromBeginning);
     910      destination.LoadFromStream(ms);
     911    finally
     912      ms.Free;
     913    end;
     914  end;
     915end;
     916
     917procedure FastAddStrings(source, destination: TStrings);
     918// do not use this with RichEdit Lines unless source and destination are RichEdit with PlainText
     919var
     920  ms: TMemoryStream;
     921begin
     922  if (source is TStringList) and (destination is TStringList) then
     923    destination.AddStrings(source)
     924  else
     925  begin
     926    ms := TMemoryStream.Create;
     927    try
     928      destination.SaveToStream(ms);
     929      ms.Seek(0, soFromEnd);
     930      source.SaveToStream(ms);
     931      ms.Seek(0, soFromBeginning);
     932      destination.Clear;
     933      destination.LoadFromStream(ms);
     934    finally
     935      ms.Free;
     936    end;
     937  end;
    817938end;
    818939
     
    861982    end; {for i}
    862983    AList.Clear;
    863     AList.Assign(NewList);
     984    FastAssign(NewList, AList);
    864985  finally
    865986    NewList.Free;
     
    12481369end;
    12491370
     1371var
     1372  AlignList, AnchorList: TStringList;
     1373
     1374function AnchorsToStr(Control: TControl): string;
     1375var
     1376  j: TAnchorKind;
     1377
     1378begin
     1379  Result := '';
     1380  for j := low(TAnchorKind) to high(TAnchorKind) do
     1381    if j in Control.Anchors then
     1382      Result := result + '1'
     1383    else
     1384      Result := result + '0'
     1385end;
     1386
     1387function StrToAnchors(i: integer): TAnchors;
     1388var
     1389  j: TAnchorKind;
     1390  value: string;
     1391  idx : integer;
     1392begin
     1393  Result := [];
     1394  value := AnchorList[i];
     1395  idx := 1;
     1396  for j := low(TAnchorKind) to high(TAnchorKind) do
     1397  begin
     1398    if copy(value,idx,1) = '1' then
     1399      include(Result, j);
     1400    inc(idx);
     1401  end;
     1402end;
     1403
     1404procedure SuspendAlign(AForm: TForm);
     1405var
     1406  i: integer;
     1407  control: TControl;
     1408begin
     1409  AForm.DisableAlign;
     1410  AlignList.Clear;
     1411  AnchorList.Clear;
     1412  for i := 0 to AForm.ControlCount-1 do
     1413  begin
     1414    control := AForm.Controls[i];
     1415    AlignList.Add(IntToStr(ord(control.align)));
     1416    control.Align := alNone;
     1417    AnchorList.Add(AnchorsToStr(control));
     1418    control.Anchors := [];
     1419  end;
     1420end;
     1421
     1422procedure RestoreAlign(AForm: TForm);
     1423var
     1424  i: integer;
     1425  control: TControl;
     1426begin
     1427  try
     1428    for i := 0 to AForm.ControlCount-1 do
     1429    begin
     1430      control := AForm.Controls[i];
     1431      control.Align := TAlign(StrToIntDef(AlignList[i],0));
     1432      control.Anchors := StrToAnchors(i);
     1433    end;
     1434    AlignList.Clear;
     1435    AnchorList.Clear;
     1436  finally
     1437    AForm.EnableAlign;
     1438  end;
     1439end;
     1440
    12501441procedure ResizeFormToFont(AForm: TForm);
    12511442var
    12521443  Rect: TRect;
    1253 begin
     1444  OldResize: TNotifyEvent;
     1445begin
     1446// CQ# 11481 apply size changes to form all at once, instead of piece by piece.  Otherwise,
     1447// multiple calls to fAutoSz.FormResize, even if the form has not resized, can distort
     1448// the controls beyond the size of the form.
    12541449  with AForm do begin
    1255     ClientWidth := ResizeWidth( Font, MainFont, ClientWidth);
    1256     ClientHeight := ResizeHeight( Font, MainFont, ClientHeight);
    1257     HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range);
    1258     VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range);
    1259     Rect := BoundsRect;
    1260     ForceInsideWorkArea(Rect);
    1261     BoundsRect := Rect;
    1262     ResizeFontsInDescendants( Font, MainFont, AForm);
    1263     //Important: We are using the font to calculate everything, so don't
    1264     //change font until now.
    1265     Font.Size := MainFont.Size;
     1450    OldResize := AForm.OnResize;
     1451    AForm.OnResize := nil;
     1452    try
     1453      SuspendAlign(AForm);
     1454      try
     1455        HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range);
     1456        VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range);
     1457        ClientWidth := ResizeWidth( Font, MainFont, ClientWidth);
     1458        ClientHeight := ResizeHeight( Font, MainFont, ClientHeight);
     1459        Rect := BoundsRect;
     1460        ForceInsideWorkArea(Rect);
     1461        BoundsRect := Rect;
     1462      finally
     1463        RestoreAlign(AForm);
     1464      end;
     1465      ResizeFontsInDescendants( Font, MainFont, AForm);
     1466      //Important: We are using the font to calculate everything, so don't
     1467      //change font until now.
     1468      Font.Size := MainFont.Size;
     1469    finally
     1470      if(Assigned(OldResize)) then
     1471      begin
     1472        AForm.OnResize := OldResize;
     1473        OldResize(AForm);
     1474      end;
     1475    end;
    12661476  end;
    12671477end;
     
    12701480var
    12711481  Rect: TRect;
     1482  OldResize: TNotifyEvent;
     1483
    12721484begin
    12731485  with AForm do begin
    1274     ClientWidth  := ResizeWidth( Font, MainFont, ClientWidth);
    1275     ClientHeight := ResizeHeight( Font, MainFont, ClientHeight);
    1276     HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range);
    1277     VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range);
    1278     Rect := BoundsRect;
    1279     ForceInsideWorkArea(Rect);
    1280     BoundsRect := Rect;
    1281     ResizeDescendants( Font, MainFont, AForm);
    1282     ResizeFontsInDescendants( Font, MainFont, AForm);
    1283     //Important: We are using the font to calculate everything, so don't
    1284     //change font until now.
    1285     Font.Size := MainFont.Size;
     1486  // CQ# 11481 - see ResizeFormToFont
     1487    OldResize := AForm.OnResize;
     1488    AForm.OnResize := nil;
     1489    try
     1490      HorzScrollBar.Range := ResizeWidth( Font, MainFont, HorzScrollBar.Range);
     1491      VertScrollBar.Range := ResizeHeight( Font, MainFont, VertScrollBar.Range);
     1492      ClientWidth  := ResizeWidth( Font, MainFont, ClientWidth);
     1493      ClientHeight := ResizeHeight( Font, MainFont, ClientHeight);
     1494      Rect := BoundsRect;
     1495      ForceInsideWorkArea(Rect);
     1496      BoundsRect := Rect;
     1497      ResizeDescendants( Font, MainFont, AForm);
     1498      ResizeFontsInDescendants( Font, MainFont, AForm);
     1499      //Important: We are using the font to calculate everything, so don't
     1500      //change font until now.
     1501      Font.Size := MainFont.Size;
     1502    finally
     1503      if(Assigned(OldResize)) then
     1504      begin
     1505        AForm.OnResize := OldResize;
     1506        OldResize(AForm);
     1507      end;
     1508    end;
     1509  end;
     1510end;
     1511
     1512// CQ 11485 - Adjusts all forms  - adds additional height to the form to
     1513// adjust for Windows XP style title bars, and for large fonts in title bar
     1514procedure AdjustForWindowsXPStyleTitleBar(AForm: TForm);
     1515const
     1516  DEFAULT_CAPTION_HEIGHT = 19;
     1517  DEFAULT_MENU_HEIGHT = 19;
     1518
     1519var
     1520  dxsb, dysb, dy, menuDY: integer;
     1521
     1522begin
     1523// Call GetSystemMetrics each time because values can change between calls
     1524  dy := GetSystemMetrics(SM_CYCAPTION) - DEFAULT_CAPTION_HEIGHT;
     1525  if (AForm.Menu <> nil) then
     1526  begin
     1527    menuDY := GetSystemMetrics(SM_CYMENU) - DEFAULT_MENU_HEIGHT;
     1528    inc(dy, menuDY);
     1529  end;
     1530  if dy <> 0 then
     1531  begin
     1532    SuspendAlign(AForm);
     1533    try
     1534    // Assitional adjustment to allow scroll bars to dissappear
     1535      dxsb := GetSystemMetrics(SM_CXVSCROLL);
     1536      dysb := GetSystemMetrics(SM_CYHSCROLL);
     1537      AForm.Height := AForm.Height + dy + dysb;
     1538      AForm.Width := AForm.Width + dxsb;
     1539      AForm.Height := AForm.Height - dysb;
     1540      AForm.Width := AForm.Width - dxsb;
     1541    finally
     1542      RestoreAlign(AForm);
     1543    end;
    12861544  end;
    12871545end;
     
    13291587begin
    13301588  DC := GetDC(0);
    1331   SaveFont := SelectObject(DC, AFontHandle);
    1332   GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize);
    1333   Result := TextSize.cx;
    1334   SelectObject(DC, SaveFont);
    1335   ReleaseDC(0, DC);
     1589  try
     1590    SaveFont := SelectObject(DC, AFontHandle);
     1591    try
     1592      GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize);
     1593      Result := TextSize.cx;
     1594    finally
     1595      SelectObject(DC, SaveFont);
     1596    end;
     1597  finally
     1598    ReleaseDC(0, DC);
     1599  end;
    13361600end;
    13371601
     
    13441608begin
    13451609  DC := GetDC(0);
    1346   SaveFont := SelectObject(DC, AFontHandle);
    1347   GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize);
    1348   Result := TextSize.cy;
    1349   SelectObject(DC, SaveFont);
    1350   ReleaseDC(0, DC);
     1610  try
     1611    SaveFont := SelectObject(DC, AFontHandle);
     1612    try
     1613      GetTextExtentPoint32(DC, PChar(x), Length(x), TextSize);
     1614      Result := TextSize.cy;
     1615    finally
     1616      SelectObject(DC, SaveFont);
     1617    end;
     1618  finally
     1619    ReleaseDC(0, DC);
     1620  end;
     1621  if Result > 255 then // CQ 11493
     1622    Result := 255; // This is maximum allowed by a Windows
    13511623end;
    13521624
     
    13931665    end;
    13941666  end;
     1667  if Result > 255 then // CQ 11492
     1668    Result := 255; // This is maximum allowed by a Windows
    13951669end;
    13961670
     
    14711745
    14721746var
    1473   uReadOnlyColor: TColor;
    1474   uHaveReadOnlyColor: boolean = FALSE;
    1475 
    1476 function ReadOnlyColor: TColor;
    1477 begin
    1478   if not uHaveReadOnlyColor then
    1479   begin
    1480     uHaveReadOnlyColor := TRUE;
    1481     if ColorToRGB(clWindow) = ColorToRGB(clWhite) then
    1482       uReadOnlyColor := $00F0FBFF
     1747  uNormalColorScheme: boolean = false;
     1748  uBlackColorScheme: boolean = false;
     1749  uWhiteColorScheme: boolean = false;
     1750  uMaroonColorWhenBlack: TColor = clMaroon;
     1751  uCheckColorScheme: boolean = true;
     1752  PURE_BLACK: longint = 0;
     1753
     1754const
     1755  uBorderlessWindowColorWhenBlack: TColor = clNavy;
     1756
     1757
     1758procedure CheckColorScheme;
     1759begin
     1760  if uCheckColorScheme then
     1761  begin
     1762    uNormalColorScheme :=
     1763      ((ColorToRGB(clWindow)      = ColorToRGB(clWhite)) and
     1764       (ColorToRGB(clWindowText)  = ColorToRGB(clBlack)) and
     1765       (ColorToRGB(clInfoText)    = ColorToRGB(clBlack)) and
     1766       (ColorToRGB(clInfoBk)     <> ColorToRGB(clWhite)));
     1767
     1768    uBlackColorScheme := ((ColorToRGB(clBtnFace) = ColorToRGB(clBlack)) and
     1769                          (ColorToRGB(clWindow) = ColorToRGB(clBlack)));
     1770    uWhiteColorScheme := ((ColorToRGB(clBtnFace) = ColorToRGB(clWhite)) and
     1771                          (ColorToRGB(clWindow) = ColorToRGB(clWhite)));
     1772
     1773    if uBlackColorScheme then
     1774    begin
     1775      if(ColorToRGB(clGrayText) = ColorToRGB(clWindowText)) then
     1776        uMaroonColorWhenBlack := clHighlightText
     1777      else
     1778        uMaroonColorWhenBlack := clGrayText;
     1779    end;
     1780
     1781    uCheckColorScheme := FALSE;
     1782  end;
     1783end;
     1784
     1785function BlackColorScheme: Boolean;
     1786begin
     1787  if uCheckColorScheme then CheckColorScheme;
     1788  Result := uBlackColorScheme;
     1789end;
     1790
     1791function NormalColorScheme: Boolean;
     1792begin
     1793  if uCheckColorScheme then CheckColorScheme;
     1794  Result := uNormalColorScheme;
     1795end;
     1796
     1797function Get508CompliantColor(Color: TColor): TColor;
     1798begin
     1799  Result := Color;
     1800  if NormalColorScheme then exit;
     1801
     1802  case Color of
     1803    clCream:    Result := clInfoBk;
     1804    clBlack:    Result := clWindowText;
     1805    clWhite:    Result := clWindow;
     1806  end;
     1807
     1808  if uBlackColorScheme then
     1809  begin
     1810    case Color of
     1811      clBlue:     Result := clAqua;
     1812      clMaroon:   Result := uMaroonColorWhenBlack;
     1813  //    clRed:      Result := clFuchsia;
     1814    end;
     1815  end;
     1816
     1817  if uWhiteColorScheme then
     1818  begin
     1819    case Color of
     1820      clGrayText: Result := clGray;
     1821    end;
     1822  end;
     1823end;
     1824
     1825type
     1826  TExposedControl = class(TControl)
     1827  public
     1828    property Color;
     1829    property Font;
     1830  end;
     1831
     1832  TExposedCustomEdit = class(TCustomEdit)
     1833  public
     1834    property BorderStyle;
     1835    property ReadOnly;
     1836  end;
     1837
     1838procedure UpdateColorsFor508Compliance(control: TControl; InputEditControl: boolean = FALSE);
     1839var
     1840  BitMapLevelCheck: integer;
     1841  Level: integer;
     1842
     1843
     1844  procedure BlackColorSchemeUpdate(control: TControl);
     1845  var
     1846    bitmap: TBitMap;
     1847    edit: TExposedCustomEdit;
     1848    x,y: integer;
     1849    cbmCtrl: IORBlackColorModeCompatible;
     1850
     1851  begin
     1852    if uBlackColorScheme then
     1853    begin
     1854      if Level < BitMapLevelCheck then
     1855      begin
     1856        if control.GetInterface(IORBlackColorModeCompatible, cbmCtrl) then
     1857        begin
     1858          cbmCtrl.SetBlackColorMode(TRUE);
     1859          BitMapLevelCheck := Level;
     1860          cbmCtrl := nil;
     1861        end
     1862        else
     1863        begin
     1864          if (control is TBitBtn) then
     1865          begin
     1866            bitmap := TBitBtn(control).Glyph;
     1867            for x := 0 to bitmap.Width-1 do
     1868            begin
     1869              for y := 0 to bitmap.Height-1 do
     1870              begin
     1871                if ColorToRGB(bitmap.Canvas.Pixels[x,y]) = PURE_BLACK then
     1872                  bitmap.Canvas.Pixels[x,y] := clWindowText;
     1873              end;
     1874            end;
     1875          end;
     1876        end;
     1877      end;
     1878
     1879      if (control is TCustomEdit) and InputEditControl then
     1880      begin
     1881        edit := TExposedCustomEdit(control);
     1882        if (edit.BorderStyle = bsNone) then
     1883          edit.Color := uBorderlessWindowColorWhenBlack;
     1884      end;
     1885
     1886    end;
     1887  end;
     1888
     1889  procedure ComponentUpdateColorsFor508Compliance(control: TControl);
     1890  var
     1891    OldComponentColor, OldFontColor, NewComponentColor, NewFontColor: TColor;
     1892  begin
     1893    OldComponentColor := TExposedControl(control).Color;
     1894    OldFontColor := TExposedControl(control).Font.Color;
     1895    NewComponentColor := Get508CompliantColor(OldComponentColor);
     1896    if NewComponentColor = clInfoBk then
     1897    begin
     1898      if (OldFontColor = clInfoBk) or (OldFontColor = clCream) then
     1899        NewFontColor := clInfoBk // used for hiding text
     1900      else
     1901        NewFontColor := clInfoText;
     1902    end
    14831903    else
    1484       uReadOnlyColor := clWindow;
    1485   end;
    1486   Result := uReadOnlyColor;
     1904      NewFontColor := Get508CompliantColor(OldFontColor);
     1905    if NewComponentColor <> OldComponentColor then
     1906      TExposedControl(control).Color := NewComponentColor;
     1907    if NewFontColor <> OldFontColor then
     1908      TExposedControl(control).Font.Color := NewFontColor;
     1909    BlackColorSchemeUpdate(control);
     1910  end;
     1911
     1912  procedure ScanAllComponents(control: TControl);
     1913  var
     1914    i: integer;
     1915
     1916  begin
     1917    ComponentUpdateColorsFor508Compliance(Control);
     1918    if control is TWinControl then
     1919    begin
     1920      inc(Level);
     1921      try
     1922        for i := 0 to TWinControl(Control).ControlCount-1 do
     1923        begin
     1924          ScanAllComponents(TWinControl(Control).Controls[i]);
     1925        end;
     1926      finally
     1927        dec(Level);
     1928        if BitMapLevelCheck = Level then
     1929          BitMapLevelCheck := MaxInt;
     1930      end;
     1931    end;
     1932  end;
     1933
     1934begin
     1935  if NormalColorScheme then exit;
     1936  BitMapLevelCheck := MaxInt;
     1937  Level := 0;
     1938  ScanAllComponents(control);
     1939end;
     1940
     1941procedure UpdateReadOnlyColorScheme(Control: TControl; ReadOnly: boolean);
     1942begin
     1943  with TExposedControl(Control) do
     1944  begin
     1945    if ReadOnly then
     1946    begin
     1947      Color := Get508CompliantColor(clCream);
     1948      Font.Color := clInfoText;
     1949    end
     1950    else
     1951    begin
     1952      Color := clWindow;
     1953      Font.Color := clWindowText;
     1954    end;
     1955  end;
    14871956end;
    14881957
     
    15211990    end;
    15221991    Canvas.FillRect(ARect);
    1523     Canvas.Pen.Color := clSilver;
     1992    Canvas.Pen.Color := Get508CompliantColor(clSilver);
    15241993    Canvas.MoveTo(ARect.Left, ARect.Bottom - 1);
    15251994    Canvas.LineTo(ARect.Right, ARect.Bottom - 1);
     
    17142183begin
    17152184  Result := Boolean(Hi(GetKeyState(VK_TAB))) and not Boolean(Hi(GetKeyState(VK_SHIFT)));
     2185  Result := Result and not Boolean(Hi(GetKeyState(VK_CONTROL)));
    17162186end;
    17172187
     
    17192189begin
    17202190  Result := Boolean(Hi(GetKeyState(VK_TAB))) and Boolean(Hi(GetKeyState(VK_SHIFT)));
    1721 end;
    1722 
     2191  Result := Result and not Boolean(Hi(GetKeyState(VK_CONTROL)));
     2192end;
     2193
     2194function EnterIsPressed : Boolean;
     2195begin
     2196  Result := Boolean(Hi(GetKeyState(VK_RETURN)));
     2197end;
    17232198
    17242199initialization
     
    17262201  FBaseFont.Name := BaseFontName;
    17272202  FBaseFont.Size := BaseFontSize;
     2203  ScrollBarHeight := GetSystemMetrics(SM_CYHSCROLL);
     2204  AlignList := TStringList.Create;
     2205  AnchorList := TStringList.Create;
     2206  PURE_BLACK := ColorToRGB(clBlack);
    17282207
    17292208finalization
    17302209  FBaseFont.Free;
    17312210  KillObj(@IdleCaller);
     2211  FreeAndNil(AlignList);
     2212  FreeAndNil(AnchorList);
    17322213
    17332214end.
Note: See TracChangeset for help on using the changeset viewer.