Menu

#11 conversion of window text to std::(w)string?

win
open
nobody
New (13)
2
2006-12-19
2006-12-19
Jan Ringoš
No

Just came to this simple problem: I have a class and I need to initialize its members (std::strings) by values that user entered into edit controls. This is perfect candidate of if-I-find-clean-safe-and-smart-yet-simple-solution-I-will-add-it-to-ext-library problem ;-) ...well actually it will be win::whatever :-)

I know that some .title member vartor to some very generic win::window class (or template) would be really nice, but that way I would need to implement a large pile of stuff, so I am going to think about some simpler solution.

If you already have invented something, please let me know as right now I haven't came up with anything.

Discussion

  • Jan Ringoš

    Jan Ringoš - 2006-12-19
    • summary: Automated conversion of window text to std::(w)string? --> conversion of window text to std::(w)string?
     
  • Jan Ringoš

    Jan Ringoš - 2006-12-24

    Logged In: YES
    user_id=1590239
    Originator: YES

    std::string function_name (HWND hWnd) {
    std::vector <char> sz;

    sz.resize (GetWindowTextLengthA (hWnd) + 1);
    GetWindowTextA (hWnd, &sz [0], sz.size ());

    return std::string (&sz [0]);
    };

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.