1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
class consolewindow
{
WNDPROC wpOrigEditProc;
form frmconsolewindow{"Console"};
HWND consoleedit=NULL;
static LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
consolewindow *clwindow=(consolewindow *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
static HBRUSH brush=(HBRUSH)GetStockObject(BLACK_BRUSH);
switch (message) /* handle the messages */
{
case WM_CTLCOLORSTATIC:
case WM_CTLCOLOREDIT:
{
SetBkMode((HDC)wParam,TRANSPARENT);
return (LRESULT)brush;
}
break;
case WM_DESTROY:
//PostQuitMessage (0); /* send a WM_QUIT to the message queue */
SetWindowLong(clwindow->consoleedit, GWL_WNDPROC,
(LONG) clwindow->wpOrigEditProc);
break;
}
return CallWindowProc (clwindow->wpOrigEditProc,hwnd, message, wParam, lParam);
}
public:
consolewindow(string strTitle)
{
frmconsolewindow.Text=strTitle;
consoleedit = CreateWindow("Edit", "hello editor",
WS_CHILD | WS_VISIBLE | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL| ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0, 0,
frmconsolewindow.width-20, frmconsolewindow.height -40 , frmconsolewindow, 0, GetModuleHandle(0), 0 ) ;
if(consoleedit==NULL)
SetBkColor(GetDC(consoleedit),RGB(0,0,0));
SetTextColor(GetDC(consoleedit), RGB(0,0,0));
wpOrigEditProc = (WNDPROC)SetWindowLong(consoleedit,GWL_WNDPROC,(LONG)consolewindow::WindowProcedure);
SetWindowLong(consoleedit,GWL_USERDATA,(LONG)this);
SetClassLong(consoleedit,GCL_HBRBACKGROUND,(LONG)CreateSolidBrush(RGB(255, 255, 255)));
}
};
|