我想從我在運行時創建的編輯控件中獲取文本,並將文本從它打印到父窗口(不是標題欄)上,我也在運行時創建。我該怎麼做呢?如何設置文本從編輯控件到窗口
const int bufferSize = 1024;
char textBuffer[bufferSize] = "";
HWND Editbox = FindWindowEx(hWnd, NULL, "Edit", NULL);
SendMessage(Editbox, WM_GETTEXT,
(WPARAM)bufferSize, (LPARAM)textBuffer);
HWND Picbox = FindWindowEx(hWnd, NULL, "Picbox", NULL);
RECT Picbox_Rect;
GetClientRect(Picbox,&Picbox_Rect);
Picbox_Rect.top = 3;
Picbox_Rect.left = 3;
hdc = GetDC (Picbox) ;
HFONT fnt = CreateFont(14,0,0,0,FW_DONTCARE,
FALSE,FALSE,FALSE,DEFAULT_CHARSET,
OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,
0, VARIABLE_PITCH,TEXT("Verdana"));
SelectObject(hdc, fnt);
SetTextColor(hdc,RGB(0,0,255));
SetBkMode(hdc, TRANSPARENT);
DrawText(hdc, textBuffer, strlen (textBuffer),
&Picbox_Rect, DT_LEFT);
ReleaseDC (Picbox, hdc) ;
DeleteObject(fnt);
//InvalidateRect(Picbox, NULL, TRUE);
你使用MFC?QT嗎? – Jeeva 2012-07-09 05:52:52
Windows? OSX? Linux呢? – 2012-07-09 05:53:08
windows和no mfc – eric 2012-07-09 05:56:36