Rectangular text selection?

This is a discussion on Rectangular text selection? within the Windows Programming forums, part of the Platform Specific Boards category; aka block selection, vertical selection, column selection etc. there are different modes of rectangular text selection. see the attached pic ...

  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?
    Attached Images Attached Images  

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,691
    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, 10:52 PM
  2. Text positioning and Text scrolling
    By RealityFusion in forum C++ Programming
    Replies: 3
    Last Post: 08-13-2004, 01:35 AM
  3. Scrolling The Text
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 07-14-2002, 05:33 PM
  4. Replies: 1
    Last Post: 07-13-2002, 06: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21