Results 1 to 8 of 8

Thread: window text

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    window text

    might sound stupid, but i am having problems writing a function that will change the text of a window, and return the previous text..the function is a member of my window class..so i know the handle from there

    PHP Code:
    char *set_text (char *text
    i dont know the size of the current text..i figured a way to do it using the new operator..but then i return the value and i cant use delete after return..
    thanks
    Amon Ra
    The Power of Learning.

  2. #2
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Use the STL string =).

    Z.

  3. #3

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    ok..i am gonna do it that way then..thanks a lot
    Amon Ra
    The Power of Learning.

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Or this way (if it's pure C):
    int set_text(const char *new_text, char *old_text, int old_size);

    The user passes the size of the buffer in old_size. If it's too small the function returns error.
    If old_text == NULL and new_text == NULL the function returns the size needed. If old_text == NULL but new_text != NULL the function doesn't return the old text.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    thats actually quite ingenious..thanks CornedBee
    Amon Ra
    The Power of Learning.

  6. #6

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    CornedBee, i have to compare GetWindowTextLength to old_size right?
    Amon Ra
    The Power of Learning.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Yes, that's the idea. And if both old_text and new_text are NULL, you return GetWindowTextLength()
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500
    thanks CornedBee
    Amon Ra
    The Power of Learning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width