I have 2 custom dialogs. They are essentially copies of each other. The idea is that there are some scenarios when the user will be presented with both dialogs, and when that happens, it is highly likely that most/all of the data will be the same, but there is a chance that it won't all be the same, and the user needs to be given the opportunity to have different values between the two dialogs.
What I'd like to do is either default the values in the second dialog to the values of the first dialog, or have a checkbox in the second that will copy the values. Either way, I need to be able to set the property values. I can either do it automatically when the user transitions between the two dialogs, or do it upon the user checking a checkbox. I would be happy with either solution.
I've looked into the SetProperty element, but from what I understand, that only works on pre-defined MSI actions, and I don't believe any of those actions will work for me.
Any help would be appreciated.
I figured it out. I was looking in the wrong area.
I ended up going with a PushButton as it actually made more sense.
I was able to copy the values when the user clicks the PushButton using the Publish element under my UI element. My Publish element looks like this:
<Publish Dialog="TargetDialog" Control="CopyButton" Property="PROPERTY_NAME" Value="[SOURCE_PROPERTY_NAME]">1</Publish>
I have 4 more of the same publish tag, with the only difference being the property and value attributes.
I hope this helps other people!
Related
To illustrate what I'm asking, let's say I have a custom TextBox that has 2 modes. Mode 1 only allows numbers, and mode 2 only allows dates in a particular format.
Using a class module I can create this custom TextBox, and I can use a loop when the userform initialises to set which TextBoxes are custom.
What I'd like to happen is have the custom TextBox, or what ever custom control I want, show up in the toolbox. And I also want its custom properties, if they exist, to show up in the property window.
So far, I've been unable to find a way to do this. In fact, I've been unable to find out if it's even possible. It seems, to me anyway, that it's something that should be possible, but maybe I'm barking up the wrong tree. If it's possible I'd really appreciate being pointed to a resource.
I have my form with a menu bar and space underneath to display my controls. One of the buttons in my menu bar is suppose to be a print button that prints a graph that's currently in a User Control I display in the form. If the graph was on the form in the print button's eventhandler I could just simply call
graph.printing.print(true)
which isn't going to work in my case since the graph is in the control and not the form.
How do I communicate with a User Control from the containing form and access or pass its variables when needed? I also have a status bar on the bottom of the form which would also need to get updated from the User Control, but I'll be able to deal with that if I got help with just this one part. Please bear in mind, I also have another User Control I'm going to add to the form which will also contain a graph which will need the same treatment as the other graph on the first control when the print button is pressed. I plan on swapping these two out so I have one form displaying one control at a time.
I got this idea from this answer: https://stackoverflow.com/a/18191630/2567273 but after further research I can't find anyone asking about the actual communication process between a form and the control it contains.
I think this answer is close to what I'm looking for, but I think it's leading me down the path to using panels instead of User Controls.
After typing this I noticed the closest answer to my question may be this, but that question has the child raising events and the parent responding while I have the parent raising the event and the parent has to get information from the child.
One way to think about this is Roles. Presumably you built this UserControl to handle the management of the data related to the graphs. As such you can think of them in the Role of a Graphs Specialist . Once you do that, printing them is actually just one more thing it should perhaps do.
The form on the other hand, is not special just because it happens to get receive the command from the user to print. Its role in this might simply to be to know which usercontrol to contact and which method to invoke:
Sub PrintGraphMenuClick....
Select Case something ' determinant as to which UC to contact
Case operation.Foo
ucFoo.PrintGraph
Case operation.Bar
ucBar.PrintGraph
Other menu options like Clear, NewGraph, Save and whatever else there is somewhat the same way. The Form's Role here may be to receive the command from the user and pass it along to the right control, invoking the correct right method and passing the correct parameters - that is not a trivial task.
Of course, rather than a MainMenu, the usercontols could alternatively implement a ContextMenu and even receive those commands directly.
Very often offloading an operation to something else results in so many properties, filenames, streams etc having to be moved from here to there that it becomes burdensome. In this case it is not like the MainForm has some special ability regarding printers that the UserControl cannot handle.
There is only one right solution:
1) Add an event to your user control.
2) Raise the event when the particular "thing" happens in the user control.
3) Attach a handler to the event in Form code.
4) Add code to update the bottom bar in the event handler.
Having a bit of a problem doing this and not sure of it can be done. I have an edit control that a user types into, I would like for the input to be all in capital letters. I tried having a custom action on the edit control to get the property, convert to capital letters and set the property again each time a letter is set but it does not work. I guessed it wouldn't but no harm in trying..:)
Has anyone else solved this? I would like to do it without having a button to press if possible. The dialog in question is a twin dialog if that helps at all.
Thanks for your help
It's not possible using the native built-in Windows Installer UI. The underlying MaskedEdit Control is primitive. There are no events to tie into to validate and modify as the characters are entered. You can only ToUpper() the property when the user clicks Back or Next.
The alternative would be to go with an external UI handler which is a lot of learning and work.
Starting off with what I need the end result to be:
Customer is able to paste a product key, of the correct format, off of the clipboard into an input box during the install.
Where I am at the minute:
We use WiX to create our MSI. We currently use a masked edit control which works fine. The product key verification is already done using a custom action when pressing the 'next' button. The product key verification should remain the same, only the input method is the issue.
I've spent the last day researching the possible ways of achieving this and have a few ideas, although i'm not sure if any of them will work. I've already ruled out trying to trigger a custom action on paste because I know MSI has no way of capturing that event.
So, my thoughts are a 'paste from clipboard' button. This would trigger a custom action which would capture the clipboard item, decide whether or not it looks like a product key (that would be the easy part) and then somehow paste that into edit control. Note how I say edit control, I'm not sure it would be at all possible with a masked edit control and i'm not certain it'd even work with a standard edit control. I already have a custom action which manages to check whether the licence text has been viewed, and this is achieved by finding the window and the 'richedit' class window where the licence resides and retrieving the scroll position. I had thought that this method may allow me to set the edit control to my clipboard key, again though, I'm not certain this would work.
I have already read about the possibility of writing my own UI controller. I know this is a big task but nothing is ruled out at this stage, I just have no idea where to start.
My final idea, although I have no thoughts on how it could be implemented, would be by changing my masked edit control to a standard edit control, which would obviously allow the full product key to be pasted, although without using a custom action to verify it is in the correct format i'll still be no further forward. But this would then require for some sort of automatic adding of dashes if the customer was to type the product key in manually.
Could anyone can shed any light on the feasibility of any of my ideas and how to implement them or any other ways of meeting my goal?
I have managed to do this using the 'paste from clipboard' option I originally thought of. I added a button to my form, which calls a custom action which queries the clipboard and, if successful, sets two properties in the installer. One containing the formatted product key, and one a basic property to tell whether or not the clipboard operation has been successful or not. The masked edit control is linked to the product key property, and by refreshing the control,
<Publish Event="Reset" Value="0" Order="3">ClipboardSuccess = 1</Publish>
the product key is populated in the masked edit control.
I am creating a web control in vb.net that contains a list box. I know that I am able to choose a selection mode of Single or Multiple, but I am interested in limiting a Multiple selection to a predetermined size. For example preventing a user from selecting more than 3 items.
I have tried adding a Validator to the list box, which might be a way forward, but was wondering if there was a way of changing the selection mode to something a bit different than just the two specified ones.
Any ideas or suggestions would be greatly appreciated
Edit: Unfortunately due to project limitations I am unable to use Javascript on this problem. very annoying I know!
You could try handling one of the SelectedIndexChange events. With multiple selection, each time this event fires you can check how many items have already been selected. If it is more than you want, have the handler deselect the one that was just selected. You could also put up a little red label under the listbox saying "Sorry, no more than [n] selections allowed."
EDIT:
Just noticed you said WEB. Same theory applies, but it would have to be done using Javascript.
On the SelectedIndexChanged event, write a short piece of code that will check the number of selected items and if it is greater than your desired amount, unselect the new selection (or unselect the oldest one, or however you wish this to operate).