Flat edit control

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

  • Merkt u theMonster hoofdtelefoon die zeker aanzienlijke bescherming heeft

    Posted by mrswanzi on 06/06/2013 04:04pm

    [url=http://koptelefoon-monsterbeats.webspawner.com/]beats by dre[/url] Het toestel komtondersteunt zowel Bluetooth als NFC en komt met ingebouwde microfoon, zodat je je telefoongesprekken via het toestel kan voeren. Naast de Executive lanceert Beats ook een draagbare muziekspeler: de Beats Pill. Die kreeg zijn naam dankzij zijn langwerpige, afgeronde vorm. Beat by dre hoofdtelefoons hebben iets speciaals. De meeste muziek producers en artiesten steken veel moeite in hun opnamesessies om hun sound te perfectioneren. Helaas zullen deze geluiden het grootste deel van de tijd hun luisteraars nooit bereiken, dit komt door de lage kwaliteits koptelefoons die worden gebruikt door de luisteraars. [url=http://beatssolokopen.weebly.com/]beats solo kopen[/url] koper suggesties aanbevolen dat voor veel mensen de oordopjes gingen "te diep". Echter, niet hebben dat je ophouden. wanneer u een geweldig in vorm te krijgen, de Beats Tour draadloze oordopjes lijken fenomenaal. groene beats by dre studio te koop Ik zou zeer raden het kopen van de Beat Tour als je probeert om een instapmodel beste uitstappen oordopjes af te maken. Beats By Dr. Dre must-have voor de echte muziekliefhebber! [url=http://koptelefoon-monsterbeats.cabanova.com/]beats by dre[/url] De Beats By Dre Real is door hen uitvoerig getest en de techneuten hebben ervoor gezorgd dat de Real niet alleen die neutrale en natuurlijke klanken heeft, maar ook een breed frequentiebereik. Iets wat natuurlijk erg belangrijk is, omdat - zoals je misschien zelf al weet - de geluidskwaliteit van een koptelefoon onder andere wordt bepaald door welke tonen je allemaal hoort. Hoe breder het frequentiebereik, hoe meer je hoort en dat is precies waar de Beats By Dre Real goed scoort.

    Reply
  • 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
  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds