//@doc SECEditView //@mfunc Internal handler. //@rdesc void //@parm BOOL bActivate //@parm CView* pActivateView //@parm CView* pDeactiveView void SECEditView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) { static BOOL bFirstTime = TRUE; if (bFirstTime) { MakeCursorVisible(); bFirstTime = FALSE; } CView::OnActivateView(bActivate, pActivateView, pDeactiveView); }
VOID ExtendSelection( IN PCONSOLE_INFORMATION Console, IN COORD CursorPosition ) /*++ This routine extends a selection region. --*/ { SMALL_RECT OldSelectionRect; HRGN OldRegion,NewRegion,CombineRegion; COORD FontSize; if (CursorPosition.X < 0) { CursorPosition.X = 0; } else if (CursorPosition.X >= Console->CurrentScreenBuffer->ScreenBufferSize.X) { CursorPosition.X = Console->CurrentScreenBuffer->ScreenBufferSize.X-1; } if (CursorPosition.Y < 0) { CursorPosition.Y = 0; } else if (CursorPosition.Y >= Console->CurrentScreenBuffer->ScreenBufferSize.Y) { CursorPosition.Y = Console->CurrentScreenBuffer->ScreenBufferSize.Y-1; } if (!(Console->SelectionFlags & CONSOLE_SELECTION_NOT_EMPTY)) { if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) { // scroll if necessary to make cursor visible. MakeCursorVisible(Console->CurrentScreenBuffer,CursorPosition); ASSERT(!(Console->SelectionFlags & CONSOLE_MOUSE_SELECTION)); // // if the selection rect hasn't actually been started, // the selection cursor is still blinking. turn it off. // ConsoleHideCursor(Console->CurrentScreenBuffer); } Console->SelectionFlags |= CONSOLE_SELECTION_NOT_EMPTY; Console->SelectionRect.Left =Console->SelectionRect.Right = Console->SelectionAnchor.X; Console->SelectionRect.Top = Console->SelectionRect.Bottom = Console->SelectionAnchor.Y; // invert the cursor corner if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) { MyInvert(Console,&Console->SelectionRect); } } else { if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) { // scroll if necessary to make cursor visible. MakeCursorVisible(Console->CurrentScreenBuffer,CursorPosition); } } // // update selection rect // OldSelectionRect = Console->SelectionRect; if (CursorPosition.X <= Console->SelectionAnchor.X) { Console->SelectionRect.Left = CursorPosition.X; Console->SelectionRect.Right = Console->SelectionAnchor.X; } else if (CursorPosition.X > Console->SelectionAnchor.X) { Console->SelectionRect.Right = CursorPosition.X; Console->SelectionRect.Left = Console->SelectionAnchor.X; } if (CursorPosition.Y <= Console->SelectionAnchor.Y) { Console->SelectionRect.Top = CursorPosition.Y; Console->SelectionRect.Bottom = Console->SelectionAnchor.Y; } else if (CursorPosition.Y > Console->SelectionAnchor.Y) { Console->SelectionRect.Bottom = CursorPosition.Y; Console->SelectionRect.Top = Console->SelectionAnchor.Y; } // // change inverted selection // if (Console->CurrentScreenBuffer->Flags & CONSOLE_TEXTMODE_BUFFER) { FontSize = Console->CurrentScreenBuffer->BufferInfo.TextInfo.FontSize; } else { FontSize.X = 1; FontSize.Y = 1; } CombineRegion = CreateRectRgn(0,0,0,0); OldRegion = CreateRectRgn((OldSelectionRect.Left-Console->CurrentScreenBuffer->Window.Left)*FontSize.X, (OldSelectionRect.Top-Console->CurrentScreenBuffer->Window.Top)*FontSize.Y, (OldSelectionRect.Right-Console->CurrentScreenBuffer->Window.Left+1)*FontSize.X, (OldSelectionRect.Bottom-Console->CurrentScreenBuffer->Window.Top+1)*FontSize.Y ); NewRegion = CreateRectRgn((Console->SelectionRect.Left-Console->CurrentScreenBuffer->Window.Left)*FontSize.X, (Console->SelectionRect.Top-Console->CurrentScreenBuffer->Window.Top)*FontSize.Y, (Console->SelectionRect.Right-Console->CurrentScreenBuffer->Window.Left+1)*FontSize.X, (Console->SelectionRect.Bottom-Console->CurrentScreenBuffer->Window.Top+1)*FontSize.Y ); CombineRgn(CombineRegion,OldRegion,NewRegion,RGN_XOR); InvertRgn(Console->hDC,CombineRegion); DeleteObject(OldRegion); DeleteObject(NewRegion); DeleteObject(CombineRegion); }