![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 4
![]() |
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?
__________________
HijackThis Team-SFDC |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Sep 2005
Location: serbia & montenegro
Posts: 484
Rep Power: 4
![]() |
There are some ways to do it:
UINT GetDlgItemText(
HWND hDlg, // handle of dialog box
int nIDDlgItem, // identifier of control
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum size of string
);int GetWindowText(
HWND hWnd, // handle of window or control with text
LPTSTR lpString, // address of buffer for text
int nMaxCount // maximum number of characters to copy
);LRESULT SendMessage(
HWND hWnd, // handle of destination window
WM_GETTEXT, // message to send
(WPARAM) cchTextMax, // number of characters to copy
(LPARAM) lpszText // address of buffer for text
);Hope that helps. EDIT: sorry for the tab-spaces, they got corrupted when I pasted the text |
|
|
|
|
|
#3 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5
![]() |
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.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#4 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 4
![]() |
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. ![]()
__________________
HijackThis Team-SFDC |
|
|
|
|
|
#5 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5
![]() |
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).
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#6 |
|
Programmer
Join Date: Nov 2004
Posts: 84
Rep Power: 4
![]() |
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.
__________________
HijackThis Team-SFDC |
|
|
|
|
|
#7 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,031
Rep Power: 5
![]() |
Quote:
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|