Getting value from edit control?

How do I get the value from an edit control into its value CString variable?

Also, how do I convert from CString to char* ? 


0
si1 (22)
11/12/2005 10:57:34 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
759 Views

Similar Articles

[PageSpeed] 5

CString has an overload for LPCTSTR (which depends on whether you are 
compiled for Unicode or MBCS) so you can pass it pretty easily.  If you need 
to access the buffer directly CString::GetBuffer() returns the pointer to 
the buffer. Call ReleaseBuffer() when you are done using that point (if you 
modify it).

To assign and retrieve values with the edit control you should create a 
variable for the control and use UpdateData().  Open the dialog and right 
click on the Edit control to find the selections to either hook messages or 
assign variables to controls.

Tom

"Si" <si@hotmail.com> wrote in message 
news:yrudf.14671$Cq4.9526@newsfe7-gui.ntli.net...
> How do I get the value from an edit control into its value CString 
> variable?
>
> Also, how do I convert from CString to char* ?
> 


0
tserface (3861)
11/12/2005 11:29:09 PM
"Si" <si@hotmail.com> schrieb im Newsbeitrag 
news:yrudf.14671$Cq4.9526@newsfe7-gui.ntli.net...
> How do I get the value from an edit control into its value CString 
> variable?

If an edit control is bound to a CString variable (or any other type of 
variable) use UpdateData(TRUE) to copy all input into the corresponding 
variables. To update controls after changing some variables, use 
UpdateData(FALSE).

> Also, how do I convert from CString to char* ?

When you are not compiling your app for unicode you can simply assign to a 
variable of type 'char const*' or pass a CString where a 'char const*' is 
expected. You can also use static_cast<char const'>() to get the address of 
the first character of a string. If you really need a 'char*' use GetBuffer 
and ReleaseBuffer. When you are compiling for unicode, you can use a CString 
wherever a 'wchar_t const*' is expected, and you can use 
GetBuffer/ReleaseBuffer when you need a 'wchar_t*'. But read the docs of 
CString carefully. Pointers obtained by (explicit or implicit) casting may 
become invalid when you modify the CString variable.

If you have to convert a unicode CString to a sequence of char's you have to 
use some function like WideCharToMultiByte to translate each character.

HTH
    Heinz 


0
hozwirk.SPAM (112)
11/12/2005 11:30:16 PM
ASSERT_VALID(pEditControl);
CString strControlText;
pEditControl->GetWindowText(strControlText);

To convert to a char *,  you can use operator LPCTSTR, which will
convert to TCHAR. For MBCS builds, TCHAR is same as char. For UNICODE,
you can use T2A conversion. I am guessing you have MBCS build.


--------
Ajay Kalra
ajaykalra@yahoo.com

0
ajaykalra (6842)
11/12/2005 11:39:26 PM
Reply:

Similar Artilces:

How to get 5 digit accuracy beyond the decimal point.
A currency has 4 digit accuracy. I need 5 digit. I am using Access 2003. You can't use Currency, then, since that's a hard-and-fast limit of the Currency type. Try using the Decimal type. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "tom" <Spamblocker@ameritech.net> wrote in message news:afg9i.12785$2v1.2433@newssvr14.news.prodigy.net... >A currency has 4 digit accuracy. I need 5 digit. > > I am using Access 2003. > ...

HELP! I can't go to my desktop, much less get online
I kept losing my connection on my WiFi laptop, so I tried repairing the connection by right clicking the icon. Now when I start my pc it presents me with a place to type a password-and I never have set a password to get into my computer. How do I avoid this because it is my computer and I'd like to use it. My system is Windows XP, IE8.-Thank nYou for your help, I'm typing this on someone elses computer. James Moore Larry wrote: > I kept losing my connection on my WiFi laptop, so I tried repairing > the connection by right clicking the icon. Now when I start my pc it ...

Changing color of a range of cells dending up on a value in anothr
Hi, I need to change the color of a range of cell, depending up on the value in another cell. I am using Excel 2003. And it allows me to give only 3 conditions when using conditional format. But I have 7 differnt conditions. Thanks in advance for any help. Srajes. Unless you move to XL2007, you will need to use VBA. Here are some sites that will help http://www.ozgrid.com/VBA/excel-conditional-formatting-limit.htm http://www.mvps.org/dmcritchie/excel/condfmt.htm Alternatively, there is an add-in here http://www.xldynamic.com/source/xld.CFPlus.Download.html -- Steve "Srajes&qu...

