text.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:3k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // text.cpp : implementation file
- //
- #include "stdafx.h"
- #include "text.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CText
- CText::CText( CDrawView * view ) : CDraw( view )
- {
- this->type = TEXT;
- this->text = "";
- this->Create( WS_BORDER | WS_CHILD | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL , CRect( 10 , 10 , 200 , 30 ) , this->view , 0 );
- }
- CText::~CText()
- {
- }
- BEGIN_MESSAGE_MAP(CText, CEdit)
- //{{AFX_MSG_MAP(CText)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CText message handlers
- void CText::LButtonDown( UINT nFlags , CPoint point )
- {
- point -= this->view->GetScrollPosition( );
- ::ClipCursor( NULL );
- this->GetWindowText( this->text );
- if( this->text.IsEmpty( ) )
- {
- this->SetWindowPos( NULL , point.x - 2 , point.y , 0 , 0 , SWP_NOSIZE );
- this->ShowWindow( SW_SHOW );
- this->SetFocus( );
- }
- else
- this->view->SendMessage( WM_LBUTTONUP , nFlags , MAKEWPARAM( point.x , point.y ) );
- }
- void CText::LButtonUp( UINT nFlags , CPoint point )
- {
- CRect rc;
- this->GetWindowRect( &rc );
- this->view->ScreenToClient( &rc );
- rc.OffsetRect( this->view->GetScrollPosition( ) );
- CClientDC dc( this );
- dc.DrawText( this->text , &rc , DT_CALCRECT );
- this->DestroyWindow( );
- this->rgn.CreateRectRgn( rc.left , rc.top , rc.right , rc.bottom );
- this->Draw( );
- this->view->Invalidate( );
- }
- void CText::MouseMove( UINT nFlags , CPoint point )
- {
- }
- LRESULT CText::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
- {
- LRESULT result = CEdit::WindowProc(message, wParam, lParam);
- //键盘输入
- if( message == WM_CHAR )
- {
- CClientDC dc( this );
- this->GetWindowText( this->text );
- CRect rc , rcClient;
- dc.DrawText( this->text , &rc , DT_CALCRECT );
- this->GetClientRect( &rcClient );
- if( rc.Width( ) > rcClient.Width( ) || rc.Height( ) > rcClient.Height( ) )
- this->SetWindowPos( NULL , 0 , 0 , rc.Width( ) + 5 , rc.Height( ) + 5 , SWP_NOMOVE );
- }
- return result;
- }
- CDC * CText::Draw( CDC * pDC )
- {
- if( pDC == NULL )
- pDC = this->view->GetMemDC( );
- if( this->rgn.GetSafeHandle( ) )
- {
- CRect rc;
- this->rgn.GetRgnBox( &rc );
- pDC->SetBkMode( TRANSPARENT );
- pDC->SetTextColor( this->GetColor( ) );
- pDC->DrawText( this->text , &rc , DT_LEFT );
- }
- return pDC;
- }