Tuesday, January 03, 2006
Taxes: Remote Desktop Connection and painting
Taxes: Remote Desktop Connection and painting: "An increasingly important developer tax is supporting Remote Desktop Connection properly. When the user is connected via a Remote Desktop Connection, video operations are transferred over the network connection to the client for display. Since networks have high latency and nowhere near the bandwidth of a local PCI or AGP bus, you need to adapt to the changing cost of drawing to the screen. If you draw a line on the screen, the 'draw line' command is sent over the network to the client. If you draw text, a 'draw text' command is sent (along with the text to draw). So far so good. But if you copy a bitmap to the screen, the entire bitmap needs to be transferred over the network. Let's write a sample program that illustrates this point. Start with our new scratch program and make the following changes: void Window::Register() { WNDCLASS wc; wc.style = CS_VREDRAW CS_HREDRAW; wc.lpfnWndProc = Window::s_WndProc; ... } class RootWindow : public Window { public: virtual LPCTSTR ClassName() { return TEXT('Scratch'); } static RootWindow *Create(); protected: LRESULT HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam); LRESULT OnCreate(); void PaintContent(PAINTSTRUCT *pps); void Draw(HDC hdc, PAINTSTRUCT *pps); private: HWND m_hwndChild; }; void RootWindow::Draw(HDC hdc, PAINTSTRUCT *pps) {"