Flat edit control

WEBINAR: On-demand webcast

How to Boost Database Development Productivity on Linux, Docker, and Kubernetes with Microsoft SQL Server 2017 REGISTER >

Download the source

This took about 20 minutes to create. I saw Kirk Stowell's CFlatComboBox class and decided it needed a similar Edit control I actually made the code look similar to Kirks to keep things simple if you need to edit the code in both classes for your purpose

Pretty neat looking edit control actually, i wonder why i never saw this sooner

Information

To Use this class :

Create a new class member of type CFlatEdit for an edit control in your dialog Make sure to have #include "FlatEdit.h" at the top of that dialogs .h file Thats It!

NOTE: For best appearance, under the properties for your edit control, deselect 'border' and select 'static edge'

For the CFlatEdit class to appear in the new member variable dialog for an edit control, you must rebuild the class information You can do this by deleting the .clw file in your project directory. When you go into class wizard, it will ask you to rebuild your class info from files.

Select all the c, cpp, and h files in that directory and add them all

You can change the m_bDrawGripper and m_bDrawSeperator values to true to use the seperator and gripper features. You can also set the left edit margin using SetIndent(int)

And one more kewl feature: use m_bFlatStyle to change the style. If its true (default), it will draw the control as a typical flat control. If its false, it will be drawn with a thick black border (Like that around a flat Checkbox)

Last updated: 17 October 1998



