user-0 提问: 为什么我刚创建的编辑框（Edit）无法输入内容？

回复:
user: user-1
content: show us the code

user: user-0
content: 引用 5 楼 赵4老师 的回复:MSDN98_1.ISO http://pan.baidu.com/s/1dDF41ix,  MSDN98_2.ISO http://pan.baidu.com/s/1bnGo0Vl  MSDN98\SAMPLES\VC98\SDK\NETDS\WINSOCK\GLOBCHAT\CLIENT\GLOBCL.C       112: //      113: //  FUNCTION: MsgCreate(HWND, UINT, WPARAM, LPARAM)      114: //      115: //  PURPOSE: Creates Inbox and Outbox Edit controls      116: //      117: //  PARAMETERS:      118: //      119: //    hwnd      - Window handle      120: //    uMessage  - Message number (Unused)      121: //    wparam    - Extra data     (Unused)      122: //    lparam    - Extra data     (Unused)      123: //      124: //  RETURN VALUE:      125: //      126: //    Always returns 0 - Message handled      127: //      128: //  COMMENTS:      129: //      130: //      131:       132: LRESULT MsgCreate(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)      133: {      134:     // Create Edit control for typing to be sent to server      135:     hOutWnd = CreateWindow("EDIT",      136:                            NULL,      137:                            WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |      138:                            ES_MULTILINE | ES_AUTOVSCROLL,      139:                            0,0,0,0,      140:                            hwnd,      141:                            (HMENU) ID_OUTBOX,      142:                            (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),      143:                            0);      144:     // Create Edit control for typing to be received from server      145:     hInWnd = CreateWindow("EDIT",      146:                           NULL,      147:                           WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |      148:                           ES_MULTILINE | ES_AUTOVSCROLL,      149:                           0,0,0,0,      150:                           hwnd,      151:                           (HMENU) ID_INBOX,      152:                           (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),      153:                           0);      154:       155:     return (TRUE);      156: }  https://bbs.csdn.net/topics/390374955 赵老师，现在您一般用的是GetWindowLong还是GetWindowLongPtr？

