How do I setup the Actions/Outlets for 2 radio buttons, a calculate button, and a graph output in XCode? - xcode

The image above is a screenshot of what I've set up in my storyboard. I have 2 radio buttons, 3 static values, and a final calculate button.
The way it works is this:
User selects either radio button #1 or radio button #2. If she selects radio button #2, she must select a file from disk. This file will then be parsed by the function linked to the calculate button.
The user must provide the 3 static values in order for this to work.
After pressing the calculate button, the function will calculate some things and eventually feed some data into the graph to the Container View on the right.
Here's the catch - I am doing this all through VNC viewer, so I cannot ctrl + drag. I need to know how to set this all up using the Connections Inspector menu (which is the alternative for users who cannot ctrl + drag):
Does anyone know how?

Related

MFC: CListView: Why SetItemState(-1, 0, LVIS_SELECTED) doesn't work if multiple items were selected with SHIFT + arrow key?

Easy to reproduce problem using default MFC dialog application:
Add listview control and link it to CListCtrl class - m_listCtrl.
Enable "owner data" or LVS_OWNERDATA flag to enable virtual list view mode. Enable multiple selection and "Always show selection".
In OnInitDialog() add at least one column and call m_listCtrl.SetItemCount() to set number of items in the list to more than one.
Link button click with a method that calls m_listCtrl.SetItemState(-1, 0, LVIS_SELECTED); That call should deselect all entries in the list.
Click on item in the list and use SHIFT + arrow key to extend selection to at least two entries. If selection is extended with mouse or CTRL + click or CTRL + SHIFT, then the issue doesn't appear.
Click on a button that triggers SetItemState() call in step (4) and notice that items don't get deselected the first time. They only get deselected the second time.
Is that a bug in listview control or am I doing something wrong?
Calling m_listCtrl.SetItemState(-1, 0, LVIS_SELECTED); should deselect all entries with the first call, but it does so only when called twice.

how to remove previous item on user clicks or any button pressed

How I can add for example 10 item including text image and etc into the one slide of power point, and the slide Show start like this?
only the first item appears
on user click or any button pressed the previous item should be removed and second item placed instead of it.
One have to add text and image in a specific order on the slide.

VB6 + how to switch between windows/frame in form by buttons

I am very new beginner with VB6 and I hope I explain the things right
I want to create form with 2 buttons (the buttons are located on the top form position )
So each button will switch to other form/window/frame
For example
The first button will show window 1 (there I can set only parameters)
The second button will show window 2 (there I can set only IP address)
Please advice if we can do that by VB6 ?
And if yes how to do that ( step by step )
Remark - Similar example but with multiple windows in the same form is the system properties ( right click on my computer and properties ) , the we can see each button will view different window
Create a form with 2 buttons, Command1 and Command2.
On this form, create 2 frames, Frame1 and Frame2. hide Frame2 and make sure to line up both framesso that they are of the same size and located right on top of each other (Top, Left, Width and Height properties must be the same)
Now put this code in:
Private Sub Command1_Click()
Frame1.Visible = True
Frame2.Visible = False
End Sub
Private Sub Command2_Click()
Frame1.Visible = False
Frame2.Visible = True
End Sub
Now each the first button shows the first frame while hiding the 2nd. The second button hides the first frame and shows the seconds. I think this is the simplest way to implement your task.
PS: don't forget to name your objects properly, it's not a good idea to have default names like Command1 or Frame2 - should be more descriptive than that.
It sounds like you are asking about the tabbed dialog control. To use a tabbed dialog control in VB6:
Click Project -> Components
Scroll down to "Microsoft Tabbed Dialog Control 6.0" and select it.
Click the Apply button.
You should notice a new control in the component tool box. If you do not see the toolbox, click View -> ToolBox. This is the same area of the IDE where you first click to add a button to a form. The tabbed dialog control looks like the top tab of several file folders. When you hover your mouse over the control in the toolbox, you will see a tool tip text of "SSTab". Click this control and then draw a rectangle on your form.
By default, this will add a tabbed dialog control with 3 tabs, but you can change this in the properties window. You can now create any control on top of a tab of the tabbed dialog control and interact with the control exactly the same way you would if the control was placed on the form itself.
What you want is called an MDI Form. It's a form that contains other forms.
You can find a full tutorial on them here, but here's the gist of what you want to do:
Set the "MDIChild" property of all your subforms you want to use to True. Disable their minimize, maximize, and resize functions as well.
Create an MDIForm. Disable its AutoShowChildren property.
Add a toolbar to the MDIForm. Add buttons to the toolbar corresponding to the forms you'll be switching between.
Implement each button's click event, to create child form as expected (or switch to an existing one).

How to position a Popup menu right underneath a button in VB6

