?
Solved

Changing the Style of an Edit Control in Run-time!

Posted on 2000-05-01
4
Medium Priority
?
346 Views
Last Modified: 2013-11-20
The application is a MFC dialog based one. In run-time, I need to change the style of an edit control from ES_LEFT to ES_CENTER! What function should I use to do it?
Thank you!
Jim
0
Comment
Question by:nkhbeik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 1

Expert Comment

by:RAVID
ID: 2768068
Hi,

To modify the syle from ES_LEFT to ES_CENTER use the function

m_edit.ModifyStyleEx(ES_LEFT,ES_CENTER,0);

Here m_edit is the member variable of the edit box whose style has to be changed.

Hope this helps u

Regards...
0
 
LVL 2

Expert Comment

by:vbk_bgm
ID: 2768512
Use ModifyStyle instead of ModifyStyleEx
(which is for extended window styles)
m_edit.ModifyStyle(ES_LEFT,ES_CENTER,0)
0
 
LVL 5

Expert Comment

by:proskig
ID: 2768583
Frankly speaking, do not think that any of these approaches will work. There are some styles which you cannot change dynamically, you can only assign it upon creation. I think there was an message from Mike Blaszczak about it even at this site, saying that for alignment window checks this style on creation and fills up internal structures appropriately and you cannot change it during runtime. What you can do is to create two controls with central and left alignment and show/hide them when necessary, you also have to synchronize their content.
0
 

Accepted Solution

by:
bthomsen earned 40 total points
ID: 2781166
If you know which type of dialog you will need when creating the dialog, then you can create two separate versions of the dialog in the resource file, one with the edit control set to ES_LEFT, and the other with the edit control set to ES_CENTER.  For the constructor function in the dialog's support class, pass the CDialog constructor the resource ID of the appropriate dialog (instead of the enum IDD) for its first argument.

You could also use this technique after the dialog is up and running, but it would involve saving the state information for the dialog, closing that dialog, creating a new dialog using the different resource ID, and adjusting the position, edit controls values, and focus of this new dialog.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 6 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question