user: user-0
content: 引用 4 楼 Intel0011 的回复:只需将 while (GetMessage(&msg, NULL, 0, 0))    {       DispatchMessage(&msg);    } 改为 while (GetMessage(&msg, NULL, 0, 0))    {       TranslateMessage(&msg); //转换字符消息       DispatchMessage(&msg);    } 即可 我前面的说法有点问题，应该是不处理WM_KEYDOWN等消息是吧？我想Edit类应该还是有很多种类消息要处理的

user: user-0
content: 引用 4 楼 Intel0011 的回复:只需将 while (GetMessage(&msg, NULL, 0, 0))    {       DispatchMessage(&msg);    } 改为 while (GetMessage(&msg, NULL, 0, 0))    {       TranslateMessage(&msg); //转换字符消息       DispatchMessage(&msg);    } 即可 我去，，这也太牛了，强啊，能问下是什么原理吗？DispatchMessage应该也会发送消息到编辑框呀，难道是编辑框只接收WM_CHAR消息，因此对于KEY_DOWN不处理，看起来就是没反应，是吧？

user: user-2
content: MSDN98_1.ISO http://pan.baidu.com/s/1dDF41ix,  MSDN98_2.ISO http://pan.baidu.com/s/1bnGo0Vl  MSDN98\SAMPLES\VC98\SDK\NETDS\WINSOCK\GLOBCHAT\CLIENT\GLOBCL.C       112: //      113: //  FUNCTION: MsgCreate(HWND, UINT, WPARAM, LPARAM)      114: //      115: //  PURPOSE: Creates Inbox and Outbox Edit controls      116: //      117: //  PARAMETERS:      118: //      119: //    hwnd      - Window handle      120: //    uMessage  - Message number (Unused)      121: //    wparam    - Extra data     (Unused)      122: //    lparam    - Extra data     (Unused)      123: //      124: //  RETURN VALUE:      125: //      126: //    Always returns 0 - Message handled      127: //      128: //  COMMENTS:      129: //      130: //      131:       132: LRESULT MsgCreate(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)      133: {      134:     // Create Edit control for typing to be sent to server      135:     hOutWnd = CreateWindow("EDIT",      136:                            NULL,      137:                            WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |      138:                            ES_MULTILINE | ES_AUTOVSCROLL,      139:                            0,0,0,0,      140:                            hwnd,      141:                            (HMENU) ID_OUTBOX,      142:                            (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),      143:                            0);      144:     // Create Edit control for typing to be received from server      145:     hInWnd = CreateWindow("EDIT",      146:                           NULL,      147:                           WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT |      148:                           ES_MULTILINE | ES_AUTOVSCROLL,      149:                           0,0,0,0,      150:                           hwnd,      151:                           (HMENU) ID_INBOX,      152:                           (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),      153:                           0);      154:       155:     return (TRUE);      156: }  https://bbs.csdn.net/topics/390374955

user: user-1
content: 只需将 while (GetMessage(&msg, NULL, 0, 0))    {       DispatchMessage(&msg);    } 改为 while (GetMessage(&msg, NULL, 0, 0))    {       TranslateMessage(&msg); //转换字符消息       DispatchMessage(&msg);    } 即可

user: user-2
content: EDIT Designates a rectangular child window into which the user can type text from the keyboard. The user selects the control and gives it the keyboard focus by clicking it or moving to it by pressing the tab key. The user can type text when the edit control displays a flashing caret; use the mouse to move the cursor, select characters to be replaced, or position the cursor for inserting characters; or use the backspace key to delete characters. For more information, see Edit Controls.    For a table of the edit control styles you can specify in the dwStyle parameter, see Edit Control Styles.

user: user-0
content: 引用 1 楼 Intel0011 的回复:show us the code #include "stdio.h" #include "windows.h" #include "windowsx.h" void SetWNDCLASS( WNDCLASS* a, WNDPROC proc, LPCTSTR ClassName ) { 	a->style 			=0;			 	a->lpfnWndProc	=proc;							 	a->cbClsExtra		=0;		 	a->cbWndExtra	=0;	 	a->hInstance		=NULL;		 	a->hIcon			=NULL;			 	a->hCursor		=NULL;		 	a->hbrBackground	=(HBRUSH)GetStockObject(WHITE_BRUSH); 	a->lpszMenuName	=NULL;	 	a->lpszClassName	=ClassName;	 } LRESULT MyProc( HWND h, UINT msg, WPARAM wParam, LPARAM lParam) { 	HWND h2; 	switch( msg ) 	{ 		case WM_CREATE:			 			h2=CreateWindow("EDIT", "编辑框", WS_TABSTOP|WS_CHILD | WS_VISIBLE | WS_BORDER | ES_MULTILINE | ES_WANTRETURN | ES_NOHIDESEL , 30,20,100,30,h, 1,NULL,NULL ); 			CreateWindow("butTon", "按钮", WS_CHILD|WS_TABSTOP|WS_VISIBLE , 150,20,80,30,h, 2,NULL,NULL ); 			SendMessage(h2,EM_LIMITTEXT,100,0); 			Edit_Enable( h2, TRUE); 			return 0;  		case WM_DESTROY: 			PostQuitMessage(0); 			return 0; 	} 	return DefWindowProc( h, msg, wParam, lParam);  }  int main( void ) { 	WNDCLASS MyClass; 	SetWNDCLASS ( &MyClass,   MyProc, "MyClass" ); 	RegisterClass( &MyClass );				 	 	MSG msg; 	HWND h = CreateWindow( "MyClass", "ABC", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 280, 120, NULL, NULL, NULL, NULL);  	UpdateWindow(h);							  	while( GetMessage(&msg, NULL , 0, 0) ) 	{ 		DispatchMessage ( &msg ); 	} 	return 0; }