home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.pascal:8382 comp.os.ms-windows.programmer.misc:5215
- Path: sparky!uunet!think.com!rpi!ghost.dsi.unimi.it!insa-lyon.fr!pc110-02.insa-lyon.fr!ppollet
- From: ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
- Newsgroups: comp.lang.pascal,comp.os.ms-windows.programmer.misc
- Subject: Re: Give window a caption
- Date: Thu, 21 Jan 1993 08:40:34 GMT
- Organization: INSA CENTRE INFORMATIQUE DU 1er CYCLE
- Lines: 73
- Message-ID: <ppollet.169.727605634@cismibm.univ-lyon1.fr>
- References: <C15rpJ.Izy@cs.vu.nl>
- NNTP-Posting-Host: pc110-02.insa-lyon.fr
-
- In article <C15rpJ.Izy@cs.vu.nl> martijn@cs.vu.nl (Lemmens ML) writes:
- >From: martijn@cs.vu.nl (Lemmens ML)
- >Subject: Give window a caption
- >Date: 20 Jan 93 15:15:18 GMT
-
-
- >I have created a window (TWindow) with Borland Pascal 7.0 without
- >a caption. While the program is running I want to change the looks of
- >the window and give it a caption. Is this possible without destroing
- >the window and creating a new one?
-
- >Martijn
-
- in TurboVision or OWL?
-
- In OWL I think there is something called SetWindowText(Handle,NewText)
- that is actually a Window API call ? (no experience on that)
-
- In Tvision you could:
-
- 1. Change the Title of the Window by
- With ThatWindow^ do
- begin
- If Title<>Nil then DisposeStr(Title);
- (* Title is a field of the tWindow Object *)
- Title:=NewStr(TheNewTitle);
- Frame^.redraw; (*faster that full redraw*)
- end
-
- 2. Overload its method GetTitle so that at every redraw, the
- Window redraw method will "recalculate" its new caption:
-
- let's suppose you have an editor Window that should holds
- the name of the File that is being edited or "Untitled" if
- it is a new file
- you could have :
-
- type tMyWindow=object(tWindow)
- FileName:pString; (* WILL BE NIL AT THE CONSTRUCTION*)
- ......
- Function GetTitle(maxSize:integer):tTitleStr;VIRTUAL;
- Procedure SetFile(aNewFilename:String);
- ......
- end;
-
- function TMyWindow.GetTitle(maxSize:Integer):tTitleStr;
- (* don't use Title that is NIl from the constructor and
- stay that way *)
- begin
- if FileName=Nil then GetTitle:='My editor [Untitled]'
- else GetTitle:='My editor ['+FileName^ +']';
- end;
-
- Procedure tMyWindow.SetFile (aNewFilename:String);
- (* by convention an empty file would means New file *)
- begin
- If Filename<>Nil then DisposeStr(Filename);
- Filename:=NewStr(aNewFilename); (* =NIl if empty*)
- Frame^.redraw
- end;
-
- Hope it helps
- ppollet@cismibm.univ-lyon1.fr (Patrick POLLET)
- --------------------------------------------------------
- Dr Patrick L.Pollet
- Institut National des Sciences Appliquees
- Centre Informatique du 1er Cycle Bat 110
- 20 Avenue A.Einstein
- 69621 Villeurbanne Cedex France
- --------------------------------------------------------
- Phone: 72 43 83 80 - la premiere erreur c'est
- Fax : 72 43 85 33 - de se lever le matin ... GASTON
- -------------------------------------------------------
-