CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Want to set "ES_MULTILINE" property of Edit object externally

  1. #1
    Join Date
    Sep 2005
    Posts
    63

    Want to set "ES_MULTILINE" property of Edit object externally

    Hi,
    I have One Edit Box on the dialog..
    I want to set its property ES_MULTILINE throught the code.
    I cannot change its properties straight way on dialog..
    It has to be done through code..
    Is there any option where I can create the Object and Subclass It to the Edit box on dialog?

    I mean something like..
    CEdit *My_Edit;
    My_Edit->Create(...,....ES_MULTILINE,...,...);
    and then subclass it with the Edit box I have on the dialog?
    If this is possible then What should I put in CRect and nID and parent
    parameters in Create method of CEdit?

  2. #2
    Join Date
    May 2005
    Location
    Oregon
    Posts
    3,725

    Lightbulb Re: Want to set "ES_MULTILINE" property of Edit object externally

    you can do it simply like

    Code:
    CEdit* pEdit = new CEdit; pEdit->Create(ES_MULTILINE | WS_CHILD | 
    WS_VISIBLE | WS_TABSTOP | WS_BORDER,	CRect(10, 10, 100, 100), 
    this, 1);
    or use ::SetWindowLong() to change the style of edit Control at run time

    in your rect specify the size of your control and id what ever you wann you can take 1,2 etc
    Last edited by humptydumpty; October 18th, 2005 at 07:02 AM.

  3. #3
    Join Date
    Sep 2002
    Location
    14 39'19.65"N / 121 1'44.34"E
    Posts
    9,815

    Re: Want to set "ES_MULTILINE" property of Edit object externally

    Quote Originally Posted by humptydumpty
    or use ::SetWindowLong() to change the style of edit Control at run time
    You don't need to use SetWindowLong() for that - ModifyStyle() would be much easier.
    However, ES_MULTILINE is one of those styles which can't be changed after the control has been created. To change it dynamically, you would need to destroy the control and create a new one with the ES_MULTILINE style set when you call Create().

  4. #4
    Join Date
    Jun 2021
    Posts
    2

    Re: Want to set "ES_MULTILINE" property of Edit object externally

    Quote Originally Posted by gstercken View Post
    You don't need to use SetWindowLong() for that - ModifyStyle() would be much easier.
    However, ES_MULTILINE is one of those styles which can't be changed after the control has been created. To change it dynamically, you would need to destroy the control and create a new one with the ES_MULTILINE style set when you call Create().
    Where did you get that info? I don't see it anywhere in the documentation.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,038

    Re: Want to set "ES_MULTILINE" property of Edit object externally

    Quote Originally Posted by sergiol View Post
    Where did you get that info? I don't see it anywhere in the documentation.
    https://docs.microsoft.com/en-us/win...control-styles
    https://docs.microsoft.com/en-us/cpp...60#modifystyle
    Victor Nijegorodov

  6. #6
    Join Date
    Jun 2021
    Posts
    2

    Re: Want to set "ES_MULTILINE" property of Edit object externally

    I was talking specifically about this part:

    Quote Originally Posted by gstercken View Post
    However, ES_MULTILINE is one of those styles which can't be changed after the control has been created.
    I had nowhere seen this stated.

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,038

    Re: Want to set "ES_MULTILINE" property of Edit object externally

    Quote Originally Posted by sergiol View Post
    I was talking specifically about this part:
    Quote Originally Posted by gstercken View Post
    You don't need to use SetWindowLong() for that - ModifyStyle() would be much easier.
    However, ES_MULTILINE is one of those styles which can't be changed after the control has been created. To change it dynamically, you would need to destroy the control and create a new one with the ES_MULTILINE style set when you call Create().
    I had nowhere seen this stated.
    Again: see the link I have posted! From https://docs.microsoft.com/en-us/win...control-styles
    Edit Control Styles
    05/31/2018


    To create an edit control using the CreateWindow or CreateWindowEx function, specify the EDIT class, appropriate window style constants, and a combination of the following edit control styles. After the control has been created, these styles cannot be modified, except as noted.
    ...
    ES_LOWERCASE
    Converts all characters to lowercase as they are typed into the edit control.
    To change this style after the control has been created, use SetWindowLong.
    ...
    ES_NUMBER
    Allows only digits to be entered into the edit control. Note that, even with this set, it is still possible to paste non-digits into the edit control.
    To change this style after the control has been created, use SetWindowLong.
    ...
    ES_OEMCONVERT
    Converts text entered in the edit control. The text is converted from the Windows character set to the OEM character set and then back to the Windows character set. This ensures proper character conversion when the application calls the CharToOem function to convert a Windows string in the edit control to OEM characters. This style is most useful for edit controls that contain file names that will be used on file systems that do not support Unicode.
    To change this style after the control has been created, use SetWindowLong.
    ...
    ES_UPPERCASE
    Converts all characters to uppercase as they are typed into the edit control.
    To change this style after the control has been created, use SetWindowLong.
    ES_WANTRETURN
    Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box's default push button. This style has no effect on a single-line edit control.
    To change this style after the control has been created, use SetWindowLong.
    As you can see the ES_MULTILINE style is NOT among those that can be changed with SetWindowLong after the control has been created.
    Victor Nijegorodov

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)