How can use WM_LBUTTONUP with ON_WM_PARENTNOTIFY() - c++

I have a window containing a list. When more than one item is highlighted I want a button to become visible to be pushed over another button. If it goes back to one or none highlighted I want the button to be disabled and the previous button to be shown again.
Currently I have a OnParentNotify function
if(message = LBUTTONDOWN)
int count = pMyListControl->GetSelectedCount();
if(count>1)
{
pTotalBox->ShowWindow(SW_HIDE);
pCheckBut->ShowWindow(SW_SHOW);
count=0;
}
else
{
pTotalBox->ShowWindow(SW_SHOW);
pCheckBut->ShowWindow(SW_HIDE);
count = 0;
}
This approach is working somewhat. If I click one item, nothing happens, as wanted. But if I select 2, nothing happens still. It isn't until I select another, after selecting at least 2, that it works correctly.
So I understand it is only getting the count of items prior to being clicked. I need it to get items already selected, AND items selected when performing a click.

Related

Initialize record on cell enter of XamDataGrid

Assume we have a XamDataGrid with 10 columns.
Column 1 is a XamComboEditor bound to a collection in the model
This can't be changed, the data is coming from a server and the combo's collection is based on different selections within the model so it's very dynamic.
Columns 2 - 10 are just normal alpha numeric fields
The problem:
When you enter a alpha numeric and start typing the model is initialized and everything is fine. However, if you go to the very last row, the non-initialized empty one, and click on the combo editor before entering any data into any of the other fields, the combo editor is empty.
Now I am well aware of why this is happening, it's clear that this is due to the model not being initialized yet. I'm just not sure the best method to fix this.
I would hope there is a property on the XamDataGrid that adjusts when the record is initialized but I've searched the Infragistics documentation and examples and I can't find anything.
There are events for:
EditModeStarting
EditModeStarted
EditModeEnding
EditModeEnded
private void OnCellEditModeStarting(object sender, EditModeStartingEventArgs args)
{
if (args.Cell.Field.Name == "TotalQuantity")
{
DataRecord record = args.Cell.Record;
if (record == null)
return;
MyGridEntry item = record.DataItem as MyGridEntry;
// Do a thing
}
}
You can also respond to the InitializeRecord event. It can fire for multiple reasons, such as cell editing, so check the state of your row model when responding to it. All these events are on the parent grid, not any FieldLayouts or Fields.
<i:XamDataGrid x:Name="myGrid"
InitializeRecord ="OnInitializeRecord"
EditModeStarting ="OnEditModeStarting">

Edit Win32 combo box items

I have a combo box with a list of names that are editable through a text box on the same form. How would I go about editing the items that are sitting in the combo box when the user changes the name in the text box? There doesn't seem to be any message to update the strings sitting inside the combo box.
Thanks,
Edit: this is the code thats called when the text changes
void txtNameChange(HWND hDlg)
{
if(SelectedIndex != -1)
{
wchar_t Name[255];
GetDlgItemText(hDlg, txtName, Name, 255);
//need to set the item text of an item at a certain index here
}
}
You cannot rename an item in place. You need to delete the item you wish to modify with the CB_DELETESTRING message, and then insert the new value with the CB_INSERTSTRING message.

Prevent selected item from going out of view in QListView

I am using a QListView with only single selection and selection changes handled by the up and down arrows. Everything is working as expected with one minor issue. If many items are added to the top of the list then the currently selected item risks moving down and out of view. Is there any way to detect when this happens? Thanks.
I found solution, but first of all I try to do dimilar thing, I run timer and every 2 second I insert new row to the begin of list and try to detect, is selected item still visible?
//somewhere in the constructor, it is not important
ListModel = new QStandardItemModel();
ui->listView->setModel(ListModel);
Now when I want to insert new row , I wrote code, which checks is the item visible
QStandardItem* Items = new QStandardItem(QString::number(qrand()%100));
ListModel->insertRow(0,Items);
// here we get rect of current selected item
QRect rec = ui->listView->visualRect(ui->listView->currentIndex());
//here we get all listView region, convert it to rect and check is our listView
//contain selected item
if(ui->listView->viewport()->visibleRegion().boundingRect().contains(rec))
{
qDebug() << "visible";//all good
}
else
{
qDebug() << "not visible";//not good, we need do something
//you want to detect it, so you get!
//now you know that item "runs away from you"
//and you can do some actions
someAction();
}
I test it on my computer, when I can see item, I get visible word, when item tries "run away from me" I get not visible
I hope it helps.

Make list value selected - sencha touch

