既然这样,就先创建一个EDIT窗口吧,参见MSDN的例子,如下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
还望指教 怎么用API在一个窗口中 在创建子窗口?是不是再建个WNDCLASS wc,createWindow(wc,...,WS_CHILD,...);
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;