-
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
}
-
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..
-
Thanks, it worked (adding TranslateMessage).
PS:
I assumed you meant:
Code:
while(GetMessage(&Message, NULL, 0, 0))
{
TranslateMessage(&Message);
DispatchMessage(&Message);
}
-
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. :)