Can't Get CRM 3.0 Reports To Work
In the readme file that comes with server installation in the early access program it mentions under Known Issues: ************************************************ Microsoft CRM Server Privileges Required for Installing Microsoft CRM and Using an Existing Microsoft SQL Server Reporting Services Server The user installing Microsoft CRM and connecting to an existing Microsoft SQL 2000 Server Reporting Services Server must have as a minimum the Content Manager Role privileges at the Root Folder Level, and System Administrator privileges at the Site Wide Setting Level. ***********************...

Ending balance doesn't equal market value
I am using MS Money 2004. In my portfolio the Contributions ($) Market Value amount is showing a negative amount, but Today's Balance shows a zero Ending Balance. How do I get them to both show tha same number? In microsoft.public.money, Eggman wrote: >I am using MS Money 2004. In my portfolio the Contributions ($) Market Value >amount is showing a negative amount, but Today's Balance shows a zero Ending >Balance. How do I get them to both show tha same number? Try File->RepairMoneyFile->QuickFileRepair Look for future transactions. ...

HOw do I get my sent items to appear on the day that I send them
How do I get my sent items to appear on the day that I send them. How do they appear now? Are you filtering your view of your Sent Items folder? -- Kathleen Orland "celeste" <celeste@discussions.microsoft.com> wrote in message news:8A277EB9-348B-4504-9B06-EB552DA44362@microsoft.com... > How do I get my sent items to appear on the day that I send them. > ...

Lowest value in a selection of data
Hi What formula would I use to find the lowest value in a selection of data i.e. B49:E52. Much Appreciated Brian =MIN(B49:E52) -- Gary''s Student - gsnu2007a Jumping in here... Is it possible to know the address of the cell containing the minimum value? John. You can use the MATCH function to locate the (relative) position, but if you have more than one value which are minima then it will only find the first. Pete On Nov 16, 7:23 pm, John Google <JohnGoo...@hotmail.co.uk> wrote: > Jumping in here... > > Is it possible to know the address of the cell containin...

Exchange 2003 server is a domain controller
Exchange 2003 on Win 2k Ent, 2 other DCs running Win 2003, single domain. The previous admin here made the exchange box a domain contoller. It's having some DNS problems looking for an old DC that doesn't exist anymore, log in issues etc. I'd like for it not to be a DC at all. The problem is that when I demote it from being a DC, no mail flows at all and OWC connections quit. Can someone explain to me why mail stops and what needs to happen for me to fix this? This is my last Win 2k box and I'm leary of trying to upgrade it in it's current condition. On Thu, 8 F...

WM_COPY message not being passed to controls deriving from CEdit within an ActiveX control
Hi, As stated in the subject, I have some custom edit controls classes in an ActiveX control. I can enter text and interact with the edit controls without any problems except in the case when I try to Copy/Paste/Cut/Clear through the key shortcuts Ctrl-C/V/X/B. Nothing happens when I press those key shortcuts, because the control itself never receives a WM_COPY/WM_PASTE/WM_CUT/WM_CLEAR message. Does anyone have any idea why these windows messages would be filtered out or simply not sent by the parent? Is there a more elegant solution that to override the OnKeyDown handler of the parent wind...

How to get full directory path from SHBrowseForFolder()
Does anyone know how to get the full directory path from the return value of SHBrowseForFolder()? Thanks, Ivan hi did you tried the code i posted earlier.. esle find here hi try the following snippet code BROWSEINFO binfo; char szFolder[MAX_PATH]; CString csCaption; csCaption="Select Destination folder "; memset(&binfo,0,sizeof(binfo)); binfo.hwndOwner=m_hWnd; binfo.pszDisplayName=szFolder; binfo.lpszTitle=csCaption; binfo.ulFlags=BIF_RETURNONLYFSDIRS; LPITEMIDLIST pidl=SHBrowseForFolder (&binfo); int iRet=SHGetPathFromIDList(pidl,szFolder); // The varibal...

