Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305881
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:13:02+00:00 2026-06-08T18:13:02+00:00

I am making a program in win32 c using visual studio rc and I

  • 0

I am making a program in win32 c using visual studio rc and I can’t figure out how to do this seemingly simple task. I have a static text control, an edit control, and a button. When the user clicks the button, I wan’t the program to take the text in the edit control and add it to whatever is in the static text box. After much headache and various attempts, I still cannot get this to work. I can retrieve the text from the edit control fine, but any attempt to add it to the static control crashes. Well actually just to clarify, I can set the text fine; it’s just adding to the existing text that crashes the program. Could someone please post some code that would allow me to do this using GetWindowText() and SetWindowText(), (or something else if it preferable). Here is what I have:

SendMessage(hwndEditControl, WM_GETTEXT,255,(LPARAM)editbuffer);
GetWindowText(hwndTextControl, (LPWSTR)allText, GetWindowTextLength(hwndTextControl));
//function to add data, please create on
SetWindowText(hwndTextControl, (LPCWSTR)allText);}
//where
static TCHAR*       editbuffer = new TCHAR; //feel free to change these declarations
static TCHAR*       allText    = new TCHAR;

Any help much appreciated! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:13:03+00:00Added an answer on June 8, 2026 at 6:13 pm

    You’re only reserving one char for your string buffers. So instead of

    static TCHAR*       editbuffer = new TCHAR;
    static TCHAR*       allText    = new TCHAR;
    

    you have to reserve much more memory, e.g.:

    static TCHAR*       editbuffer = new TCHAR[255];
    static TCHAR*       allText    = new TCHAR[255];
    

    which would give you string buffers that can hold 254 chars and the terminating null char.

    However I would recommend that you simply reserve the memory on the stack inside your function:

    void OnButtonClick()
    {
        TCHAR editbuffer[255] = {0};
        TCHAR allText[255] = {0};
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a win32 application using visual studio 2008. When ever i compile
In an OpenGL win32 program developed in Visual Studio C++ 2010, the debug version
I'm making a win32 program in C. When you have multiple threads running, and
While making my program i have come across this requirement that i have to
I'm making a program using Seam and Java. On my web page I have
I am using the cool map making program DIY map and i want to
Im making a program for class that manages a Hotel. I have a function
I'm making a program on the HUFFMAN ALGORITHM where I have one class of
I am making a program for handheld PDAs using .net 2.0 compact framework and
Im making a program using Java for android. I'm drawing alot of rectangles on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.