Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CEdit in a ComboBox

Posted on 2004-04-25
10
Medium Priority
?
515 Views
Last Modified: 2013-11-20
I'm trying to save real estate in my program.  I have a sometimes large paragraph of information that I want to make available to my user to look at and even cut and paste parts of it if they want.  My solution is to use a combobox control where the showing text says something like "Click the arrow on the right to read the information" and when the user clicks on the combobox's arrow, they get a drop down that contains a read-only edit control with the text, scrollbar, etc.  Like a regular edit box, they can still select and copy and paste text from this box.  Then click the arrow again to close the box.  

I've been working on this for hours and I'm pretty frustrated.  Any help would be greatly appreciated.  Let me know if you have any questions.  Thanks in advance.
0
Comment
Question by:jjjkkklll
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 4

Expert Comment

by:r2far
ID: 10913265
It would take an aweful long time for me to explain in detail how to do this... In short you need both a combo box and an edit box that the combo box has control over...

Check this out >> http://www.codeproject.com/netcf/historycombo.asp?target=combobox
0
 
LVL 7

Expert Comment

by:peterchen092700
ID: 10913520
I would try a different approach:

* Catch the CBN_DROPDOWN notification to be notified when the combo-box opens.
* in the handler, close it immediately (CB_SHOWDROPDOWN, WPARAM=false), and create a "in-place-edit" control.

This would be a simple edit control, that
 - has WS_POPUP style
 - the dialog as parent
 - destroys itself when it loses focus

a simple - but not the best - example how to create an in-place edit is on http://www.codeproject.com/combobox/lbed.asp

Additionally you might want to handle ESC and RETURN in the edit, so these keys are not "taken away".




0
 
LVL 5

Expert Comment

by:Nass89
ID: 10915485
Hi,
I'm agree to both suggested solutions from r2far and peterchen, with a modification to it. Place a combobox over an Editbox and when Combobox is clicked, hide the Combobox and show the Editbox and so on. I have tested something like this for three controls based on a user selection and it worked fine.

Good Luck!


0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 45

Accepted Solution

by:
AndyAinscow earned 2000 total points
ID: 10915808
Have an edit box.  When it gets the focus increase it's size (use SetWindowPos or MoveWindow).  When the focus leaves the edit then reduce it's size to the default.
0
 

Author Comment

by:jjjkkklll
ID: 10930776
Hey guys, thanks a lot for the ideas.  I tried for a while to create an in-place edit control, but I couldn't get it going.  I decided a better solution is do something like AndyAinscow suggested.  I put an edit control on my dialog with just enough height to show the first line.  Then I put a bitmap button right next to it that looks just like the combobox's down arrow (this way I have more control over what it looks like color-wise, etc.)  Now when the user clicks the "down arrow" I handle the click and use movewindow to expand the edit box down to full size.  They click it again and I return the box to its original size.  

The problem I'm having is that there's a lot of buttons and static controls and edit boxes under the box, so when it expands down, it covers over the other controls.  Which is what I want.  The problem is that some of the controls show through the new edit box and the buttons show up when you mouse over them.  Pretty messy.  Is there a way to make sure this doesn't happen.  That the new edit box is the only box in the area until the user hits the button or the box loses focus (I haven't handled that yet).  Thanks for the help.
0
 
LVL 4

Expert Comment

by:r2far
ID: 10931642
I am not sure what this is for, but is it possible for you to have one large, multi-line edit box that does not shrink or expand.  then have a group of radio buttons to select what is displayed and edited in the box.  You could even use a static text control to display the first line of each content.

This suggestion is made without much knowledge of it's application so i hope it helps.
0
 

Author Comment

by:jjjkkklll
ID: 10933823
Yeah, that's a good idea too.  However, I really want this new box to add information and not affect the rest of the program or interface, which is pretty good.  I just want to be able to fit in a way to make more information available within tight real estate.  The perfect solution is a dropdown box that holds the info.  If I can't get this painting problem solved, I'm thinking the next option is to create a dialog box and pop that up over the edit control when the user hits the "down" button.  
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 10935729
When you resize use code like
GetDlgItem(IDC_CTLxxx)->ShowWindow(SW_SHOW);  or SW_HIDE
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 10935730
obviously for the controls that are covered by your enlarged edit
0
 

Author Comment

by:jjjkkklll
ID: 10940137
Hi guys,

Again, thanks for all the help.  I figured it all out.  The edit control that enlarges has to be after the other controls in the tab order.  That seems to solve that problem.  Here's the final code.  I have an edit control and a button next to it.  I handle the onkill focus of the edit control to know when to close the box back up.  I use bSuggestionOpen to know when the box is open.

void CPers1::OnDropbutton()
{
      RECT rect;
      m_edit1.GetWindowRect(&rect);
      ScreenToClient(&rect);
      
      if(bSuggestionOpen == TRUE)
      {
            bSuggestionOpen = FALSE;
      }
      else
      {
            rect.bottom += 100;
            bSuggestionOpen = TRUE;
                                //set focus so when I know it will lose focus to close
            m_edit1.SetFocus();
      }
      
      m_edit1.MoveWindow(&rect);
}

void CPers1::OnKillfocusSuggestionpers1()
{
      if(bSuggestionOpen == TRUE)
      {
            RECT rect;
            m_edit1.GetWindowRect(&rect);
            ScreenToClient(&rect);
            rect.bottom -= 100;
            m_edit1.MoveWindow(&rect);      
            bSuggestionOpen = FALSE;
      }
                //I had to add this so when the edit box loses control to click the drop button,
                //the box doesn't close before ondropbutton is handled and opens it again.
      if(GetFocus() != NULL)
      {
            if( GetFocus()->GetDlgCtrlID() == IDC_DROPBUTTON)
                  bSuggestionOpen = TRUE;
      }
}

It seems to work okay.  Let me know if you see anything that needs tweaking.  I'm going to give AndyAinscow the points.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question