要多简单?
只包含一个编辑控件的?
这样的SDK程序才不过200行啊.........
等晚上再写吧,现在太忙啦.........

解决方案 »

  1.   

    这是个特简单的例子,只是一个编辑控件喽LONG APIENTRY MainWndProc( 
    HWND hwnd,                // window handle 
    UINT message,             // type of message 
    WPARAM wParam,            // additional information 
    LPARAM lParam)            // additional information 

        static HWND hwndEdit; 
     
        CHAR lpszTrouble[] = "When in the Course of human Events " 
                             "it becomes necessary for one People " 
                             "to dissolve the Political Bands which " 
                             "have connected them with another, and " 
                             "to assume among the Powers of the " 
                             "Earth, the separate and equal Station " 
                             "to which the Laws of Nature and of " 
                             "Nature's God entitle them, a decent " 
                             "Respect to the Opinions of Mankind " 
                             "requires that they should declare the " 
                             "causes which impel them to the " 
                             "Separation. "; 
     
        switch (message) 
        { 
            case WM_CREATE: 
                hwndEdit = CreateWindow( 
                    "EDIT",     // predefined class 
                    NULL,       // no window title 
                    WS_CHILD | WS_VISIBLE | WS_VSCROLL | 
                        ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL, 
                    0, 0, 0, 0, // set size in WM_SIZE message 
                    hwnd,       // parent window 
                    (HMENU) ID_EDITCHILD, // edit control ID 
                    (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE), 
                    NULL);                // pointer not needed 
     
                 // Add text to the window. 
     
                 SendMessage(hwndEdit, WM_SETTEXT, 0, 
                    (LPARAM) lpszTrouble); 
     
                return 0; 
     
            case WM_COMMAND: 
                switch (wParam) 
                { 
                    case IDM_EDUNDO:                     // Send WM_UNDO only if there is something 
                        // to be undone. 
     
                        if (SendMessage(hwndEdit, EM_CANUNDO, 0, 0)) 
                            SendMessage(hwndEdit, WM_UNDO, 0, 0); 
                        else 
                        {
                            MessageBox(hwndEdit, 
                                "Nothing to undo.", 
                                "Undo notification", MB_OK); 
                        }
                        break; 
     
                    case IDM_EDCUT: 
                        SendMessage(hwndEdit, WM_CUT, 0, 0); 
                        break; 
     
                    case IDM_EDCOPY: 
                        SendMessage(hwndEdit, WM_COPY, 0, 0); 
                        break; 
     
                    case IDM_EDPASTE: 
                        SendMessage(hwndEdit, WM_PASTE, 0, 0); 
                        break; 
     
                    case IDM_EDDEL: 
                        SendMessage(hwndEdit, WM_CLEAR, 0, 0); 
                        break;                 case IDM_PASSWORD: 
                        DialogBox(hinst, // current instance 
                            "PassBox",   // resource to use 
                             hwnd,       // parent handle 
                             (DLGPROC) PassProc); 
                        break;                 case IDM_WRAP: 
                        SendMessage(hwndEdit, 
                            EM_SETWORDBREAKPROC, 
                            (WPARAM) 0, 
                            (LPARAM) (EDITWORDBREAKPROC) WordBreakProc); 
                        SendMessage(hwndEdit, 
                            EM_FMTLINES, 
                            (WPARAM) TRUE, 
                            (LPARAM) 0); 
                        SendMessage(hwndEdit, 
                            EM_SETSEL, 
                            0, -1); // select all text 
                        SendMessage(hwndEdit, WM_CUT, 0, 0); 
                        SendMessage(hwndEdit, WM_PASTE, 0, 0); 
                        break;                 case IDM_ABOUT: 
                        DialogBox(hinst, // current instance 
                            "AboutBox",  // resource to use 
                             hwnd,       // parent handle 
                             (DLGPROC) About); 
                        break;                 default: 
                        return DefWindowProc(hwnd, message, wParam, lParam); 
                } 
                break;         case WM_SETFOCUS: 
                SetFocus(hwndEdit); 
                return 0;         case WM_SIZE:             // Make the edit control the size of the window's 
                // client area.             MoveWindow(hwndEdit, 
                    0, 0,           // starting x- and y-coordinates 
                    LOWORD(lParam), // width of client area 
                    HIWORD(lParam), // height of client area 
                    TRUE);          // repaint window 
                return 0;         case WM_DESTROY: 
                PostQuitMessage(0); 
                return 0;         default: 
                return DefWindowProc(hwnd, message, wParam, lParam); 
        } 
        return NULL; 

      

  2.   

    to joke100:       你这个程序并没有自己处理按键,字符输出之类的功能,只是用SDK的方式结合已有的windows自带的editCtl来弄的,好象不符和zing的要求吧:0
      

  3.   

    我也感兴趣,不过要功能比较全面的。不知道哪里有。
    和windows的notepad一样就可以了。再简单我也会编 :)
      

  4.   

    顺便问问在编辑控件里为什么不能键入Enter键后,光标就回车换行?谢谢
      

  5.   

    to gil:
      
         editctl有个属性 是multiRows,你得选中那个才行.
      

  6.   

    to robin_hood_pot:     我倒是写了一个,是可以进行语法分析(多色彩显示)的,可是性能不是很好(当需要查找的关键字符太多(>50个左右)时速度不能忍受),哎,只能做个notepad用用了.:(
      

  7.   

    VC之路这样的程序有一大把。http://vcroad.6to23.com
      

  8.   

    joke100(joke100)
    你的代码我看还需要将edit却省窗口过程子类化吧!