How to set a default value in an Edit control

I am new to VC.  I need to set a default value to an Edit control which is
read-only.   How can I do that in a dialog?   I tried
my_Edit_Control.SetWindowText("mytest") in  it compiles successfully, but it
crashed at run-time.



bytj (9)
6/30/2003 8:52:20 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 32

Tony Hu wrote:

>I am new to VC.  I need to set a default value to an Edit control which is
>read-only.   How can I do that in a dialog?   I tried
>my_Edit_Control.SetWindowText("mytest") in  it compiles successfully, but it
>crashed at run-time.

The read-only property applies only to the user, not the programmer using
SeWindowText. You crashed probably because you made the call from your ctor,
or outside a dialog class member function, before calling DoModal(). In
either case, the CEdit object wasn't hooked up to the HWND. This binding
occurs in your derived dialog class's DoDataExchange override, when it calls
DDX_Control etc. This function (DoDataExchange) is first called by
UpdateData(FALSE), which is called by CDialog::OnInitDialog. So control
variables are safe to use after WM_INITDIALOG has been processed, or your
MyDlg::OnInitDialog override (if any) has called CDialog::OnInitDialog.
Before this time, and after DoModal has returned control to its caller,
control variables are off-limits. However, value variables can be used as
long as the dialog object exists. You can use ClassWizard to bind a CString
to your edit control, set it to _T("mytest") or whatever in your MyOlogy
ctor, and DDX will take care of the rest.

BTW, did you run a debug build? If I'm right, it should have asserted.

Doug Harrison
Microsoft MVP - Visual C++
dsh (2498)
6/30/2003 9:12:30 PM
Doug Harrison [MVP] wrote:

>You can use ClassWizard to bind a CString
>to your edit control, set it to _T("mytest") or whatever in your MyOlogy
>ctor, and DDX will take care of the rest.


See what a spellchecker run amok can do? :)

Doug Harrison
Microsoft MVP - Visual C++
dsh (2498)
6/30/2003 9:17:00 PM

Similar Artilces:

How do I set up an argument which asks for multiple criteria
I am trying to use an argument that asks for one of three criteria (2345P, 8319T, or 7026J) in cell C108, and if it finds it, enters the amount of yet another cell, G108 into cell K108, and if not enters 0 into cell K108. It seems there are too many arguments for the "if" argument, and I can't seem to get the "lookup" argument to work either. Is there another argument I should be working with? Thanks -- Diver Try: =IF(OR(C108="8319T",C108="2345P",C108="7026J"),G108,0) "bj" wrote: > try in K108 > =if(or(c108=&qu...

setting up new outlook mail account
i can not set up a new account on my outlook, i keep saying establish network connection with a correct sign but searching for my mail account shows X can you please advise Are you trying to setup a POP3 mail account or an Exchange account? Also, what version of Outlook are you using? "rashid" <> wrote in message > i can not set up a new account on my outlook, i keep saying establish > network > connection with a correct sign but searching for my mail account shows X > ...

Linked form can't be edited
I have a large table with contact details and also additional details which only relates to about a third of my clients. If I include all the fields in my main input form(1) it becomes very cluttered so I have created another form(2) for just the additional information and select it with a button from form(1). Form(2) is filtered according to the client in form(1). However even though I have enabled editing in the properties box, I am unable to edit the form(2) fields. Without the filter it works fine, but I have to find the client manually to add the additional information. What...

OWA Set Rule problem
I have successfully install the Exchange 2003 with SP1 in the Windows Server 2003. Anything alright exclude the rules function in OWA. I try to set the rules from any then "move to" or "copy to" specify folder are no problem, but "forward to" other email address, its don't work. I try to input the email address in the contact and then select from the contact, but the result also don't work. The rules can save and I can receive the incoming email in the Exchange 2003/Outlook or OWA, but it don't forward to my specify email address. I try to...

How do I set the 'Set Synchronizing Client' field
We have a number of outlook clients using CRM that have the 'Set Synchronizing Client' select box greyed out. We need to tick them so that they are able to synchronize tasks etc. Can any one help me find out why these are greyed out and then set them so that they can synchronize thanks In my experience, that checkbox is always greyed out for the first install that is performed for a user. The only time that checkbox becomes active is if a second copy of CRM is installed for a user who already has CRM installed on another PC.... Normally the box is checked and grey. If that is...

Formating text of x-axix value
I make a chart with x-axix values from let's say 1E-9 to 1E-3, using logaritmic scale. So far so good. But my need is not to display the values in the chart like 1E-9, 1E-8, etc. but like 10-9, where the -9 text will be formated as upper index. Thx for any help or suggestion. see best wishes -- Bernard V Liengme remove caps from email "Karel" <> wrote in message >I mak...

