I use a custom-drawn context menu (MFT_OWNERDRAW). I handle WM_MEASUREITEM and WM_DRAWITEM messages.
For the WM_DRAWITEM message, I can identify the event source based on the DRAWITEMSTRUCT structure. It contains hwndItem - for menus, this member is a handle to the menu that contains the item.
The MEASUREITEMSTRUCT structure doesn't contain such information. Is it possible to somehow determine the event source for WM_MEASUREITEM?
EDIT: I can use itemData to send some custom struct. When handling WM_MEASUREITEM, I have to cast ULONG_PTR to my struct, eg:
A* a = (A*)item->itemData
What if WM_MEASUREITEM is sent for some other control with a different itemData, for example a B struct? How to determine that at runtime?
According to the WM_MEASUREITEM:
Contains the value of the CtlID member of the MEASUREITEMSTRUCT structure pointed to by the lParam parameter. This value identifies the control that sent the WM_MEASUREITEM message. If the value is zero, the message was sent by a menu. If the value is nonzero, the message was sent by a combo box or by a list box. If the value is nonzero, and the value of the itemID member of the MEASUREITEMSTRUCT pointed to by lParam is (UINT) 1, the message was sent by a combo edit field.
The CtlID is the identifier of the combo box or list box and itemID is the identifier for a menu item or the position of a list box or combo box item MEASUREITEMSTRUCT.You can use them to distinguish different controls.
Related
My goal is to Programmatically select items from the List of the combo box, but without updating the edit control. The same can be achieved with the mouse. E.g. when you drop down and hover an item from the list, that item is highlited. And that is all. If you want to select in it the combo box (e.g. move it to the edit control) - you must click on the LisBox.
I tried with CB_SELECTSTRING. But it automatically updates the ComboBox edit control with the selected text which is not what I want. I want to do this using raw Win32 or VB6
Thanks
There is a big difference between highlighting an item in the drop-down list and actually selecting an item to make it active. CB_SELECTSTRING selects an item, as its name implies. But there is no official ComboBox API to highlight an item, though.
However, you can display the drop-down list manually (CB_SHOWDROPDOWN), and either:
move the mouse over the desired item so the list can perform hot-tracking logic.
manipulate the list directly. Use CB_GETCOMBOBOXINFO or GetComboBoxInfo() to get the list's HWND, and then send LB_SETCURSEL to it.
I have a combo-box within my window; and I'm capable of adding elements to the combo-box flawlessly however when I attempt to remove one or all of the items, no items are removed. According to Spy++ the message WM_DELETEITEM sends however the combo-box is not receiving the message.
You don't send WM_DELETEITEM to delete the item, it gets sent back to you once the control has finished deleting the item. Use CB_DELETESTRING instead.
I am trying to debug a form window written in VB6. It is to enter customer data so you can type in an address in the address field. You can also type in something like 90210 Main Street and on enter it will automatically parse the text and write the 90210 in the postal code field below and let Main Street be in the address field. It however can occasionally parse it wrong, which is what I am trying to fix.
The problem is that I can't figure out how exactly it is set up. If I type something into the TextBox address field and do a
?ADDRESS.text
In the immediate window, the it returns an empty string. There is also only a single function defined when I look in the dropdown list under the form. But when I set a breakpoint at it and click the textbox, then it doesn't break. It is the GotFocus() event:
Private Sub ADDRESS_GotFocus()
Call GCui.BM(ADDRESS)
End Sub
It's the same with the POSTALCODE textbox. It has DblClick, GotFocus and LostFocus event functions defined. But setting a break point in either one of them has no effect.
Is there any way of finding out where in the form the value Main Street or 90210 is stored? They are clearly visible in the ADDRESS textbox and the POSTALCODE textbox, but the immediate window returns an empty line when asking for their values.
Update 1:
It seems that someone has decided to completely rebuild the form with new controls. It probably happens in form.load. But I would still like to know if there is a way to search through variable values to find the string "Main Street" or "90210".
Update 2:
It turns out that there are two frames on top of each other. The top frame is hidden at startup and the bottom (almost identical frame with same labels and controls) are shown.
You can use the "Watch" feature. This will let you inspect all the properties of a form and all controls within the form and their values (look at the controls node).
You can also do this via code by looping over the form.controls collection.
Dim o As Object
For Each o In Me.Controls
If TypeOf o Is TextBox Then
Debug.Print o.Text
End If
Next
I want to capture the information of new created appointment item, For that I hook the event with NewInstpector window & again hook the Write event. I am also using standard outlook item wrapper(from msdn).
The problem is inside the Item_Write event handler I get the reference of new item however some properties are coming as NULL. For e.g. EntryID, Optional attendees.
The value for EntryID might be null because item is not yet witten on the exchange server, so the question is how to capture the EntryID of newly created appiointment item
Atul Sureka
EntryID is not set until the item is saved or sent, because it isn't added to the store otherwise.
You will need to do either of those things before you can read the entry ID.
I am trying to enable/disable checkboxes in treeitems in ctreecntrl of visual c++ 6.0. I have found the options to do that for all items, but couldn't do that per item basis. Is there any function to do that?
To turn checkboxes on and off for individual tree items, you need to send TVM_SETITEM messages, which are used to set attributes for items in a TreeView.
The documentation says the wParam must be zero, and the lParam is a pointer to a TVITEM structure that contains the new item attributes.
So the real battle is in getting the TVITEM structure filled out accordingly. Here are the important parts:
The hItem member must contain the handle to the tree item that you want to modify.
The mask member should be set to TVIF_STATE, which indicates that the state and stateMask members are valid. Those are the ones you'll be using to turn checkboxes on and off.
The state member can be set to 0, which will hide the checkbox for the specified tree item.
To show the checkbox for the tree item, set this member of 1 << 12. (See the docs for details).
The stateMask member should be set to TVIS_STATEIMAGEMASK to indicate that you're changing the item's state image index.
Since you've set mask to indicate that you're only using the state and stateMask members, you can happily ignore the rest of the members.
And finally, once you've got the TVITEM structure set, you can either use the standard SendMessage function, or the TreeView_SetItem macro, to send the message to the tree item.
(Of course, the entire TreeView must have the TVS_CHECKBOXES style set in order for any of the above to work! But you said you already figured out how to do that.)