Date parsed: 17/04/2008 22:44:05
Date: Fri, 18 Apr 2008 02:44:05 -0400
Hey Skid...
METHOD I.
It is a very simple concept in any language and you can provide many
different means for doing such; ie, even dynamically (allow the client to
change it / while the application is running). The text of the title bar is
simply the Text Property of the Form. Therefore, whatever language you are
using, simply set the Text property of the form upon any action, at any
time. For example (using VB and doing such dynamically):
1. From the calling procedure; Call the Sub as such:
Call ChangeFormTitle("The Form's Title Text")
2. Set the Text Property of the form to the passed argument in the sub
3. Then call this sub (as per the previous Call example) wherever and
whenever you desire, passing your desired title as the parameter
eg:
a. Upon form startup (in Sub New())
b. Upon a Button-Click on the form which has an associated text box for
the client to indicate the desired title.
Private Sub ChangeFormTitle(ByVal title As String)
Me.Text = title
End Sub
METHOD II.
For additional functionality you could even create an Event such that
you only need to
RaiseEvent and set a Field to the title value wherever you desire the Title
changed. ( I feel talkative tonight, hence am going a little overboard on
my reply (lol).) Here's how...
1. First, you have to remove the argument from the Sub that changes the
title. E.G: Change the previous sub as follows:
(the "fTitle" field will be explained next)
Private Sub ChangeFormTitle()
Me.Text = fTitle
End Sub
2. Then, to enable the functionality which matches passing the Title as
a parameter; create a module-level Field; as such:
Private fTitle as String = <your default value, if desired, else Nothing>
3. Then, at module-level of the form, declare the event as such:
Public Event ChangeTitle()
4. In the "Sub New" procedure indicate the Sub associated with the Event
(The Delagate) as follows:
Public Sub New()
AddHandler ChangeTitle, AddressOf ChangeFormTitle
End Sub
5. Now, anywhere you desire to have the Title changed, you only have to
do two lines of code:
a. Set the module-level field to the value you desire the title to
be
b. Raise the event / Fire the Event.
Anywhere in code (a Procedure); the following two lines are all that
are needed to change the title.
fTitle = "The Form's Title Text"
RaiseEvent ChangeTitle
Because you associated (via of the Delagate), which procedure is
invoked upon raising the event, the following, and previously written,
sub is called upon "RaiseEvent ChangeTitle"
Private Sub ChangeFormTitle()
Me.Text = fTitle
End Sub
In Summary, I have explained two methods by which you can change the Form's
Title (Text Property). If you desire more assistance, feel free to e-mail
me
the.boss@att.netGood Luck kand Have Fun!
"skidmarks" <skidmarks@discussions.microsoft.com> wrote in message
news:229845EC-96EB-40EA-9988-E2CEB48DA05A@microsoft.com...
> I'm trying to change the caption in an MDI Main Window title bar. I've
been
> able to change the resource (<name.rc> IDR_MAINFRAME) string but I can't
seem
> to find the magic to do it programmatically. I've tried 'SetWindowText' in
> '<APP>::InitInstance' and verified it with 'GetWindowText' but the caption
> doesn't change. Any way to do this?
>
> I haven't tried to change the caption for a child window but I would like
to
> do that also.
>
> (Being a real newbie if this isn't the correct forum I will gratefully
> accept redirection).
>
> skidmarks
"skidmarks" <skidmarks@discussions.microsoft.com> wrote in message
news:229845EC-96EB-40EA-9988-E2CEB48DA05A@microsoft.com...
> I'm trying to change the caption in an MDI Main Window title bar. I've
been
> able to change the resource (<name.rc> IDR_MAINFRAME) string but I can't
seem
> to find the magic to do it programmatically. I've tried 'SetWindowText' in
> '<APP>::InitInstance' and verified it with 'GetWindowText' but the caption
> doesn't change. Any way to do this?
>
> I haven't tried to change the caption for a child window but I would like
to
> do that also.
>
> (Being a real newbie if this isn't the correct forum I will gratefully
> accept redirection).
>
> skidmarks