How do I invoke an ActiveX control's property page? - c++

I have created an ActiveX control that uses five different colors. I would like to the control's property page to let the user choose the R, G and B values for each of the five colors. That won't be a problem. My problem is: how do I display the property page? For the sake of this question, let's say I want to connect it to the control's double-click event. The user would double-click on the control and the property page dialog box would appear. What code would have to be in the event handler to do that?
And yes, I know I'm working with antique technology. So is the rest of my company, and far too many other companies.
In case it matters, I'm writing the control in C++ using Visual Studio 2012.

As I was about to ask this question over on reddit since I don't have an answer here yet, it occurred to me that one would want to invoke a control's property page from the control's container, not the control itself. So, I went to my test application, typed my instance's variable name, and Intellisense showed me that the control has a property named ShowPropertyPages().

Related

Does MFC CRichEditCtrl has a display level?

i'm currently working on a legacy project in MFC.
I encounter an issue where i create a bunch of CRichEditCtrl objs in the view, many of them are overlapping each other. When i select them, the visual is totally messed up.
Is it possible to click on a particular control and bring it to the "foreground". so i can edit on that particular control?
Other question is that is there a way to distinguish those controls dynamically?
I know when i create them, the last parementer is their ID. But when i click on those, i want command handler in parent dialog or view knows which one i'm about to edit.
Thanks in advance

Sitecore 8, MVC, Experience Editor: How to make a rendering refresh after a Field Editor Button has been used

We have a rendering listing the selected items in a TreeSelect in the current item. In our case we call them "Tags" (1)
We have added a Field Editor Button to the component to let the editor change selected items. (2) (As described on for example Adding a custom component)
When an editor clicks (2) the editor window (3) it is opened in a dialog. The editor may select different items(called tags in our case) using the TreeSelect.
When the editor presses the ok-button (4) the values are set.
Now to the problem:
The values are actually set as they get stored when the editor presses the Save button but we want our list on the page (1) to immediately reflect the set items when the editor presses the ok-button (4), i.e. before having to actually save the whole item.
How do we achieve that?
(I am in contacts with Sitecore support but so far I have not gotten any answers...)
Update
After a lot of conversation with the support we still have no useful solution.
We tried turning it into a field renderer displaying the links.
What worked was:
The field do get updated when you have edited it in the popup field editor. (but...)
It looks good the first time when page is loaded.
You can make a WebEdit button with commands to edit the field and add it as Custom button to the field (register <command name="webedit:fieldeditor" type="Sitecore.Shell.Applications.WebEdit.Commands.FieldEditor, Sitecore.Client"/> and set Click on the button to webedit:fieldeditor(command={3473DDA1-2983-493C-AF7A-054C75AA7AD3},fields=NameOfField where the guid points to itelf and an "Icon" is set on it.)
What didn't work was:
The field get updated by the raw value, not what I want to display. Server code is involved, but not in the rendering of html-code.
When I want to edit the value in the field editor, the value sent to the field editor is not the raw value but what actually is displayed on the page. (I guess this can be solved somehow)
The issue to the support turned into a feature request to let the server be involved in rendering the field, not just sending a new value to the JavaScript updating it. The server does the first rendering so when it already is involved in updating, it should be allowed to do the rendering the following times too.
We have decided to not spend more time on this right now (we have other things to do too.) and have a bad editor experience as the field not get updated until the editor actually saves the item.
Still we have no suitable solution for this issue. If you want to keep working on it and want a reference to my issue it is 439059.
This may not be useful here. I've done this in normal sites, but not in Sitecore. But, here's one possibility....
This is a situation where you would pass a callback function to the child popup window. This callback will cause the caller / parent window to re-read/re-load the information that was just updated by the child.
Example:
User presses (2) to open Editor Window(3) (Editor window is opened and the Callback function is passed as a parameter)
User presses "OK" button (4). The "OK" button event handler updates the changes, then calls the Callback function which re-loads the now updated information, and closes the popup window.
Once the popup closes, the parent window now displays the information that the popup/editor just updated.
This takes some client side javascript (jquery) development but it is quite do-able normally.

windows forms, how to launch a separate window with datagridview?

I've some data that can be shown on grid attached on a panel. When user clicks some button i'm showing this panel. Now i wanted to launch this grid in a separate window(should be a child to existing window) and want to make the grid editable, click controls...etc, is it possible?
thanks in advance.
You should be able to achieve this effect by placing your grid on a separate form, complete with editing stuff. Disable the form and set its parent, (see control.parent), to be the main form panel. When the user wants to edit it, set the grid-form parent to nil and enable it.
Not actually tried this with WinForms, but it works fine with Delphi VCL so worth a test if no better answers are forthcoming
Rgds,
Martin

MFC: How to create options dialog with listbox and multiple pages?

Developing using Visual Studio 2010 C++ and MFC. I want to create an options (preferences/settings) dialog box that can display several options. After considering many different options dialog box UIs I think I like the listbox-with-multiple-pages-style similar to visual studio's option dialog box (but I don't need the treeview, a list box is fine).
What's a good way to implement this? Do I use a CListBox and then handle the selection event to load up the individual pages? I'm new to MFC, what would the individual pages even be? Something like a panel? Ideally I would design them in the resource editor and then be able to load them up.
Take a look at http://www.codeproject.com/KB/dialog/embedded_dialog.aspx for one possible way of doing this.
The individual property pages can be designed as dialogs in the resource editor, and then the relevant page can be displayed in your main dialog depending on the selection in the list box, by handling the LVN_ITEMCHANGED message.
See CPropertySheet and CPropertyPage classes. This allows you to easily manage a properties window with several views.

