Can't modify the text in

This is a discussion on Can't modify the text in within the Windows Programming forums, part of the Platform Specific Boards category; I have this problem that I can't modify the text in the text-edit control (while running the program). I can ...

  1. #1
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145

    Can't modify the text in

    I have this problem that I can't modify the text in the text-edit control (while running the program).
    I can select it, but not delete it or add new characters. It's ID is TextMain.
    Do you know what could cause this?

    Code:
    //+-----------------------------------------------------------------------------
    //| Included files
    //+-----------------------------------------------------------------------------
    #include <windows.h>
    
    
    //+-----------------------------------------------------------------------------
    //| ID definitions
    //+-----------------------------------------------------------------------------
    #define MainDialog 1
    #define TextMain 101
    #define ButtonAbout 103
    #define ButtonColor 2
    #define ButtonCopy 1
    #define ButtonExit 3
    
    
    //+-----------------------------------------------------------------------------
    //|  Global objects
    //+-----------------------------------------------------------------------------
    HWND MainWindow;
    
    
    //+-----------------------------------------------------------------------------
    //| Message handler
    //+-----------------------------------------------------------------------------
    LRESULT MessageHandler(HWND Handle, UINT Message, WPARAM wParam, LPARAM lParam)
    {
       switch(Message)
       {
          case WM_COMMAND:
             switch(LOWORD(wParam))
             {
                case ButtonCopy:
                	return 0;
                case ButtonColor:
                	return 0;
                case ButtonAbout:
                	return 0;
                case ButtonExit:
                	DestroyWindow(Handle);
                	return 0;
             }
             return 0;
          case WM_CLOSE:
             DestroyWindow(Handle);
             return 0;
          case WM_DESTROY:
             PostQuitMessage(0);
             return 0;
       }
       return 0;
    }
    
    
    //+-----------------------------------------------------------------------------
    //| Main function
    //+-----------------------------------------------------------------------------
    int WINAPI WinMain(HINSTANCE CurInst, HINSTANCE PrevInst, LPSTR Param, int Show)
    {
       MSG Message;
       MainWindow = CreateDialog(CurInst, MAKEINTRESOURCE(MainDialog), NULL, (DLGPROC)MessageHandler);
       ShowWindow(MainWindow, SW_SHOW);
       UpdateWindow(MainWindow);
       while(GetMessage(&Message, NULL, 0, 0)) DispatchMessage(&Message);
       return 0;
    }
    
    
    いいいいいいいいいいいいいいいいいいい
    This is the resource file:
    いいいいいいいいいいいいいいいいいいい
    
    
    
    #define IDD_DIALOG1	1
    #define MainDialog	1
    #define IDC_EDIT1	101
    #define IDC_EDIT2	102
    #define TextMain	101
    #define IDC_BUTTON1	102
    #define IDC_BUTTON2	103
    #define ButtonAbout	103
    #define ButtonColor	2
    #define ButtonCopy	1
    #define ButtonExit	3
    
    MainDialog DIALOG 0, 0, 268, 52
    EXSTYLE WS_EX_DLGMODALFRAME | WS_EX_CONTEXTHELP
    STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | DS_CONTEXTHELP | 0x200L | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_MAXIMIZEBOX
    CAPTION "War3Color v1.00"
    FONT 8, "MS Sans Serif"
    {
     CONTROL "Select a color", ButtonColor, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 100, 28, 64, 14
     CONTROL "Exit", ButtonExit, "BUTTON", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 220, 28, 40, 14
     CONTROL "Enter text here", TextMain, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 8, 8, 252, 13, 0
     CONTROL "Put text in clipboard", ButtonCopy, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 28, 86, 14, 0
     CONTROL "About", ButtonAbout, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 172, 28, 40, 14, 0
    }
    Last edited by Magos; 08-15-2002 at 02:25 PM.
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    This is a guess: try changing the 'CONTROL' statement in your resource script to the more usual 'EDITTEXT' for the edit control.

    The CONTROL statement is normally used for user-defined controls; there are specific resource statements for the standard/user/predefined controls (buttons,edits etc).

    edit: before you try that though, try changing this line:
    Code:
    while(GetMessage(&Message, NULL, 0, 0)) DispatchMessage(&Message);
    to
    Code:
    while(GetMessage(&Message, NULL, 0, 0)) TranslateMessage(&Message);DispatchMessage(&Message);
    As TranslateMessage is required to (from msdn: )..translates virtual-key messages into character messages..
    Last edited by Ken Fitlike; 08-15-2002 at 02:39 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Thanks, it worked (adding TranslateMessage).

    PS:
    I assumed you meant:
    Code:
    while(GetMessage(&Message, NULL, 0, 0))
    {
       TranslateMessage(&Message);
       DispatchMessage(&Message);
    }
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Ooops! Sorry about that - I did mean it that way. I'm glad that you at least knew what you were doing and that you got it to work.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Text adventure engine idea. thoughts?
    By suzakugaiden in forum Game Programming
    Replies: 16
    Last Post: 01-15-2006, 04:13 AM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  3. Text positioning and Text scrolling
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2004, 12:35 AM
  4. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  5. Replies: 1
    Last Post: 07-13-2002, 05:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21