home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / pascal / 8382 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  3.3 KB

  1. Xref: sparky comp.lang.pascal:8382 comp.os.ms-windows.programmer.misc:5215
  2. Path: sparky!uunet!think.com!rpi!ghost.dsi.unimi.it!insa-lyon.fr!pc110-02.insa-lyon.fr!ppollet
  3. From: ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  4. Newsgroups: comp.lang.pascal,comp.os.ms-windows.programmer.misc
  5. Subject: Re: Give window a caption
  6. Date: Thu, 21 Jan 1993 08:40:34 GMT
  7. Organization: INSA  CENTRE INFORMATIQUE DU 1er CYCLE
  8. Lines: 73
  9. Message-ID: <ppollet.169.727605634@cismibm.univ-lyon1.fr>
  10. References: <C15rpJ.Izy@cs.vu.nl>
  11. NNTP-Posting-Host: pc110-02.insa-lyon.fr
  12.  
  13. In article <C15rpJ.Izy@cs.vu.nl> martijn@cs.vu.nl (Lemmens ML) writes:
  14. >From: martijn@cs.vu.nl (Lemmens ML)
  15. >Subject: Give window a caption
  16. >Date: 20 Jan 93 15:15:18 GMT
  17.  
  18.  
  19. >I have created a window (TWindow) with Borland Pascal 7.0 without
  20. >a caption. While the program is running I want to change the looks of
  21. >the window and give it a caption. Is this possible without destroing
  22. >the window and creating a new one?
  23.  
  24. >Martijn
  25.  
  26.   in TurboVision or OWL?
  27.  
  28.    In OWL I think there is something called SetWindowText(Handle,NewText)
  29.    that is actually a Window API call ? (no experience on that)
  30.  
  31.    In Tvision you could:
  32.  
  33.       1. Change the Title of the Window by
  34.            With ThatWindow^ do
  35.              begin
  36.                 If Title<>Nil then DisposeStr(Title);
  37.                 (* Title is a field of the tWindow Object *)  
  38.                 Title:=NewStr(TheNewTitle);
  39.                 Frame^.redraw;  (*faster that full redraw*)
  40.               end 
  41.  
  42.       2. Overload its method GetTitle so that at every redraw, the
  43.          Window redraw method will "recalculate" its new caption:
  44.  
  45.          let's suppose you have an editor Window that should holds
  46.            the name of the File that is being edited or "Untitled" if
  47.            it is a new file 
  48.          you could have :
  49.  
  50.              type tMyWindow=object(tWindow)
  51.                     FileName:pString;   (* WILL BE NIL AT THE CONSTRUCTION*)
  52.                     ......
  53.                     Function GetTitle(maxSize:integer):tTitleStr;VIRTUAL;
  54.                     Procedure SetFile(aNewFilename:String);  
  55.                     ......
  56.                     end;
  57.  
  58.              function TMyWindow.GetTitle(maxSize:Integer):tTitleStr; 
  59.              (* don't use Title that is NIl from the constructor and
  60.                 stay that way *)
  61.              begin
  62.                 if FileName=Nil then GetTitle:='My editor [Untitled]'     
  63.                 else GetTitle:='My editor ['+FileName^ +']';
  64.              end;
  65.               
  66.              Procedure tMyWindow.SetFile (aNewFilename:String);
  67.              (* by convention an empty file would means New file *)
  68.              begin
  69.                If Filename<>Nil then DisposeStr(Filename);
  70.                Filename:=NewStr(aNewFilename);  (* =NIl if empty*)
  71.                Frame^.redraw
  72.              end;      
  73.  
  74. Hope it helps
  75. ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
  76. --------------------------------------------------------
  77. Dr Patrick L.Pollet
  78. Institut National des Sciences Appliquees
  79. Centre Informatique du 1er Cycle  Bat 110
  80. 20 Avenue A.Einstein
  81. 69621 Villeurbanne Cedex France
  82. --------------------------------------------------------
  83. Phone: 72 43 83 80 -   la premiere erreur c'est
  84. Fax  : 72 43 85 33 -   de se lever le matin  ... GASTON
  85. -------------------------------------------------------
  86.