I have overlay in which I am having one list component.
I am selecting multiple list items from that.
I am pressing OK button and my overlay is getting disappeared.
Now What I want is :
When I open that overlay again , I want those previously selected items highlighted.
I want to do this in sencha touch.
When you open your overlay again, previously selected items should be shown or highlighted.
As per my understanding, When you click on Ok button, You would be passing selected values as extra parameter in store to load it again.
so, when you open that overlay again, you would have those extraparams in the store...so, you can do below things. I am sure, It will work.
var store = Ext.getStore('storeId'),
selectedItems[],
selectedRec,
selectedRecs = [],
extraparameter = store.getProxy().extraParameters;
You can get selected transaction types like this.
selectedItems = extraparameter.selectedItems
Ext.Array.each(selectedItems , function(selectedItem) {
selectedRec = multiSelect.getStore().findRecord('transaction_type', transactiontype);
selectedRecs.push(selectedRec);
});`
Thanks !

How do I put a checkmark on a menu item that has submenu items. (Visual studio 2008 C++/MFC)

I have a menu that contains submenus.
eg:
Item1
Item2
Item3
item A
Item B
Item3 has items under it.
At any given time 1, 2, or the items under 3 should be checked. Since I don't have an ID for Item3 I have to use the MF_BYPOSITION indicator when I try to set a check on Item3 to indicate one of its children has a checkmark. Item3 should have a checkmark if A or B are checked. I am able to check items 1 and 2 and A and B - but can't figure out item3.
I have not been able to successfully use either ::CheckMenuItem() or ModifyMenu() to set the check mark.
Can someone point me to an example that does this successfully? The docs seem to indicate it can be done, but I have been unable to do it.
EDIT
This is for a menu that is set as the menu for a dlg box. The menu bar has three items - one of which drops down to what is shown above.
Note also, it is used as a popup for a right click, but I will take any suggestions to work in either case.
I've done this before for popup menus. You will need to access the submenu by position, instead of ID. Using your example above, Item 3 would be at position 2:
CMenu popupMenu;
popupMenu.LoadMenu(IDR_MYMENU);
popupMenu.GetSubMenu(0)->CheckMenuItem(2,MF_BYPOSITION|MF_CHECKED);
.
.
.
popupMenu.GetSubMenu(0)->TrackPopupMenu(...);
However, I haven't done this with items in the menu bar.
EDIT by Tim the OP:
For completeness
To get it to work with the menu item you have to get the hmenu
// MENU_POSITION is the zero based location of the menu you want to use. (file, edit, view, help... etc)
HMENU mainMenu = ::GetMenu(m_hWnd);
HMENU subMenu = GetSubMenu( mainMenu, MENU_POSITION);
SetMenuState(subMenu);
A few moments ago I had a similar problem - a standard MFC menu bar containing at least one submenu, and the need to be able to add a check mark to the submenu parent item, when any of the submenu child items were checked.
The easiest solution (for me) turned out to be as simple as performing the update in the standard OnUpdateMenuItem(CCmdUI* pCmdUI) call. In my case I used ON_UPDATE_COMMAND_UI_RANGE() to feed a bunch of menu IDs into the same update call, but the principal is the same for a single ON_UPDATE_COMMAND_UI() map.
The code I used (edited to be more easily inserted into other people's work) is:
void CMyApp::OnUpdateMenu(CCmdUI* pCmdUI)
{
// Note, a submenu parent (which has no editable ID in the resource editor) has the SAME ID as the first child item
if (pCmdUI->m_nID == ID_FIRST_CHILD_MENU && pCmdUI->m_pSubMenu != NULL) {
// Get the child menu so we can see if any child items are checked
CMenu* pSubMenu = pCmdUI->m_pSubMenu;
BOOL fChildChecked = FALSE;
for (UINT i = 0; !fChildChecked && i < pSubMenu->GetMenuItemCount(); ++i) {
// Do something to decide if this child item should be checked...
UINT nChildID = pSubMenu->GetMenuItemID(i);
fChildChecked = IsThisChildChecked(nChildID);
}
// The POSITION of the current menu item is stored in pCmdUI->m_nIndex
CMenu* pMenu = pCmdUI->m_pMenu;
UINT flags = MF_BYPOSITION;
if (fActiveChild) flags |= MF_CHECKED;
pMenu->CheckMenuItem(pCmdUI->m_nIndex, flags);
}
// Set the enabled state of the menu item as you see fit...
pCmdUI->Enable(TRUE);
}
Et voilĂ  the submenu item automagically gains a check mark when any of its child menu items has a check mark.
Hope this helps others looking for similar solutions!
John