MFC dynamic adding controls with scroll bar - mfc

I want to add controls, including buttons, edit box and custom controls, dynamically in a MFC MDI application. I am using from view and I want to create the following GUI.
What I want to do is:
I am able to create those row of controls(Button, Edit box and custom
control) dynamically.
I can have many rows of those controls.
When there are too many rows and the form view has no space to
display them, a scroll bar will appear.
I had read some resources talking about how to create controls dynamically. But I am still wondering how to insert them into something so that I can have a scroll bar when there are too many rows of controls I have to handle.

Related

How to dock horizontally Qt widgets?

I am migrating to Qt from Microsoft Visual Studio. Common design for dialog boxes in desktop applications is set of labels and fields, where dialog looks like grid with labels and related fields. So, we can have Username label and text box to the right from that label, then Password label, etc. Usually when we resize a window, label size remains fixed, and text box width is increased to fill extra space, so user has more space to enter long string in text box and see it without scrolling.
Visual Studio has docking concept to describe such layouts, so you select a control and set its resizing behavior, in our example we have to set Dock = Fill for text boxes to instruct Windows Forms how to resize them. WPF has similar functionality if you set Width = *.
However, I don't see any such properties in Qt Creator Designer.
So how to instruct Qt widget (text box for example) to fill all space available in its parent widget?
In Qt, widget geometry can be automatically managed by layouts. A widget by itself won't fill the parent. You need to set a layout on the parent widget, and add the widget to the parent. There are numerous tutorials on that.
The particular layout that would apply to your situation is QFormLayout. This answer has a complete example.

how to create more no of controls dynamically to wxscrolledwindow in c++

I have a list containing a number of different controls (wxStaticText, wxTextCtrl, wxCheckBox, wxRadioButton, wxComboBox, wxListButton). I'm currently creating a large number of controls dynamically in my wxScrolledWindow. When I create more than 5,000 controls this way, my EXE hangs if I scroll the window.
I want to fix this problem by only creating the objects shown on-screen, and dynamically creating/destroying objects as I scroll my window. How do I implement this?
You shouldn't create that many controls. There is a limit of 10000 windows under Windows and while it can be increased, it's really not a wise thing to do.
Creating the controls on demand when they're scrolled into view risks being tricky. Instead, consider using wxGrid or wxDataViewCtrl to display your data and create the controls only for the (single) item being currently edited.

What MFC class should I base free floating views on

I have a dialog based MFC application. Now I want to create a wiew (one or more) with a toolbar, scroll bars and a client window (based on CWnd).
What MFC class should I base this window on?
What is the best way to do it?
Thanks.
Using a scrolling client window is more natural in a Document-View application than a dialog based application -- you can have menu bars and toolbars connected to a dialog, but to a View as far as I know.
A SDI application allows support for multiple docking/floating toolbars and multiple views of the same document, so this would be my advice...
Start with a CFrameWnd. It's job is to give your window a titlebar/close button etc., and position control bars (such as a toolbar) and a menu (if you want one) and a view within itself. The view should be a CScrollView (for painted graphics) or a CFormView (for dialog-like controls).
You will find this to be a lot easier if your just start from scratch and let the app wizard generate an SDI or MDI app to start with.

MFC Dialog Combo Box in a List Control

I'm trying to create a dialog window with a List Control (report view) that displays a column of text. I'm trying to add another column that displays a combo box that will hold a list of possible actions for the first column. Is there any easy way to do this in MFC?
You can't do that with something like CListCtrl (or not without a lot of owner drawn code). Instead have a look at a 3rd party control like CGridListCtrlEx which will do all the heavy lifting for you.

MFC tooltip for list control of dialog box

I have developed on application, which shows a dialog box with two list controls.
In this list control, I am showing images. Now I want is, when we move the mouse on images from the list control of dialog box, It will show tool tip for that.
How can I show tool tips for images in a list control in a dialog box?
The CToolTipCtrl control is the MFC wrapper class around the Win32 "tool tip". You can use this to display a small pop-up window to describe another control or provide additional information in your app.
If you're using a ListBox control, explore one of these sample projects to see how to display tooltips for individual items displayed within that ListBox control:
ListBox With ToolTip Support
List Box With ToolTips
And if you're using a ListView control (CListCtrl in MFC), then you should start by reading the documentation for the GetToolTips function and the corresponding SetToolTips function. You can also check out how this sample ListView control implements tooltips:
CListCtrl and Displaying a Tooltip