Combo box in a MFC application - combobox

My question is about combo boxes in Windows MFC applications.
The dropdown part of the combo box contains items composed of a bitmap and a string.
Sometimes, the strings are too long and I have to adjust the width of the dropdown part of the combo box using the CComboBox::SetDroppedWidth() method.
My problem is that when the combo box is near the right edge of the computer screen, the right part of the dropdown is hidden (see image_1 and image_2 below).
I would like it to behave like in Excel (see image_3 below) meaning I would like the dropdown list to be shifted accordingly so that all its items can be seen without being cropped.
How can this be achieved?
image_1: right part of the dropdown is NOT hidden
image_2: near the computer right edge, the right part of the dropdown is hidden
image_3: Excel combo box
=================================================================
EDIT 1
=================================================================
EDIT 2
Ok. I forgot to mention that m_cbXmodels is a CComboBoxEx object. This is why the handles are NULL. I could get the handles via GetComboBoxCtrl()...

Handle the CBN_DROPDOWN notification.
Get the handle for the list control with GetComboBoxInfo.
Now use MoveWindow to adjust the window as needed.
Getting the current screen size is available with MonitorFromWindow. See rcWork member in MONITORINFO. You just need to adjust the left and right coordinates.
EDIT: As you can read in the comments: My Approach with CBN_DROPDOWN is to early Thanks to zett42). It is not possible to resize the combo box list part here.
But it is possible to post a user defined message to the same window and to reposition the window than.

Related

Automatically resize form and move controls when new ones are added or a text in a label grows

Beginner in Visual Studio here.
I'm trying to create an C# Windows Form application that simply displays a form to show some information about the local system.
I have created this form with the help of the VS designer:
As you can see, it consists of a simple panel with a PictureBox at the top, a label below it (both centered), three table layouts next to each other, and a button at the bottom. Never mind the label texts.
The rows of all the table layouts are set to absolute, this is because I want to programatically add rows to the end middle and right table layout if there are more than one local IP address in the computer and setting the rows to auto size or percentage would make alignment difficult if more rows are added.
Now, my problem is that I can't figure out how to make the form resize and move the controls (specifically move the 'OK' button down) when more rows are added.
I have tried anchoring the button to the bottom edge of the form as well as the bottom of the middle table, both produce the same result: the button stays where it is and the new rows overlap it, like this
I would also like to know how to have the form resize to fit the contents of the labels. For example, if the text in one of the labels inside the layout is bigger than the column width, I'd like to have the form grow to accommodate it. Likewise, I'd like the form to shrink to fit the largest text.
I realize that this may not be the most efficient or easiest way to create this particular form, but it is what I've come up with, I of course welcome any suggestions in that regard. It is important to maintain alignment between the rows of all table layouts.
Thanks in advance.
Use a data grid and add controls to it if an add button is pressed. You can scroll through the rows so you won't need to adjust the height of the form

How can I neatly line up right-aligned check boxes with with other controls?

The Visual Studio WinForms designer lets you snap together text boxes, list boxes, buttons, and so forth reasonably well. However, a check box with CheckAlign=MiddleRight does not work quite like the others, because it has two components: the built-in label, and the check box itself. If you line up the text with other labels, the check box is left floating and will not automatically line up. You can turn off AutoSize and attempt to size the CheckBox control so the check box lines up, but this is touchy and will be thrown off by custom font sizes.
In this example, I've almost lined up the check box with the other controls, but not quite:
If I had several check boxes it would be a real headache, as with AutoSize turned off the position of the check box is relative to the end of the text, so each control has to be individually sized pixel by pixel.
What's the best way to line up check boxes with other controls?
One workaround is to not include text with the CheckBox and instead have a separate Label control. However, by doing so you lose the ability to click on the label to toggle the check box. On a high-resolution screen, clicking a 10x10 pixel is finicky, a poor UX experience. You could add an OnClick event to the label, of course, but that seems like solving the wrong problem.
Here's an example of someone else with the same issue: in the preferences panel in Oracle SQL Developer, when there's a mix of properties the check boxes are handled with separate labels and boxes:
Personally, i avoid that issue by not having the CheckBoxes aligned to the right:
rather than having the caption on the left.

Get space in combo-box after populate model in GTK C

I have code where I populate combo box models by text but first time I see strange behavior.
I use Blade GUI editir to create *.ui file where i generate single empty combobox.
After, I fetch combo from methods and modify/fill my combo.
This is my snippets of code:
GtkWidget *combo_screen_share;
GtkTreeModel *model;
// here I get empty combobox
combo_screen_share=myprog_gtk_get_widget(call_view,"window_screen_stream");
GtkCellRenderer *renderer=gtk_cell_renderer_text_new();
model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING)));
int i;
for(i=0; i<200; i++){
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,"Full Screen",-1);
}
gtk_combo_box_set_model(GTK_COMBO_BOX(combo_screen_share),model);
g_object_unref(G_OBJECT(model));
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_screen_share),renderer,FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_screen_share),renderer,"text",0,NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_screen_share),0);
// bind 'onChange' with other method as callback
g_signal_connect(G_OBJECT(combo_screen_share),"changed",(GCallback)gtk_combo_box_new_with_model,NULL);
It should create 200 rows of "Full Screen" string.
However when I click on combobox, I get empty half screen as gap/space and only after all my 200 items.
If I run the loop for 100, space is going to be smaller.
Did someone meet the same thing and know how to fix it?
Thank you,
What you're seeing isn't a "bug" exactly, it's just the way Gtk does combo boxes and you'll have to live with it.
Try another app if you don't believe me --
Open a Gtk app (I used The Gimp)
Find a combo box with several options
Drag the window so that the combo box is near the bottom of the screen
Click on it
When the combo box appears it will have a big empty space at the top, just like yours.
I don't believe there's a fix without patching Gtk itself. For more discussion/rants on this issue see this Launchpad bug and this Gnome Buzilla bug.

SSRS Action hyperlink colour change

See attached screen shot.
I have made the 4 text box's hyperlinkes to different reports.
Is it possible to have a some sort of formula which will say change the colour of the box when the cursor is hovered over the hyperlink like a webpage button could do?
Unfortunately SSRS does not allow events like onHover etc. The only thing you can do is to provide a label for the entry or to simply color the text using the properties section and set it to underline. However, this would mean at all times it would be underlined and colored.

Find a better control

It is necessary to implement the following functionality:
There is a rectangle "field", its size is 150x100 pixels. Field is split to locations, each location is 10x10 (totally 15x10 locations on the field).
There are few "coins" (5, for example), each of them can be dropped into any location.
The list of text messages should be displayed in the drop-down list if any coin is clicked (when any message is clicked, drop-down list should be hidden and coin should display the number of selected message from 0 to 9, for example).
That should be done with Silverlight 4.0
I am going to implement custom control "Coin", it will have a view (with a circle), it will display some kind of popup-window (please advise, which one), focus will be set to this window. On "FocusLost" window will be closed (without changing message number), if any message from the list will be clicked then its number will be stored inside of coin.
Question 1: is there any control that already has required functionality?
Question 2: how to implement "drag-and-drop" of coins to the "field" (lets assume, they will be close to the field)?
Any thought or ideas will be helpful. Thanks.
You should not place multiple questions in one 'question'.
AutoCompleteBox is in the Silverlight SDK, in the System.Windows.Controls.Input.dll assembly, and may be of help for the auto completion.

Resources