How to set backcolour
Hello All I have a continuous form containing a number field (long integer) called [v_colour]. This field contains the number of a certain colour - as per the numbers that are used in the format properties for back colour etc. I would like to set the back colour for the form's [v_colour] text box to be the value of the field: e.g. If the value of [v_colour] in the first record is 255, I want the back colour of the textbox for that record to be bright red. I tried this as the OnLoad event for the form: [v_colour].backcolour = [v_colour].value .... but this resulted in the back colour of...

Changing Default Recipient Policy
Can anyone please help me out and point out any risks that are involved in changing the Default Recipient Policy? What exactly are trying to accomplish? -- John Oliver, Jr MCSE, MCT, CCNA Exchange MVP 2007 Microsoft Certified Partner "Help" <> wrote in message > Can anyone please help me out and point out any risks that are involved in > changing the Default Recipient Policy? > Our default policy is @companyname.local and will not send NDR's externally. http://suppo...

Editing/Renaming a senders Email Address in the received message
Hello - I'm in a bit of a situation. I use a web processing cgi script that doesn't allow the senders address to be that of the email field on my web site's form - so any messages I receive processed through the web form have an email/reply-to address of FORMBUDDY (no- Now, with hundreds of forms in my inbox, I'd like to change the sender/reply to address manually, so that everytime I want to send an email to the individual/company who filled out the form, I don't have to cut and paste there email address in to the TO: field. Anotherwords,...

Applying Percent Decrease Across Set Periods
I have a column which includes dates when items were purchased. I have used the DATEDIF function to find the number of years between that date and today's date. I now want to decrease the purchase amount 10% for every year calculated via the DATEDIF function. Any ideas, is this possible, why can't I think...? -- Hunt&amp;Peck ------------------------------------------------------------------------ Hunt&amp;Peck's Profile: View this thread: ...

Set Regional Settings but not Language
Hi I have a multi-language APP en-US, es-ES, it-IT I usually change Languages and Locales by using the CultureInfo to switch Languages System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("es-ES"); My issue is - what if the user wants to View App in english and use the Regional Options on a PC in say Spain ??? If I change the CultureInfo to en-US then they can view APP in English ( English satelite assemblies) but date and numbers will be in US format If I change the CultureInfo to es-ES then date and numbers will be in Spain forma...

Active X control
Hi All, I am trying to make a dialog based ActiveX control in VC++ using MFC. I inserted buttons, radio buttons, and a FlexGrid control in this ActiveX. But when I run this control in a client application, the control disappears. If I remove Flexgrid, the control is displayed but when I press any button on this control, program hangs. Where is it that I might be going wrong? Would highly appreciate a solution or suggestion regarding this. TestHim wrote: > Hi All, > I am trying to make a dialog based ActiveX control in VC++ > using MFC. I inserted buttons, radio buttons, and ...

Work Hours setting excludes specified hours from Scheduling
I am miffed by this problem. I specify a work hour schedule for a user. When I schedule a CRM User as a Resource for a Service in Scheduling of a Service Activity with Requested Time of ASAP and click Find Available Times, the values for Avilable Times returned are outside of the Work Hours I specified for the user and not within the work hours. When I drill into the Work Hours for this User, the Calendar view shows Cross Day rather than 8:00AM - 5:00PM I speciied for work hours and editing the hours reveal the correct hours in the Work Hours. What gives? Never mind. Figured out w...

Reading Pane Settings
I did a search for an answer to this question and have not found one. If I missed an answer already posted, please direct me to the right place. I have Outlook 2007 and set up the "right" reading pane for my e-mail. Now when I go to my calendar it is set up the same way - calendar on the left (same size as the inbox) and then there is a blank space to the right that is the size of the reading pane/preview. To the right is the to-do bar (which I have no problem with). I don't know why there is a reading/preview pane on the calendar when there is nothing to preview, and I...

Outlook "Arrange By" option does not retain its setting
In outlook 2007, I use a custom view for my inbox, and I have the Group By option checked to"Automatically group according to arrangement." This has been workn flawlessly until today, when I realized Outlook did not like a particular mouse click; perhaps I clicked on the border of two options or some other anomoly that caused the window toflash once. The end result was that my Arrange By option changed to "From" when I had previously set it to "Conversation." Now, whenever I hange it backto "Conversation," leave the inbox and come back, ...

