Thread: How to give a window a title.

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912

    How to give a window a title.

    I'm clueless when it comes to OWL (ObjectWindows Library), but I need to code for OWL pretty urgently. All I need to know, is how to give a window it's title (like what you would see in the blue bar at the top of your screen). I know you're not supposed to explect people to write your code for you, but I guess that's what's needed in this case - so if you do, just put a comment line in the code where I would put the code for the rest of my program.

    Thanks,
    Sean Mackrory.
    [email protected]

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Umm, you should be able to use:

    GetApplication()->GetMainWindow()->SetCaption("The new title");

    Just put this in any member fuction of some OWL object (probably code that is related to the button/whatever that you're using to trigger the title change.

    If you have the actual TWindow object of your main window, just do:

    theMainWindowObject->SetCaption("The caption");

    This is often used just after you create the main window object.

  3. #3
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post You can try this, too

    if you know the current caption, do this(The "Current Caption Here" is where you put YOUR window's current caption):

    HWND find;

    find = FindWindow(NULL, "Current Caption here");

    SetWindowText(find, "New Caption");

    As a matter o' fact, I made a program to do that for you. I will attach the program.
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    you realize that does nothing but add a string to a listbox, right?

  5. #5
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Post ummmm...

    It shouldn't unless I accid. put in the wrong one..sorry, I'll try again:
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  6. #6
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Question Sean..

    Is that what you were looking for?
    Website(s): http://www16.brinkster.com/trifaze/

    E-mail: [email protected]

    ---------------------------------
    C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
    DirectX Version: 9.0b
    DX SDK: DirectX 8.1 SDK

  7. #7
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Wouldn't you set the Window title (at the title bar) in the CreateWindow function? Yes, it would be the second parameter, right?

    I'm new to Windows programming, so excuse me if I'm wrong. I'm learning with Charles Petzold. It's great!

    --Garfield
    1978 Silver Anniversary Corvette

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    412
    Yes, but you often might want to change the title after creation (to reflect the file you have open, as one example).

  9. #9
    Registered User
    Join Date
    Nov 2001
    Posts
    18

    Talking ............

    SendMessage(wnd,WM_SETTEXT,0,(LPARAM)"text");
    SetWindowText(wnd,"text");

    very simple !
    What would this world be without some1 to break into your comuter or crack your software !????

  10. #10
    aurė entuluva! mithrandir's Avatar
    Join Date
    Aug 2001
    Posts
    1,209
    When you create your window, you should be able to name it like this (as Garfield mentioned).

    Code:
     // Creating the Window
     hwnd = CreateWindowEx(
            WS_EX_CLIENTEDGE, 
            g_szClassName,
            "The title of your window here",
            WS_OVERLAPPEDWINDOW,
            CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
            NULL, NULL, hInstance, NULL);
    >>Yes, but you often might want to change the title after creation (to reflect the file you have open, as one example).

    Good point.

  11. #11
    Programming is fun, mkay?
    Join Date
    Oct 2001
    Posts
    490

    Lightbulb Also, if you want to..

    If you want to change another window's title, and don't know its handle, you use:

    HWND find; //find can be anything for a handle

    find=FindWindow(NULL,"Title"); //Finds a window and sets a handle

    Then you do:

    SetWindowText(find,"NewTitle");

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. how i create a window whith all it's elements
    By rasheed in forum Windows Programming
    Replies: 1
    Last Post: 05-31-2006, 06:53 PM
  3. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  4. Title and Icon On Window
    By matth in forum C++ Programming
    Replies: 0
    Last Post: 03-21-2005, 03:53 PM
  5. opengl help
    By heat511 in forum Game Programming
    Replies: 4
    Last Post: 04-05-2004, 01:08 AM