How to identify the sender of a WM_COMMAND message? - visual-c++

I am using VS 2010 c++. I have a dialog window containing an array of 126 identical pushbutton controls sharing the same value for control ID.
When a button is clicked and the host dialog window receives the resulting WM_COMMAND message, how can the dialog window identify which pushbutton is pressed?
I could use 126 different control ID values, but I was hoping for something a little more concise.
Can anyone help?

ID itself means "what identifies" an object. So you will need to have separate control ID.
There has to be something different about each button control to identify a particular one.
If you want to keep the same control ID, then you can keep track of the handle (HWND) of each button that is created and use the LPARAM parameter of WM_COMMAND message to identify the control by handle.
If you are having unique text for each button then you can use the text property also of the button.

Related

How Receiving WM_Notify in win32 python

I want to get notification to my Form or Dialog handle that one of the control(Ex Button) got its state changed by performing some action(Ex Selecting an Item from combobox) in the same Form or Dialog
I have tried to implement on_notify, but for some reason Its not getting called on occurrence of any event change in the form or Dialog
I need to get on_notify method to be called on any kind of style or state changed in my Dialog or form and also find which control sent the notification to the Toplevel dialog

Best practice in dealing with xpages extensions dialog box?

I have an extension pages dialog box that I placed in a custom control. The dialog box is used to search for cost centers and return information such as market, cost center number, cost center name etc.
A "Select" button is pressed and the dialog box appears. The user searches for and selects their cost center. The OK button is pressed and it closes the dialog box and updates the various fields on the xPage.
A couple of questions.
Currently the "Select" button on the CC needs to know and refer to the name of the dialog box control within the CC. Seems to me that this is not the best practice. My end user programmer needs to know the ID of that dialog box control within the CC. Is there any way for my "Select" button could "show" the CC and the CC would actually show the dialog box control?
My CC makes use of custom properties to store the various document fields from the selected cost center. The OK button then uses these properties to set the various fields on the xPage. This again does not seem to be a best practice. If I wanted to use that CC in another application then I might need to edit the code in the OK button. Is there a better way to deal with this? Like I can set properties for a CC when I drop it on my xPage, is there a way I can tell it the code that I want to execute when the OK button is pressed?
One thing I thought was to have properties for the fields that need to be updated by the OK button but that does not seem to be so flexible.
For the issue of needing to know the id not sure if theres a typo but I don't understand why its bad that a select button inside a cc needs to no the id of the dialog to open it? did you mean the select is outside the cc? either way have you tried anything like creating a property on the custom control so that from outside it you can set something maybe
<xc:mycustomControl showDialog="false">
and then when something outside it happens change showDialog and refresh the cc, then inside the cc you can have a before / after page load to determine what happens when showDialog is true / false.
For your second issue it sounds to me like this should be using a domino document structure. Rather than the dialog pulling out each piece and the ok button updating, what I would do is have a domino doc data source on the page. when something is selected through the dialog I would update the document this source is pointing to and have all the fields bound to what ever fields they need to be. This way after something is selected the fields will just update to what ever the document contains, and it will be much more re useable so long as the domino docs have the same field names

How can I get access to items of a modal dialog in MFC?

I just want to get access to an object in the modal dialog. The following example will explain exactly what I'm trying to do:
(This code is not working)
CAddDlg dlg;
CString S;
dlg.DoModal();
dlg.GetDlgItem(IDC_NAME)->GetWindowTextW(S);
MessageBox(S);
But an assert will fail and I can't get the text of the Edit control.
What should I do?
You can't access the controls of modal dialogs from outside. Even if you could, it's not a good idea. The caller of the dialog should not know how the data is represented in the dialog. What is now an edit control could be a listbox in the future.
The way to go is declare getter functions which you call after DoModal() (if it returned IDOK) and get the values there.
Check Can I return a custom value from a dialog box's DoModal function? for some examples

how to get rid of text selection in wxwidget combobox component?

In my program I want the user to be able to choose between some options so I was using wxChoice component. Unfortunately after user interaction (clicking a button) I have to show custom text (not from my predefined list). Everything works fine if I use wxCombobox control but the drawback of this approach is that each time user selects an element from a list, selected text is highlited. It is annoying. I want the component to be read-only like. How to achieve this ?
Some code to visualize my question:
wxComboBox* viewAngle = wxDynamicCast( owner->FindWindow
( ID_CHOICE_3D_VIEWANGLE ), wxComboBox );
viewAngle->SetSelection( wxNOT_FOUND );
viewAngle->SetValue(_("Custom View"));
EDIT:
This control is used to set camera view in 3D object viewer application. Possible options are like: top, left, right, etc. It is also possible that the user moves 3D object using mouse. In that case I want my combobox to display "custom view" string. However "custom view" should not be a part of combobox list because selecting this option does nothing.
wxWidgets default implementation alwasy marks selected text. Which might be misleading for the user because he might think that he is expected to input any text.
IMHO, the custom text should be added to the wxComboBox control, the program could just ignore it when user selects that option.
Also, the wxComboBox's wxCB_READONLY style could be used to avoid the highlighting thing.

How to get menu item selected event in Carbon

I'm trying to handle events related to clicking on or pressing enter on a menu item using the Carbon API in OSX (Cocoa is not an option).
I know about EventTypeSpec and kEventClassMenu and i've dug through the header files looking for the relevant kind constant to use, but i'm still a bit confused as to how I respond to the selection of a menu item. Do I need to handle a key down or mouse down event at the same time as a kEventMenuTargetItem? Do I need to handle kEventMenuMatchKey separately for the enter key?
I'm an idiot.. Events caused by menu items are handled by class command. So:
eventTypes[0].eventClass = kEventClassCommand;
eventTypes[0].eventKind = kEventCommandProcess;
will handle menu events.

Resources