Need to sum values that are not strikethroughs
I need to sum a column without it adding the rows that have strikethroughs values; is it possible to combine a formula and vb code to a cell ? =SUM(BH100:BH120) & Activecell.selection.font.strikethrough = false Thank you Khf Try: Function zum(r As Range) As Double Dim rr As Range For Each rr In r If rr.Font.Strikethrough = False Then zum = zum + rr.Value End If Next End Function In the worksheet use it like: =zum(A1:A10) -- Gary''s Student "Rock" wrote: > I need to sum a column without it adding the rows that have strikethroughs > values; i...

How do I set OOR
I have searched the help menu and have had no luck finding out how to set my outlook 200 to send an OOR (Out of Office Reply) Any assistance would be great If you are in an Exchange environment (ask your administrator if you do notknow) you can set the Out of the Office Assistant which is located under Tools. If you are not in an Exchange environment you can create a rule that replies on all e-mails. The downside of this is that you'll have to have your Outlook open all the time for the rules to process. Make sure you set some exceptions (for instance based on the subject field so ...

Opening to a default tab?
Hello, Is there a way to get a workbook to default to a certain tab when opening the file? I noticed that it opens to whatever page was open when last saved but I want it to always open to the first sheet regardless. Any ideas? Thank you in advance, Joe Use the Workbook_open event in ThisWorkbook module or an auto_open macro in a regular module sub auto_open() sheets("mysheet").select end sub -- Don Guillett SalesAid Software "Joe" <> wrote in message news:eZpp9EUKEHA.1312@TK2MSFTNGP12.phx.gbl... > Hello, > > Is there a wa...

interactive buttons, multiple sets
hi folks I'm sure one of you good folks will save my bacon as usual I have a series of websites, all of which exhibit the same odd behavior with interactive buttons. I have a bunch of buttons in the left margin, each of which pulls up ( lets call it ) a chapter, and in each 'chapter' are a number of related pages. On the top of each page is an imbedded page which has 'page numbers' for all the 'pages' in that chapter. So, it's a grid where the 'vertical' buttons in the left margin and the 'horizontal' buttons at the top comb...

Set Focus
I have text box that I input data into and I was wondering if it is possible to set focus to the text box and avoid clicking on the box. I thought the term is Set Focus, but can't find any information or example that would help in doing so. Any help would be appreciated .. PPT 2003. Look at the following page for code to set focus on a text box: - Chirag PowerShow - View multiple PowerPoint slide shows simultaneously "Phil K" <PhilK@discussions.microsof...

outlook 2003 resetting default folders
After following a tutorial on customizing personal folders in Outlook 2003, I changed the settings. After living with it for a few hours, I decided to move all my email back into the inbox and delete the personal folders and rules I set earlier. Now I can't view any of my emails. I can see that there's unread emails ny the number in the parentheses, but I can't view them. Please tell me how to get my outlook back to the default settings. TIA, Sophia Solved the problem. There's a tool w/in the program called "scanpst.exe". It must be run with outlook closed....

Set published amount of calendar information
Hey guys! Is there any way I can have Exchange 2000/2003 force the amount of time published in the outlook calendar? I know that you can go into the the calendar options and set the amount you want published, but is there a way to have exchange require the amount that is published so that I could get everyone to publish a year's worth of calendar data instead of one person being set at 2 months and another at 6 months and another at 12? Thanks! Mike On Thu, 29 Jun 2006 06:18:02 -0700, Mike <> wrote: >Hey guys! > >Is there any way I c...

Publisher 2003 Need to set business card to Avery 5371 setting
I need to set the print settings so the business cardd that I created will print on Avery 5371 business cards Okay.........and your question is? -- JoAnn Paules MVP Microsoft [Publisher] "Jonathan" <Jonathan> wrote in message >I need to set the print settings so the business cardd that I created will > print on Avery 5371 business cards Page setup, business cards, click change copies per sheet, type > .5 top, .75 side, zero gaps. Avery 5371 is a standard business card s...

moving values from sheet to another
I would like to know if it is possible to create a formula on one shee (sheet 2) and copy that resulting value to another sheet (main sheet) So when I make changes to the formula on sheet 2 it will update on th main sheet and be used in another formula on that sheet (main sheet) Is this possible? Thank you. :) : -- makdaddy92 ----------------------------------------------------------------------- makdaddy925's Profile: View this thread: On the main sheet in the ce...

Setting the Settings
Really quickly: How (exactly) does one get Publisher to remember the page settings I want. ie. every time I open a new document, I get centimeters, and usually, I'd prefer inches. I have not been able to find a "Save Settings" option anywhere. Can anyone help? thomas In Publisher 2000 it's Tools Options General tab Measurements unit box - select inches. OK That should do it. -- Don -------- Vancouver, USA - One of the great cities in one of the 45+ countries in America! "ThomasL" <> wrote in message ne...