Sign in to follow this  
SpiritX

win32 textbox and array quesiton

Recommended Posts

SpiritX    122
Im trying to make a window with some text boxes where a user can input data and then save it to a file by pushing a button (kind of like a form for a database). How would I go about doing this? Any tutorials for this? Also, Im trying to newly initialize an array and resize it. I was told to use pointers and the new operator, but Im using a custom class and I keep getting an undeclared variable error. This is my code:
resume a*   //resume is my custom class;
a = new resume[5] ;

which gives an a is undeclared. Also how would I resize the array without creating a new array of size+1 and copying all the previous data? and also arethere any good programming IRC channels I can get real time help ? Thanks for all the help!

Share this post


Link to post
Share on other sites
silverphyre673    454
Is there a semicolon after the declaration? Did you remember to include "resume.h" or wherever the resume class is defined? Thats all I can think of. Unfortunately, no, you cannot resize an array without creating a bigger one and copying everything into it. Finally, gamedev actually has an IRC, although I have never used it.

Share this post


Link to post
Share on other sites
Xiachunyi    556
Try using this:

The GetDlgItemText function retrieves the title or text associated with a control in a dialog box.

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
);


Parameters

hDlg

Identifies the dialog box that contains the control.

nIDDlgItem

Specifies the identifier of the control whose title or text is to be retrieved.

lpString

Points to the buffer to receive the title or text.

nMaxCount

Specifies the maximum length, in characters, of the string to be copied to the buffer pointed to by lpString. If the length of the string exceeds the limit, the string is truncated.



Return Values

If the function succeeds, the return value specifies the number of characters copied to the buffer, not including the terminating null character.
If the function fails, the return value is zero.

Remarks

The GetDlgItemText function sends a WM_GETTEXT message to the control.



So implementation should look like:
GetDlgItemText(hDlg, ID_TEXT_EDIT, store, size_of_store);

Share this post


Link to post
Share on other sites
SpiritX    122
alright I got my array to work..

im not quite sure how to use your code Xiachunyi. Is there a tutorial or maybe sample code to maybe make a simple window where you can input some text and it saves it to a file?

thanks!

Share this post


Link to post
Share on other sites
Xiachunyi    556
Here is a tutorial for the function I was talking about. The function simply retrieves the the contents of the edit box and stores it into an array. From there, you can do anything to the array you wish, fstream it to a file or manipulate it in some way.

Edit: It does not seem to be C/C++, but the essential logic is the same.

If you need more of a specific elucidation, I can make a simple application later in the evening.

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this