Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
tools
vsnet.act
vsnet.debugging
vsnet.documentation
vsnet.enterprise.tools
vsnet.general
vsnet.ide
vsnet.jlca
vsnet.servicepacks
vsnet.setup
vsnet.vsip
vsnet.vss
vsnet.vstools.office
vstudio.development
vstudio.extensibility
vstudio.general
vstudio.helpauthoring
vstudio.setup
vstudio.sourcesafe
  
 
date: Tue, 15 Apr 2008 09:42:00 -0700,    group: microsoft.public.vstudio.development        back       


Changing Caption in Title Bar   
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
date: Tue, 15 Apr 2008 09:42:00 -0700   author:   skidmarks

Re: Changing Caption in Title Bar   
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"  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
date: Wed, 16 Apr 2008 11:44:07 +0100   author:   KeithM am

Re: Changing Caption in Title Bar   
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"  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
date: Thu, 17 Apr 2008 19:26:42 -0400   author:   Glenn T. Kitchen

Re: Changing Caption in Title Bar   
"skidmarks"  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
date: Fri, 18 Apr 2008 02:05:55 -0400   author:   Glenn T. Kitchen

Re: Changing Caption in Title Bar   
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"  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"  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
date: Fri, 18 Apr 2008 02:44:05 -0400   author:   Glenn T. Kitchen

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us