Thread: Flat Scrollbar In Edit Control?

  1. #1
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465

    Flat Scrollbar In Edit Control?

    I am trying to use the WS_VSCROLL style on an edit control and use a flat scrollbar. I found this codeproject article: http://www.codeproject.com/editctrl/ceditex.asp and decided to try to mimic such behavior in Win32. The only thing I am trying:

    Code:
    // In the Message map
    ON_CONTROL_REFLECT(EN_VSCROLL, OnVscroll)
    
    void CEditEx::OnVscroll()
    {
        InitializeFlatSB(GetSafeHwnd());
        // Use the flat scrollbar feature provided by Microsoft.
        // See MSDN for this API
    }
    And my implementation:

    Code:
    		case WM_COMMAND:
    			if(HIWORD(wParam) == EN_VSCROLL && LOWORD(wParam) == IDC_EDITMAIN)
    			{
    				::InitializeFlatSB(HWND(lParam));
    			}
    			break;
    It seems to generally wrok, but when I click the up or down arrows, the XP styled scrollbar comes back for a second.

    Also, if I click the scrollbar and drag it to the top, it will jump down to the bottom after releasing the mouse, but not scroll down to the bottom, and trying to click it again makes it turn brown and then it restores itself after a second.

    http://img.photobucket.com/albums/v2...o1/fckedup.jpg

    This is pretty bizarre and I don't understand what is going on with this, or how to fix it. If it is not possible, can I make an owner drawn scrollbar control?

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    I found this little thing: http://www.catch22.net/tuts/coolscroll.asp

    Why you can't customize a standard Windows control

    (Only relevant under Windows 95,98,ME)

    Someone is bound to complain that they can't add cool scrollbars to a tree-view control, or an edit control, so I'll explain why this isn't possible.

    Firstly, it is quite possible to custom-draw the scrollbars on a standard window. All you need to do is call InitializeCoolSB, after all. However, internally, the standard windows all make use of the standard scrollbar functions such as SetScrollInfo and SetScrollPos. This is a problem, because these functions cause a window's scrollbars to be re-drawn, and this redraw does not get performed via a WM_NCPAINT message. Whenever you resize a standard window, or scroll up and down in one, the standard scrollbar API will be called, and this will cause your nicely drawn custom scrollbars to be over-written. So, unless you have the source-code to a window or control, you cannot apply the cool scrollbar library to it, because you must call the CoolSB_xxx API functions to perform all scrolling operations instead.
    Well, that sucks. It says it's only relevant to 95, 98, ME, but this would sort of explain my problem in a wierd way. It proposes a solution involving patching the import table to redirect those API's to his libraries' ones, I may try the same to do redirect it to the FlatSB API's.

  3. #3
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well. This seems like a little overkill, not really something that I want to do. Is there any way that I can have an owner drawn scrollbar instead? Or hide the scrollbar in the edit control when there is not enough text to fill it? Or make my own sort of scrollbar control to interact with the edit control (without a great deal of difficulty)?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  2. Appending text to an edit control
    By dit6a9 in forum Windows Programming
    Replies: 3
    Last Post: 08-13-2004, 09:52 PM
  3. endless edit control
    By ZerOrDie in forum Windows Programming
    Replies: 3
    Last Post: 03-21-2003, 02:51 AM
  4. Controlling an edit control
    By master5001 in forum Windows Programming
    Replies: 2
    Last Post: 10-16-2001, 03:08 PM
  5. Rich edit control example Win API
    By Echidna in forum Windows Programming
    Replies: 1
    Last Post: 09-17-2001, 02:12 AM