![]() |
Reading from a textarea
In java, when one wants to read text from a text area, they do something like
:
string[] s = textArea.getText();I am assuming that C++ has something similar, but I sure can't find it in any of the APIs. Can someone point me in the proper direction please? |
There are some ways to do it:
:
UINT GetDlgItemText(:
int GetWindowText(:
LRESULT SendMessage(Hope that helps. EDIT: sorry for the tab-spaces, they got corrupted when I pasted the text |
Quote:
If you're using the raw Win32 API, you need to realize that all the controls like buttons, scrollbars, etc are just windows. When you create one of these predefined controls, you're creating a window of the appropriate 'window class'. A window class, not to be confused with C++ classes, is a sort of 'template' from which you can create instances. Each class has its own class name (a string), and has been pre-registered by Windows for you, which explains why you don't need to write a WinProc to catch the messages aimed at the control. In fact, the WinProc for most (all?) of these controls will handle events like clicking, and translate those into WM_COMMAND messages fired back at the parent window. Anyways, the upshot of all this is that since controls are just windows, you can use SetWindowText() and GetWindowText() to manipulate the text. On regular windows, it's the caption in the title bar, on buttons, labels (static controls in raw API terminology), etc, it's the text on the control, and for some, like scrollbars, it will be ignored. Remember, these functions will just send WM_SETTEXT or WM_GETTEXT to the target window. |
I am using the .net framework... I'm pretty sure that once I have time to understand everything that the IDE is throwing at me, I'll be able to figure it out.
Thanks for the input. :) |
Quote:
Properties are essentially a hybrid between methods and attributes. They are like attributes in that you just access them like object.property or objectPtr->property (note the lack of parentheses), but they are like methods in that the return value is determined by code (giving you encapsulation). They are kinda neat, but by no means essential; the only real benefit is they can help the code look cleaner. The downside is that you can't tell from a line of code whether something is accessing a property, or a public data member. That said, try the 'Text' property of the relevant control. Basic ones like buttons, textboxes, and labels all have it. For some of the more complex controls, like comboboxes and stuff, they either don't have it, or have it plus other properties/methods to get the additional bits of text. Usually the text is a String, but sometimes you need to convert it (like if it's an item in a listbox). |
I have been using the pre-defined templates, and you are describing pretty much what I am seeing, only it is a horrible jumble of files... when I double click on a button in the IDE, it takes me to the prototype in the header file of the form. There is also a .cpp for the form, which I always thought the relevant code went, but the way it is presented, it appears that it wants you to put the execution code in the header ??.. anyway, it's a mess.
I think at this point I would be better off rolling my own code so at least I can understand what the heck is going on. :) But I will look to the Text properties and see what I can come up with. |
Quote:
|
| All times are GMT -5. The time now is 8:56 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC