Welcome Guest Search | Active Topics | Members | Log In | Register

Re: Changing Caption in Title Bar Options · View
KeithM
Posted: Wednesday, April 16, 2008 12:44:07 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 16/04/2008 12:44:07
Date: Wed, 16 Apr 2008 11:44:07 +0100

You probably want to be in a NG for the language you are using.
eg. microsoft.public.dotnet.languages.csharp , vb, etc.

But anyway, in C#, in the constructor for your main MDI window, possibly
called 'Form1' simply set the text property.

this.Text = "My New Title"

In your child windows, "Form2" perhaps, use the same trick in the
constructor.


"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


Glenn T. Kitchen
Posted: Thursday, April 17, 2008 3:26:42 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 17/04/2008 15:26:42
Date: Thu, 17 Apr 2008 19:26:42 -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.net

Good 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


Glenn T. Kitchen
Posted: Thursday, April 17, 2008 10:05:55 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 17/04/2008 22:05:55
Date: Fri, 18 Apr 2008 02:05:55 -0400


"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


Glenn T. Kitchen
Posted: Thursday, April 17, 2008 10:44:05 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
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.net

Good 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


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.070 seconds.