Text editor

I have the basic layout for the a text editor I'm trying to make but ID_BUTTON is failing , it says it wasn't declared?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_CREATE:{
               CreateWindow(TEXT("EDIT"), TEXT(""),
              WS_VISIBLE | WS_CHILD | WS_BORDER | ES_AUTOHSCROLL,
                10, 20, 700, 400,
                hwnd,(HMENU) NULL, NULL, NULL
                            );

              //HMENU hMenubar = CreateMenu();
             // HMENU hFile= CreateMenu();
             // HMENU hOptions = CreateMenu();
             // AppendMenu(hMenubar , MF_POPUP,NULL,"Make file");
             // SetMenu(hwnd, hMenubar);
         CreateWindow(TEXT("EDIT"),TEXT("FILENAME HERE"),
                      WS_VISIBLE | WS_CHILD | WS_BORDER ,
                      720, 10, 100,50,
                      hwnd,(HMENU) NULL, NULL, NULL
                      );
         CreateWindow(TEXT("button"), TEXT("Make FILE"),

                      WS_VISIBLE | WS_CHILD,
                      720, 70 , 80, 40,
                      hwnd,(HMENU) ID_BUTTON, NULL, NULL


                      );

          break;


        }
case WM_COMMAND:{

if(LOWORD(wParam)==ID_BUTTON){



}

break;
}

        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

   return 0;
}





also how can I implement this code into the windows 32 source codes button function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
 #include <cstdlib>
#include <string>
#include <fstream>
#include <sstream>
#include <cmath>
using namespace std;
int makefile();
void editfile();
void readfile();

int get_an_integer( istream& ins )
{
  // Get an entire line input from the user
  string s;
  getline( ins, s );

  // Get rid of any trailing whitespace
  s.erase( s.find_last_not_of( " \t\r\n\f\v" ) + 1 );

  // Try to convert it to the object of our desire (an int)
  std::istringstream ss( s );
  int result;
  ss >> result;

  // Check for success or failure.
  if (!ss.eof()) cin.setstate( std::ios::failbit );

  // Return the (potentially invalid) result
  return result;
}


     int main()
    {
        int menuc;
        system ("title File maker and editor");
        system ("cls");
        system ("color 9");
        cout<<"\n\n"<<endl;
        cout<<"                           Make and edit your files                             "<<endl;
        cout<<"_________________________________1.Read file____________________________________"<<endl;
        cout<<"_________________________________2.Make file____________________________________"<<endl;
        menuc=get_an_integer(cin);
         switch(menuc){
                case 1:
            readfile();
                 break;
                case 2:
            makefile();
                 break;
                 break;
        }

              return 0;
    }
       void readfile(){

              char output[1000];
              string content2;
              string filename2;
              ifstream ss;
             //Function starts here
        cout<<"enter the name of the file and the extension"<<endl;
                getline(cin , filename2);
                ss.open(filename2.c_str());
         if (ss.is_open())
         {
          while (!ss.eof()){
                ss >> output;
                cout<<output;
            }
            }
         if(!ss.is_open()){
                cout<<"file couldn't be found"<<endl;
            }
         ss.close();
      }
    int makefile(){

        ofstream f;
        string filename;
        string content;
        cout << "Please enter a file name to write: ";
        getline( cin, filename );
        f.open( filename.c_str() );
        cout<<"now enter what you want in this file"<<endl;
        getline(cin, content);
        f << content;
        f.close();



    }

Last edited on
obviously,the return type int of function "makefile" is a mistake.because u didnt return any type in the funcion body.so you should use void replace of int.

1.the funtion WindowProcedure only do with all kinds of signals from the hardware.so if the first " CreateWindow" ,you want to only display the text to
tip the user,it should be in WinMain body.of course ,in the WindowProcedure
you also "create text" after you use keyboard etc. to create a signal to os if you want.
2,you should known more about the windows programming analasis,only this can u solve the problem quickly.
Topic archived. No new replies allowed.