Win32API: How to determine if EN_CHANGE was because of user action, not software action?

I find this situation comes up from time to time, and I never seem to have a really robust generic solution to it.
I have a control - in this example an EDIT control on a dialog. I want to take certain actions in response to the user - and only the user - modifying the contents of the edit control.
The edit control can be set programmatically - e.g. when the dialog is being setup, there may be an initial value placed into the edit field. Or when the user selects an item from a listview, that selection's text may well be what's placed into the edit field.
But when the user modifies the contents of the edit field, I need to know that, and respond (in this scenario, I want to clear the selection from the corresponding listview).
I am currently looking at what control has focus, and only considering EN_CHANGE's to be "from the user" if the edit control has focus.
This works beautifully under Windows 7. This fails under XP (I haven't tested Vista yet).
In XP, if the edit field has the focus, but the user clicks on the list view, and the list view tells the edit control to set its contents, then I get a notification from the edit control which claims to still have focus (::GetFocus() == HWND of edit control). But this incorrect state doesn't occur in Win7.
This is a layered interface, so I cannot modify the list-view notification handler. It gets a selection change, and updates the edit field without my involvement or ability to really intervene other than to get notifications from both of them.
Any thoughts on how to generically, permanently solve the "Is this control notification really from the user" conundrum?
You can always track LVM_ITEMCHANGING, LVM_ITEMCHANGED, and EN_MSGFILTER messages. If the edit box is modified between LVM_ITEMCHANGING and LVM_ITEMCHANGED without an EN_MSGFILTER in between then you can probably assume the user did not modify the item. Or just check to see if there are any items selected when EN_CHANGE fires and if not or the text doesn't match the selected item, assume it is a user edit.
Or use ES_MULTILINE (from EN_CHANGE documentation):
The EN_CHANGE notification is not sent
when the ES_MULTILINE style is used
and the text is sent through
WM_SETTEXT.
I'd suggest using the right message. EN_CHANGE is too generic, you want to know if the user typed or pasted text. So why not subclass the control and watch for WM_KEYPRESS messages?
Alternatively, you can set a flag in your other code that sets the edit control content. You might be able to assume that anything that makes your wndproc re-entrant represents a programmatic change.
You aren't looking for something actually secure, are you? If you just want to exclude set content calls that's fairly straightforward. If you want to differentiate between user action and programmatic simulation of user keypresses, that's a much harder problem.