Ignore:
Timestamp:
May 7, 2015, 12:34:29 PM (9 years ago)
Author:
healthsevak
Message:

Updating the working copy to CPRS version 28

File:
1 edited

Legend:

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

    r829 r1679  
    3636function LowerOf(i, j: Integer): Integer;
    3737function StrToFloatDef(const S: string; ADefault: Extended): Extended;
     38function RectContains(Rect: TRect; Point: TPoint): boolean;
    3839
    3940{ String functions }
     
    4142function ContainsAlpha(const x: string): Boolean;
    4243function ContainsVisibleChar(const x: string): Boolean;
     44function ContainsUpCarretChar(const x: string): Boolean;
    4345function ConvertSpecialStrings(const x: string): String;
    4446function CRCForFile(AFileName: string): DWORD;
     
    118120
    119121{ Misc functions }
     122function CPRSInstances: integer;
    120123{ You MUST pass an address to an object variable to get KillObj to work }
    121124procedure KillObj(ptr: Pointer; KillObjects: boolean = FALSE);
     
    124127procedure CallWhenIdle(CallProc: TORIdleCallProc; Msg: String);
    125128procedure CallWhenIdleNotifyWhenDone(CallProc, DoneProc: TORIdleCallProc; Msg: String);
     129
    126130procedure menuHideAllBut(aMenuItem: tMenuItem; butItems: array of tMenuItem);
    127131function TabIsPressed : Boolean;
    128132function ShiftTabIsPressed : Boolean;
    129133function EnterIsPressed : Boolean;
     134procedure ScrollControl(Window: TScrollingWinControl; ScrollingUp: boolean; Amount: integer = 40);
    130135
    131136implementation  // ---------------------------------------------------------------------------
     
    387392end;
    388393
     394function RectContains(Rect: TRect; Point: TPoint): boolean;
     395begin
     396  Result := ((Point.X >= Rect.Left) and
     397             (Point.X <= Rect.Right) and
     398             (Point.Y >= Rect.Top) and
     399             (Point.Y <= Rect.Bottom));
     400end;
     401
    389402{ String functions }
    390403
     
    415428  Result := False;
    416429  for i := 1 to Length(x) do if x[i] in ['!'..'~'] then  // ordinal values 33..126
     430  begin
     431    Result := True;
     432    break;
     433  end;
     434end;   
     435
     436function ContainsUpCarretChar(const x: string): Boolean;
     437{ returns true if the string contains the ^ character }
     438var
     439  i: Integer;
     440begin
     441  Result := False;
     442  for i := 1 to Length(x) do if x[i] = '^' then  // ordinal values 33..126
    417443  begin
    418444    Result := True;
     
    20222048*)
    20232049
     2050function CPRSInstances: integer;
     2051// returns the number of CPRS sessions open
     2052var
     2053  AHandle: hWnd;
     2054  LengthText, LengthConst, counter: Integer;
     2055  CharText: array [0..254] of Char;
     2056  TitleText, TitleCompare: string;
     2057const
     2058  TX_IN_USE = 'VistA CPRS in use by: '; // use same as in fFrame
     2059begin
     2060  counter := 0;
     2061  LengthConst := length(TX_IN_USE);
     2062  AHandle := FindWindow(nil, nil);
     2063  while AHandle <> 0 do begin
     2064    LengthText := GetWindowText(AHandle, CharText, 255);
     2065    if LengthText > 0 then
     2066    begin
     2067      TitleText := CharText;
     2068      TitleCompare := copy(TitleText, 1, LengthConst);
     2069      if TitleCompare = TX_IN_USE then
     2070        counter := counter + 1;
     2071    end;
     2072    AHandle := GetWindow(AHandle, GW_HWNDNEXT);
     2073  end;
     2074  Result := counter;
     2075end;
     2076
    20242077{ You MUST pass an address to an object variable to get KillObj to work }
    20252078procedure KillObj(ptr: Pointer; KillObjects: boolean = FALSE);
     
    21972250end;
    21982251
     2252procedure ScrollControl(Window: TScrollingWinControl; ScrollingUp: boolean; Amount: integer = 40);
     2253var
     2254  Delta: integer;
     2255
     2256  // This is needed to tell the child components that they are moving,
     2257  // The TORCombo box, for example, needs to close a dropped down window when it moves.
     2258  // If Delphi had used standard scroll bars, instead of the customized flat ones, this
     2259  // code wouldn't be needed
     2260  procedure SendMoveMessage(Ctrl: TWinControl);
     2261  var
     2262    i: integer;
     2263  begin
     2264    for i := 0 to Ctrl.ControlCount - 1 do
     2265    begin
     2266      if Ctrl.Controls[i] is TWinControl then with TWinControl(Ctrl.Controls[i]) do
     2267      begin
     2268        SendMessage(Handle, WM_MOVE, 0, (Top * 65536) + Left);
     2269        SendMoveMessage(TWinControl(Ctrl.Controls[i]));
     2270      end;
     2271    end;
     2272  end;
     2273 
     2274begin
     2275  Delta := Amount;
     2276  if ScrollingUp then
     2277  begin
     2278    if Window.VertScrollBar.Position < Delta then
     2279      Delta := Window.VertScrollBar.Position;
     2280    Delta := - Delta;
     2281  end
     2282  else
     2283  begin
     2284    if (Window.VertScrollBar.Range - Window.VertScrollBar.Position) < Delta then
     2285      Delta := Window.VertScrollBar.Range - Window.VertScrollBar.Position;
     2286  end;
     2287  if Delta <> 0 then
     2288  begin
     2289    Window.VertScrollBar.Position := Window.VertScrollBar.Position + Delta;
     2290    SendMoveMessage(Window);
     2291  end;
     2292end;
     2293
    21992294initialization
    22002295  FBaseFont := TFont.Create;
Note: See TracChangeset for help on using the changeset viewer.