Loading
submit to reddit
May 23, 2013, 01:25:28 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome!
 
   Forum Home   Help Search Forum Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: Text boxes  (Read 1926 times)
iPhill
Newbie
*
Posts: 2


« on: April 27, 2009, 06:02:15 PM »

hey, basically I'm trying to create my own scripting language, it's all going well but in order to code you have to do everything in notepad. Basically, I want to create an application that has a text box where users can input the code, click a button that says "Save" and it saves everything to a text file...

How would I do this please?
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #1 on: April 27, 2009, 06:06:02 PM »

Are you wondering how to do the interface code or the file handling code?

Mike
Logged
iPhill
Newbie
*
Posts: 2


« Reply #2 on: April 27, 2009, 06:08:32 PM »

Are you wondering how to do the interface code or the file handling code?

Mike

Just the interface code please... I think I can manage the file handling.
Logged
Michael Hall
Administrator
Hero Member
*****
Posts: 901



« Reply #3 on: April 27, 2009, 09:15:56 PM »

There is a text editor that was written by Charles Petzold called "Poppad," which was published in his classic book on windows programming. The code is explained in the text and has multiple versions. I found one version of the code here, but I haven't tested it. It may have more or less functionality than you're looking for, but it should get you started.

Mike
Logged
Paul
Newbie
*
Posts: 14


« Reply #4 on: May 14, 2009, 11:20:54 AM »

You can create a multi-line edit box with Win32 quite easily:

Code:
   
RECT R;
GetClientRect(Hw,&R); // to fill the owner window with the edit box

EditHw=CreateWindowEx(0,"EDIT","",
        WS_CHILD|ES_MULTILINE|ES_WANTRETURN|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_HSCROLL|WS_VSCROLL,
        0,0,R.right-R.left,R.bottom-R.top,Hw,0,0,0);

    ShowWindow(EditHw,SW_SHOW);

This will provide most normal text editing functions by default.

You can get the text into a std::string like this:

Code:
int Ln=SendMessage(EditHw,WM_GETTEXTLENGTH,0,0);
std::vector<char> V(Ln+1);

SendMessage(EditHw,WM_GETTEXT,Ln+1,LPARAM(&(V[0])));

std::string S(V.begin(),V.end()-1);

// S now contains the text from the edit box

or set the text like this:

Code:
std::string S="This is some text";
SendMessage(EditHw,EM_REPLACESEL,WPARAM(false),LPARAM(S.c_str()));

There are a vast amount of other operations you can do - see the MSDN docs on "Working with edit boxes" for more details or post back if you have specific questions.
Logged
Pages: [1]   Go Up
  Send this topic  |  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!