Comments

  • very good but not surport multiline

    Posted by Legacy on 05/13/2002 12:00am

    Originally posted by: Brick Luo

    :(

    Reply
  • ExEditors Library

    Posted by Legacy on 03/19/2002 12:00am

    Originally posted by: Mike Philips

    A complete collection of editors in a single file:
    
    

    http://www.exontrol.com/sg.jsp?content=products/exeditors

    Regards,
    Mike

    Reply
  • Your forgot about HScroll and VScroll

    Posted by Legacy on 12/12/2001 12:00am

    Originally posted by: reversed

    On a multiline edit box, the frame of the edit box is created on top of vscroll and/or hscroll.
    I'm working in solution, i'll post when found.

    Reply
  • Problem with editview

    Posted by Legacy on 01/23/2001 12:00am

    Originally posted by: Rajasekhar

    Hello Everybody,

    I am using eVC 3.0 to develop applications for pocketPC.

    I developed one SDI application using DVArchitecture.My main View is CView.It's working fine.Later i included one dialog and using ClassWizard i created a class with CEditView as the base calss. Using CSingleDocTemplate i am including this view as another template.The view is getting displayed perfectly for typing in the edit control,saving. But when i used Open option, after selecting a file, main view is coming up and the edit view is going back.I am not implementing the open and saving dialog boxes.

    What might be the reason?How to keep the editview as the top window until i close it?

    How to retrieve text from a CEditView in to a string?

    Thanking you.

    Regards...
    Rajasekhar

    Reply
  • How Can I Have Edit Box With Transparent Layout!

    Posted by Legacy on 01/04/2000 12:00am

    Originally posted by: Sharifi

    Please Help Me.
    How Can I Have Edit Box With Transparent Layout!

    Reply
  • Drawing problem when using with SpinButtonCtrl

    Posted by Legacy on 08/02/1999 12:00am

    Originally posted by: Subbi Iyer

    Very nice control.
    But I found a broblem ,when using the FlatEdit control with the SpinButtonCtrl where SpinButtonControl's Buddy Property is set to FlatEdit control. ie, It causes the SpinButton Control to half visible. This is happening even with out Gripper and Separator.

    Reply
  • Letters overwrite the edit control's edges

    Posted by Legacy on 05/24/1999 12:00am

    Originally posted by: Hector Lasso

    Excellent control. Very easy to use.
    
    

    Unfortunately, when you write anything in the edit control, the left and top edges get overwritten by the letters.

    To remedy this, I changed the DrawEdit() method like this:

    void CFlatEdit::DrawEdit(int style, COLORREF clrTopLeft, COLORREF clrBottomRight)
    {
    CRect rcItem;
    CRect rcGripper;
    CRect rcSeperator;

    GetClientRect(&rcItem);
    GetClientRect(&rcGripper);
    GetClientRect(&rcSeperator);

    CDC* pDC = GetDC();
    COLORREF clrBlack;
    clrBlack = RGB(0, 0, 0);

    if(m_bFlatStyle)
    {
    // ADD THIS LINE
    rcItem.InflateRect(1,1,0,0);
    pDC->Draw3dRect(rcItem, clrTopLeft, clrBottomRight);
    rcItem.InflateRect(1,1);
    ...
    }
    else { // When m_bFlatStyle is FALSE
    // ADD THIS LINE
    rcItem.InflateRect(1,1,0,0);
    pDC->Draw3dRect(rcItem, clrBlack, clrBlack);
    rcItem.InflateRect(1, 1);
    pDC->Draw3dRect(rcItem, clrBlack, clrBlack);
    ...

    It is a dirty work around, but it works fine for me. However, the control gets a little bit bigger than it should be.

    Another change I made to the control was to allow it to remain "POPPED UP" when it has focus just like the Office 97 flat combo box does! I haven't tested the code extensively...

    First of all, add message handler functions for WM_SETFOCUS and WM_KILLFOCUS:

    // Don�t forget to use class wizard to add these message
    // handlers
    void CFlatEdit::OnSetFocus(CWnd* pOldWnd) {
    CEdit::OnSetFocus(pOldWnd);
    DrawEdit(FE_MOUSEOVER, m_clrShadow, m_clrHilite);
    }

    void CFlatEdit::OnKillFocus(CWnd* pNewWnd) {
    CEdit::OnKillFocus(pNewWnd);

    // The same code found in the timer handler
    POINT pt;
    GetCursorPos(&pt);
    CRect rcItem;
    GetWindowRect(&rcItem);

    if(!rcItem.PtInRect(pt)) {
    DrawEdit(FE_MOUSEOUT, m_clrButton, m_clrButton);
    return;
    }
    }

    Next, change the OnPaint() method:
    void CFlatEdit::OnPaint()
    {
    Default();
    if (GetFocus() == this)
    DrawEdit(FE_MOUSEOVER, m_clrShadow, m_clrHilite);
    else
    DrawEdit(FE_MOUSEOUT, m_clrButton, m_clrButton);
    }

    Finally, in the timer message handler change/add the following lines:

    if(!rcItem.PtInRect(pt)) {
    KillTimer(1);
    // The following four lines replace the 'lonely' line
    // found in the original before the 'return' statement
    if (GetFocus() == this)
    DrawEdit(FE_MOUSEOVER, m_clrShadow, m_clrHilite);
    else
    DrawEdit(FE_MOUSEOUT, m_clrButton, m_clrButton);
    return;
    }

    Reply
  • Text Fields are the Problem

    Posted by Legacy on 04/20/1999 12:00am

    Originally posted by: Steve Miller

    SQL Text fields (LONGVARCHAR) can be greater than 255. This is where we have encounted the data truncation problem. We created a RFX variation that passes SHRT_MAX (32767) as the maximum. Of course, now users want to enter more than this. Is there a more dynamic way of doing this? I can always bump up my maximum to a larger number, but the memory is locked and what happens when the user exceeds that threshold?

    Thanks,
    Steve
    Change 'com' to 'gov' to email...

    Reply
  • Removed flickering not tested extensively though

    Posted by Legacy on 10/26/1998 12:00am

    Originally posted by: Vytukas

    I decided to make min changes in code, just to add one bool variable to prevent continual repainting when
    mouse is over edit control.
    
    

    variable is m_LastPaintOn.

    void CFlatEdit::OnTimer(UINT nIDEvent)
    {
    POINT pt;
    GetCursorPos(&pt);
    CRect rcItem;
    GetWindowRect(&rcItem);

    static bool bPainted = false; //dunno what does this part
    //(maybe author forgot something)

    if(!rcItem.PtInRect(pt)) {
    KillTimer(1);
    DrawEdit(FE_MOUSEOUT, m_clrButton, m_clrButton);
    m_LastPaintOn = false; // changes here
    return;
    }
    else {
    if(!m_LastPaintOn) // here
    DrawEdit(FE_MOUSEOVER, m_clrShadow, m_clrHilite);
    m_LastPaintOn = true; // and here
    }

    CEdit::OnTimer(nIDEvent);
    }

    Reply
  • cool grippers

    Posted by Legacy on 10/22/1998 12:00am

    Originally posted by: Jason

    This is a cool control. the grippers match my flat toolbar
    quit nicely. and even better, you saved me 20 minutes. ;)
    Jason.

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • In this highly valued report, you'll learn the results of "The Forrester Wave™: Hybrid Integration For Enterprises, Q4 2016" extensive research of the top Hybrid Integration Solutions, including each product's overall ranking, specific capabilities and strengths and weaknesses.

  • On-demand webcast Continuous integration and continuous deployment (CI/CD) allow DevOps teams to be more efficient. When starting from a production environment, the use of Microsoft SQL Server 2017 in Docker containers and Kubernetes clusters can facilitate a DevOps CI/CD pipeline. Using SQL Server tools also allows you to easily integrate core DevOps application lifecycle management practices to database development. Watch this on-demand presentation to learn how defining the database dependency as …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date