Thread: Rectangular text selection?

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    13

    Rectangular text selection?

    aka block selection, vertical selection, column selection etc.

    there are different modes of rectangular text selection. see the attached pic for examples.

    now the question is, how do i implement something like that on an edit/richedit control?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Probably gonna have to make it owner-drawn or something like that.
    Or implement the entire control yourself.

    gg

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    13
    OK, so i decided to try this using a richedit control. i subclassed the control and now i'm trying to implement 'normal' text selection. the following code works, but it flickers quite badly. anyone know how to remove the flicker?

    the message handlers are in the WndProc of the RichEdit that i subclassed.

    Code:
    case WM_LBUTTONDOWN:
    {
    	IsSelecting = true;
    	SelStartChar = MoveCaret(hWnd, lParam);
    	return 0;
    }
    
    case WM_MOUSEMOVE:
    {
    		
    	if (IsSelecting)
    	{
    		SelEndChar = MoveCaret(hWnd, lParam, true, SelStartChar);
    	}
    				
    	return 0;
    }
    
    case WM_LBUTTONUP:
    {
    	IsSelecting = false;
    	return 0;
    }
    
    //...other stuff
    
    LONG MoveCaret(HWND hWnd, LONG coord, bool Select, LONG SelStart)
    {
    	CHARRANGE cr;
    	LONG lChResult;
    	POINTL p;
    
    	p.x = LOWORD(coord);
    	p.y = HIWORD(coord);
    
    	lChResult = SendMessage(hWnd, EM_CHARFROMPOS, 0, (LPARAM)&p);
    	
    	Select == true ? cr.cpMin = SelStart : cr.cpMin = lChResult;	
    	cr.cpMax = lChResult;
    	
    	SendMessage(hWnd, EM_EXSETSEL, 0, (LPARAM)&cr);
    
    	return lChResult;
    }
    [edit]changed MoveCaret function and wm_mousemove handler, but it still flickers[/edit]
    Last edited by Sea Monster; 12-19-2003 at 08:31 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  2. Text positioning and Text scrolling
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2004, 12:35 AM
  3. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 04:33 PM
  4. Replies: 1
    Last Post: 07-13-2002, 05:45 PM
  5. random selection of words from a text file
    By archie in forum C++ Programming
    Replies: 0
    Last Post: 03-02-2002, 12:59 AM