1 / 12

Graphical User Interface

Graphical User Interface. Dr. Abraham Professor UTPA. Forms. Forms used to create GUIs for programs and it is a container for controls and components. Active window has a highlighted title bar and It has the focus

Télécharger la présentation

Graphical User Interface

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Graphical User Interface Dr. Abraham Professor UTPA

  2. Forms • Forms used to create GUIs for programs and it is a container for controls and components. • Active window has a highlighted title bar and It has the focus • When a control or component is dragged onto the form, visual studio generates code for it and can be viewed. • A programmer can write the code to place these controls as well. • See the example of adding pictures I discussed in class.

  3. Coding to add a button Friend WithEvents BtnMine As System.Windows.Forms.Button Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load BtnMine = New System.Windows.Forms.Button BtnMine.Location = New System.Drawing.Point(20, 20) BtnMine.Name = "BtnMine" BtnMine.Size = New System.Drawing.Size(75, 23) BtnMine.Text = "My Button" Controls.Add(BtnMine) End Sub

  4. Code generated for picture box PictureBox1 = New PictureBox PictureBox1.Image = Global.windowsForms.My.Resources.Resources._1 Me.PictureBox1.Location = New System.Drawing.Point(12, 51) Me.PictureBox1.Name = "PictureBox1" Me.PictureBox1.Size = New System.Drawing.Size(74, 97) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(284, 264) Me.Controls.Add(Me.PictureBox1)

  5. Now look at the program I discussed in class ‘PictureName = InputBox("What is the Name of the Picture?", "Picture") PictureName = "C:\vb2008\addPictures\" + PictureName pictBox = New PictureBox Controls.Add(pictBox) pictBox.BringToFront() pictBox.Image = Image.FromFile(PictureName) pictBox.Top = offset pictBox.Width = 100 pictBox.Height = 100 pictBox.Left = offset offset = offset + 10

  6. Change parameters in the code generated • Example comment picture box location • Add picturebox1.top • Etc. • You can learn coding for controls like this

  7. Control Properties & Layout • Tab Index • Enabled – focus • Anchor (remain at fixed distance from the sides) • Docking (Attaches a control to a container) • Labels, TextBoxes and Buttons. Password Textboxt box hides information typed. • Checkboxes,comboboxes, and radio buttons • Groupboxes and Panels to arrange controls and group them.

  8. MouseEnter, MouseLeave, MouseDown, MouseUp, MouseMove, MovesHover KeyDown, KeyUp, KeyPress, KeyChar, Handled, Alt, Control, Shift, etc. Keyboard & mouse Event Handling

  9. Rich Text Box • Writing a text editor. • File Opening and Reading • Writing to File • Drop Down Menus • Context Sensitive Menus • Changing Font attributes • See demo

  10. Other Features • Splash Screen • Check boxes and dropdown lists covered earlier • Background color change • Fade-in effect • Button tricks • See math game demo

  11. Printing to Default Printer • See demo

More Related