HSCROLL and VSCROLL in Combobox - c++

I have successfully created a combobox with HSROLL as follows :
HWND find = CreateWindowEx(0, WC_COMBOBOX, _T(""), CBS_DROPDOWN | WS_VISIBLE | WS_CHILD |
CBS_AUTOHSCROLL | WS_HSCROLL | WS_VSCROLL,0, 1, 100 30,
hwndToolbar, (HMENU)0, ghinst, NULL);
SendMessage(find, CB_SETHORIZONTALEXTENT, (WPARAM)1000, 0);
But it also gives the VSCROLL, even if there are only 2 items. This is very ugly. If I drop the WS_VSCROLL, it solves the problem.
On the other hand, I also used :
SendMessage(find, CB_SETMINVISIBLE, (WPARAM)20, 0);
to show 20 items only, other items are showed by VSCROLL. The VScroll bar will appear only if there are more than 20 items. So I can not drop WS_VSCROLL.
Do you have any idea about how to use 'CB_SETHORIZONTALEXTENT' without VSCROLL bar when there are fewer items ?

It seems the height of the combo box is too small to accommodate the number of items. As many items will be shown on drop down, as the height specified. If items cannot fit into this height, then the vertical scroll bar will appear.

Related

ComboBox did not work after setting project to Unicode

I changed my project properties to Unicode and compiling works great but my ComboBox didn't work.
Here some code:
COMBOBOX IDC_DEBUGLEVEL, 478, 20, 49, 14, CBS_DROPDOWN | CBS_SIMPLE | WS_VSCROLL | WS_TABSTOP
To add some items into this ComboBox I do:
cPipe = (CComboBox *)GetDlgItem(IDC_DEBUGLEVEL);
cPipe->AddString(L"label");
If I want to open the dropdownlist I didnt't get it. Only a small line with the correct width but the height seems to be zero. It looks like
I have only this black line but my items are added. I can choose the items with my keyboard.

winapi - Date time picker, change size of prev/next button

I have this code:
HWND hwndDP = CreateWindowEx(0,
DATETIMEPICK_CLASS,
TEXT("DateTime"),
WS_BORDER | WS_CHILD | WS_VISIBLE,
20, 50, 400, 60,
hDlg,
NULL,
NULL,
NULL);
HFONT hFont = CreateFont(40, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, L"Arial");
SendMessage(hwndDP, WM_SETFONT, WPARAM(hFont), TRUE);
which creates date time picker like in image below. AS you can see, I change the size of font, so the font of date time picker is bigger. I have problem, that buttons which are circled (next/prev month) don't change the size and are small. Is it possible to change the size of this buttons. I need it because I use this date time picker on monitor with touch and is hard to click on this two buttons.
Unfortunately there's no easy way to change this that I can see. Those controls aren't actually real buttons - they're just drawn on the window, and the calendar control bases the size of them on the value of NONCLIENTMETRICS.iScrollHeight - it doesn't let you change them.
The only way to change this is globally which would affect all scrollbars in the system, probably not something you want to do.
One idea I have for you would be to sub-class the control to put your own (real) button controls over the top of the existing ones.
Then, when your sub-class procedure gets the WM_COMMAND message to say they've been clicked, send the calendar control a WM_KEYDOWN message for VK_NEXT or VK_PRIOR - those keys will cause it to scroll a month in either direction.

Draw 3 images and text in listview

I'm not using mfc.
I make my own list-view (to shown data in table)
hListView = CreateWindowEx(0, WC_LISTVIEW, NULL, WS_CHILD | WS_VISIBLE | LVS_REPORT |
LVS_EDITLABELS, 0, 0, h_rcl.right - h_rcl.left, h_rcl.bottom - h_rcl.top,
hwnd_main, (HMENU)1000, hInstance, NULL);
But in one of column i want to show data like:
"Text | Text " (ofc as i want to put a img)
So my table would look like:
# | column1 | column 2
1 | "text <img> | text <img>" | text
Best Regards
Hahaha:D Right...
How to draw this images with this text?
I dont think that it is possible with:
ListView_SetItemText(hListView, items_num, 1, "test");
You can either:
enable the LVS_EX_SUBITEMIMAGES window style and then specify a per-item per-column image index into an ImageList that you associate with the ListView.
custom-draw the ListView items.

win32 List View Abbreviating Text

I'm using win32 to create a list view with downloaded icons, however, the text is abbreviated at approximately 19 characters (as about size 12 font, Segoe UI). I have included the CreateWindow and item creation code I'm using for it.
Any advice would be appreciated.
HWND airlinelist = CreateWindow(WC_LISTVIEW,L"",WS_CHILD | LVS_LIST | WS_TABSTOP | WS_BORDER,18,104,323,74,hwnd,(HMENU)3,hinst,NULL);
LVITEM newi;
ZeroMemory(&newi,sizeof(LVITEM));
const wchar_t* n = L"Client Website Name, website.com"
newi.pszText = newc;
newi.mask = LVIF_TEXT | LVIF_IMAGE;
newi.iImage = 0;
ListView_InsertItem(airlinelist,&newi);
The above would create a list view with the icon and something to the effect of "Client Website Nam..." despite it only taking up half of the list view's width.
I'll assume you're using LVS_LIST mode because the style is shown in your code sample. You can use the LVM_SETCOLUMNWIDTH message to adjust the column size once you've added items to the list control. You can also use the ListView_SetColumnWidth macro. E.g.:
SendMessage(airlinelist, LVM_SETCOLUMNWIDTH, 0, 300);
This would set the columns to 300 pixels wide. If you're actually using LVS_REPORT mode you would need to set the width for each column individually.

Fitting a big grid (wxGrid) in a dialog (wxDialog)

Here is my layout:
I have a sizer that contains a grid (with a proportion of 1) and a ok/cancel button bar
The all thing is in a wxDialog
Here it is:
|||||||||||||||
| |
| GRID |
| |
| |
| |
|||||||||||||||
| OK CANCEL |
|||||||||||||||
The issue is that the grid contains too many row, and over flow the screen, so in the end I don't see the top part of the dialog. Is there a way, when calling Fit() on the dialog, to limit its height ?
I have tried stuff like this: SetSizeHints(-1,-1,-1,500); and SetMaxSize(500,500) but it did not worked.
Also I have tried to do that: this->SetSize(this->GetSize().GetX(), 500);, but since the vertical scroll bar appears on the grid, it is not wide enough and a horizontal scroll bar shows up.
EDIT
In the constructor I call wxGrid(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize)
The easiest way to handle this is to use a grid of fixed size. If there are more rows than will fit, then a scroll bar will appear. You set the size you want in the constructor.
new wxGrid( this, IDC_grid, wxPoint(-1,-1),wxSize(igridxsize,igridysize));
If you want the size of the grid to adjust, e.g. when the user resizes the application window, things are a bit more complex. You need handle the window size event and change the grid size as appropriate.
Something along these lines:
myDialog::OnSize(wxSizeEvent& event);
{
wxSize dialogSize = event.GetSize();
myGrid->OnSize( wxSizeEvent(
dialogSize.GetWidth() * 0.9, dialogSize.GetHeight() * 0.7 ));
}