I have a VB6 app. There is a main form. It houses a user control. This user control has a button control. When I click the button, I want a menu to pop up so that the top left of the menu is right underneath the bottom left of the button.
if I do:
frm.PopupMenu mnuBlah
the menu comes up where the mouse is.
if I try to provide coordinates
frm.PopupMenu mnuBlah, btn.Left, btn.Top + btn.Height
the math comes out totally wrong and the menu is displayed way off target.
I am not quite sure what type of coordinates the PopupMenu call requires and how to calculate the position underneath the button.
PopupMenu wants X and Y coordinates in the ScaleMode of the form on which the menu is being popped up. In this case, that probably means the user control.
But it really depends on where you're handling the MouseDown event. (You don't get coordinates with the Click event.) If your event handler is in the user control itself, then you shouldn't have any problem using the supplied coordinates. However, the code you posted is missing the Flags parameter (should be vbPopupMenuLeftAlign), which could explain why your coordinate math isn't working. Plus, you have to define the menu as a property of the user control itself.
On the other hand, if you raise the MouseDown event out of the user control, and handle it in the containing form, the popup menu has to be a property of the containing form. In this case, you can ignore the X and Y parameters, but you have to do coordinate calculations yourself. The left edge of the button, relative to the main form, will be the sum of user control's left edge and the offset of the button within the control. Similar math will work to calculate the bottom edge of the button. In other words:
Private Sub UserControl1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
PopupMenu mnuPopup, vbPopupMenuLeftAlign, _
UserControl1.Left + UserControl1.Button.Left, _
UserControl1.Top + UserControl1.Button.Top + UserControl1.Button.Height
End Sub
Note that this will require that you also expose the button (Button) as a property of the user control so that you can access its Left, Top, and Height properties. That's easy enough:
Public Property Get Button() As CommandButton
Set Button = Command1
End Property
Raising the event is simple enough as well; just put
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
at the top of the user control, then use this:
RaiseEvent MouseDown(Button, Shift, X, Y)
in the MouseDown event of the button in the user control.
Finally, to wire up the event handler in the main form, use the two dropdowns at the top of the code editing window. Select the user control from the one on the left, then select the MouseDown event from the one on the right. This will insert the event handler, which you fill in with the code above.
As far as which way is better, handling the menu inside the user control itself, and raising meaningful events when one is selected keeps things separated. The user control handles the UI work, leaving the main application to handle whatever needs to be done in response to the user's selection, without worrying about placement of the menu.
So you wouldn't actually be raising the MouseDown event; rather you'd raise events like OptionOneSelected, OptionTwoSelected, or OptionThreeSelected. (More meaningful names would be much better, of course.)
Anyway, I hope this isn't too late to be helpful...
You need to pass the vbPopupMenuLeftAlign flag to the PopupMenu method. Note, this contradicts the documentation on the PopupMenu method (could Microsoft actually have made a mistake?), but it works.
frm.PopupMenu mnuBlah, vbPopupMenuLeftAlign, btn.Left, btn.Top + btn.Height
You need to include the height and left values for the parent container (this is usually the form, but could also be a frame, or some other container).
I think you're looking for something like this:
btn.Parent.PopupMenu mnuBlah, vbPopupMenuLeftAlign , btn.Left, btn.Top + btn.Height

GUI: should a button represent the current state or the state to be achieved through clicking the button?

GUI: should a button represent the current state or the state to be achieved through clicking the button?
I've seen both and it sometimes misleads the user. what do you think?
The label on the button should reflect what the button does, i.e. it should describe the change the button makes.
For example, if you have a call logging system a button should say "Close Call" and the user can click it to close the call. The button should not have the label "Call is Open" and the user clicks to change the call status as that's very counter-intuitive, since the button is effectively doing the opposite to what it says on it.
In my opinion the label - and so the function - of a button should rarely, if ever, change. A button is supposed to be a like a physical button and they usually only do a single thing. (There are a few exceptions like play-pause on a media player where it's OK for the button label/icon to change, but at least this is copying a button from a real physical device.)
To carry on the example from above, I would say usually you would want two buttons, "Open Call" and "Close Call" and disable whichever one is not appropriate. Ideally you'd have a field elsewhere displaying the status of the call.
In summary, buttons are for doing things not for passing on information to the user.
The button should represent the action to be executed, not the state.
Some buttons are actions and are not ambiguous, like "Save", "Print" or "Enable user".
When a button represents a state that can be toggled, like Enable and Disable something, I do one of the following:
Change the button text, and make it always point to the state that will be achieved; (i.e. make the button point to actions, not states);
- Keep the button's text the same, but use one of those sticky buttons that will stay pressed, representing that the current state is "on" or "off". I prefer the former approach, though.
It should represent the action taken when clicking the button. States should always be presented by other means.
But I know what you mean. My car radio has buttons with text that shows the current state. It is really confusing.
This depends on the function which will be triggerd by the button click.
if the click changes the state of an entity i would suggest that the button represents the state the entity will enter after clicking the button
if the click triggers some kind of functionality the button should represent the function.
The appearance of the button is also a clue to its state. It should follow the standards of the environment if any exist (example, beveled edge / shadow appears on mouse click in Windows).

Resources