Win32 CreateWindowEx

This is a discussion on Win32 CreateWindowEx within the Windows Programming forums, part of the Platform Specific Boards category; ok in the following code section Question Below Code) PHP Code: VAR_NAME  =  CreateWindowEx  ( 3 , TEXT ( "EDIT" ...

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    673

    Question Win32 CreateWindowEx

    ok in the following code sectionQuestion Below Code)

    PHP Code:
    VAR_NAME CreateWindowEx (
    3,
    TEXT("EDIT"),
    NULL,
    WS_CHILD|WS_MULTILINE|ES_AUTOVSCROLL|WS_BORDER|WS_VISIBLE|ES_READONLY,
    -
    2,
    -
    2,
    400,
    150,
    hwnd,
    NULL,
    hThisInstance,
    NULL
    ); 
    You most likely noticed that ES_READONLY was bold and underlined. This brings me to my question. When I dont use ES_READONLY in a "EDIT" it has white background, but when I do use ES_READONLY it has a grey background. Is there any way to use ES_READONLY, and remain with a white background.

    Question 2:
    I have searched forever on MSDN (must not be using right keywords), but how do I output a string variable or a Int variable to my window. I looked on MSDN under SetWindowText();, DrawText(), and TextOut(), but sadly to no avail

    Any answers will be greatly appreciated.

  2. #2
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Ok, I think I may have figured it out.. so correct my if im wrong please,

    Code:
    char buf1[50] = "HAHAHAAHAHA";
    
    SetWindowText(hEDIT, buf1);
    EDIT: ARG... now I cant figure out how to get the text from a text box in a char[] array, any help on a function o look up or even a code sample of how to do it... I was trying to use WM_GETTEXT but I cant figure out how to properly use syntax ( if it is even what I need ) I am reading about different text function on MSDN right now I will update if I figure it out, but post your ideas anyways ( never hurts to know more than one way to do something)
    Last edited by Raigne; 06-27-2006 at 06:00 AM.

  3. #3
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    >>Is there any way to use ES_READONLY, and remain with a white background.<<

    You could handle the parent's WM_CTLCOLORSTATIC message and return a brush handle (HBRUSH) corresponding to the control's active background colour. Use GetSysColor to get the system colour corresponding to the edit control's default background, and use that colour with CreateSolidBrush to generate a brush handle (do it once only). When you're done with the brush, you must free system resources used by it with DeleteObject. Search this board as this has been asked and answered often in the past. You should be cautious about doing this, though, as users will have certain expectations regarding the default behaviour of controls; if they see an edit control with a normal background they will expect to edit text within it.

    Use GetWindowTextLength to determine the size of array(or, possibly, std::vector if using c++) needed and allocate memory accordingly then use GetWindowText to fill that array with a copy of the control's text.

    If you have problems with either of these then post your code and we'll proceed from there.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  4. #4
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    Does setting up pointer (allocating memory) really matter if the program is only going to hold a small amount of data? I am using the GetWindowText function now, but yet another problem arises. SetWindowText, resets the output stream for the designated control then outputs a new stream. Is there a way to output a stream into a control and then go to next line of control and wait for next output? ( what I am trying to create is a message log ) to save messages transferred from different areas of my app.

    I am actually trying to create a Text RPG using a WIN32 GUI, and I know how to do everything except for the I/O stuff ( lol std::cin and std::cout were so much easier)

  5. #5
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    If you know in advance the length of the edit control's content and that is fixed, then you can just use a normal array or std::vector if you want, provided it's big enough to accomodate the text.

    For the second issue, perhaps this thread may be of some use.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  6. #6
    Registered User
    Join Date
    Nov 2005
    Posts
    673
    that was a life saver, and sorry for new thread but, when I looked at some of those functions on MSDN it seemed like they did something else. But thanks a ton.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  2. Win32 API or Win32 SDK?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 07-20-2005, 04:26 PM
  3. OLE Clipboard :: Win32 API vs. MFC
    By kuphryn in forum Windows Programming
    Replies: 3
    Last Post: 08-11-2002, 06:57 PM
  4. win32 Winsock problem
    By spoon_ in forum Windows Programming
    Replies: 3
    Last Post: 07-19-2002, 02:19 AM
  5. Win32 API Tutorials?
    By c++_n00b in forum C++ Programming
    Replies: 9
    Last Post: 05-09-2002, 04:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21