Adding Values From Different Tabs
Is there a way to add values from different tabs on the same spreadsheet? For example A2 from tab 1 and A2 from tab 2 -- Flipkid2 ------------------------------------------------------------------------ Flipkid2's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=17984 View this thread: http://www.excelforum.com/showthread.php?threadid=398184 Assuming the name on Tab 1 is Sheet1 and Tab 2 is Sheet2, use thi formula: =Sheet1!A2+Sheet2!A2 note the name of the sheet is followed by "!" to indicate it is a shee name. HTH Bruc -- swatsp0 ------------...

Display only duplicate values and delete UNIQUE Items
All I have a very large list of data and on a monthly basis i need to display only the duplicate items in a spreadsheet. I would like to do this in VBA and then run it as a macro on the spreadsheet. Alot of the sites that i have seen only show how to removed the duplicates. Excel 2007 has a function which removed all duplicates but so far i have found nothing that only displays the duplciates.... any ideas anyone? Assuming that the field you use to determine uniqueness is column A, you can put this formula in a helper column: =3DIF(COUNTIF(A:A,A2)>1,"Duplicate","Unique&...

Using mail merge for nametags, how'd you get 8 diff. on each pg?
How do I print off a different name on each name tag in order to print them out a page at a time? I entered the names in mail merge and it will print them, just a whole page of each. Thanks "juliehrbacek" wrote: > How do I print off a different name on each name tag in order to print them > out a page at a time? I entered the names in mail merge and it will print > them, just a whole page of each. > > Thanks This is the same question that has brought me here. I've been trying to figure it out for over 2 hours now and am about ready to pull my hair ou...

2003 exchange standard edition
I have a 2003 domain controller with exchange 2003/one storage group/store. I want to setup a mailbox management policy to manage the users folders. I have done this before with enterprise edition but a different way than I am trying now. I setup the policy to find any exchange user with the word 'Limits' set as their number 1 extened attribute. When I setup the policy the find now feature finds my one test user but when I run mailbox management it runs against everyone on that server/store. In the policy I did not specify a server/storeage group. And when I test the policy it fi...

Getting Reminders when Outlook is not started
I love the remnder feature of Outlook, but If Outlook isn't started, then I never see my reminders. Is there a way, or utility that will allow my reminders to pop up even if Outlook has not started? Thanks in advanced! Chaz Xaos <chazperx@yahoo.com> wrote: > I love the remnder feature of Outlook, but If Outlook isn't started, > then I never see my reminders. Is there a way, or utility that will > allow my reminders to pop up even if Outlook has not started? I don't know of any program that will perform is job when it's not running, do you? -- Brian Tillm...

How many screen pixels get rolled when rotating mouse wheel?
Does anyone know how to determine the vertical distance (pixels) scrolled by each rotation of mouse wheel on any scrollable client window? Rob "Rob" <xiwenm@hotmail.com> wrote in message news:1139327086.880141.44320@f14g2000cwb.googlegroups.com... > Does anyone know how to determine the vertical distance (pixels) > scrolled by each rotation of mouse wheel on any scrollable client > window? http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/aboutmouseinput.asp You will have to convert from lines ...

[more of a 'c' question really] Converting doubles to strings without getting scientific notation
Hello hello.. I'm using _gcvt in a dialog to display a double, but when it gets small the string appears in scientific notation ie 0.02 become 2e-02 Is there another conversion routine I can use to prevent this? I have a not terribly scientific customer who would prefer a straight forward decimal display. Thanks "Zardoz" <thing@thing.thing> wrote in message news:122lvvkvicks85nka58iugok64ba0plpem@4ax.com... > Hello hello.. > > > I'm using _gcvt in a dialog to display a double, but when it gets > small the string appears in scientific notation ...

Exclude like values with a JOIN?
I have the following query: SELECT dbo.qry_UV_CARS_PlateX_ShouldBeValued.Yl_iD FROM dbo.qry_UV_CARS_PlateX_Valued RIGHT OUTER JOIN dbo.qry_UV_CARS_PlateX_ShouldBeValued ON dbo.qry_UV_CARS_PlateX_Valued.Yl_iD = dbo.qry_UV_CARS_PlateX_ShouldBeValued.Yl_iD WHERE (dbo.qry_UV_CARS_PlateX_Valued.Yl_iD IS NULL) And I have another secondary table containing the same field as Yl_iD. What I want to do is have my main query exclude all the Yl_iD values that are in my secondary table. What JOIN and criteria will do this? Many thanks.....Jason WHERE Yl_iD N...

increment a value by 1
How do I increment, automatically, a cell by 1 if a condition is met? If one of my cells reaches 10k I want another cell to increment by 1. Can anyone help me if this function can be done? Thank you, Ron Do you want the increment only when it changes from below 10K to above 10K, or anytime is is above 10K? -- Gary's Student "Workshops" wrote: > How do I increment, automatically, a cell by 1 if a condition is met? If one > of my cells reaches 10k I want another cell to increment by 1. Can anyone > help me if this function can be done? > Thank you, Ron Increm...

Extended CFileDialog and OCX-Controls
I want to extend the CFileDialog by some additional controls. All works fine with standard controls. But after add an OCX-Control the file dialog not appear. Inside DoModal the call ::GetOpenFileName(&m_ofn) have no effect. Anny ideas? Thank you Arnold It is not clear that OCX controls are supported, because the dialog template is not instantiated by MFC. OCX controls work in MFC dialogs because there is massive amounts of code in the MFC dialog-creation code to make this work. But the CFileDialog most likely does a ::CreateDialog call directly, so it can't work. I would suggest ...

Money 2005: Can't Get Support
I tried to open an on-line ticket for the upgrade problems I am having (2004-->2005), but the Microsoft site says "The Product ID number you entered is not supported in the country that you have selected. You may go back and choose another country or enter another Product ID number." I'm in the US. I selected "United States" and I purchased by d/l direct from Microsoft. BTW: Trying to report: 1) Cannot restore a backup unless I am connected to the internet. 2) When I started 2005, it converted from 2004 but lost quite a few transactions. 3) The first time the s/...

multiply value based on quantity
I am trying to calculate a discount price based on quantity purchased. For example if someone buys 20 widgets they pay $4.00 each for them, if they buy 50 widgets they pay $4.00 each for the first 20, then $3.50 each for the next 30, 100 widgets - $4.00 first 20, $3.50 next 30 and $3.25 for the other 50.............. Any hope? Here's a way with quantity in A2: =MIN(A2,20)*4+MAX(MIN(A2-20,30),0)*3.5+MAX(MIN(A2-50,50),0)*3.25 Regards, Per "Bigfoot3910" <Bigfoot3910@discussions.microsoft.com> skrev i meddelelsen news:524D35AE-4524-46A3-A963-703CB385C7F...

Treeview Control Question
Hello, I am using a treeview Control in a form that has a tab control. The treeview control is located on one of the tabs. When the form loads it populates the treeview control(has checkboxes enabled on treeview), bolds certain text based on the SQL table it's pulling from, and then checks any items that were checked last time the record was saved. The problem that I am having is that when I move to another tab and go back to it, all of the bolds and checks are gone. I've tried redoing the query on tab control and page click actions as well as trying to set focus on the treeview ...

conditional formatting: separating rows with differing values
Hi, Need help with conditional fomatting. What I need: I got a worksheet with 950 rows and 5 columns. The first row contain the headers. Columns A, B, D and E contains unique values. But the column C contains text values which repeats sequentially for 6-7 rows and changes thereafter. Now I want to put up a line (using border) through the whole row dividing this transition row. My Idea: Compare C2 with C3, if equal do nothing. Then compare C3 with C4 and so on till 2 consequtive values differ. Now divide the 2 rows using the border formatting option in conditional formatting dialog box. So...

Multline Tab Control with TCS_MULTILINE always empty
Hi ... I've been working with tab controls for a while now already, but this time I need to have a tab control that has multiple lines due to space contraints. I discovered the TCS_MULTILINE (Multiline) property and thought that this would solve my problem. Well, for some reason it's not working for me and I have no clue why. Basically, as soon as I set the type to multiline, the tabs themselves don't have any text in them (they're basically empty) and the control is not even multiline. Is there something that I am doing wrong? I tried clicking the option through the...