smithvoice.com
 Y'herd thisun? 

“Want to hear the last-ever space shuttle landing sonic booms echoing across the Los Angeles basin? It's neat!”

from this av page by smith

Your own image control and App part 23

TaggedCoding, VB, Imaging

Originally published December 2002 on DoItIn.net using VB7.0/2002. Updated for VB7.1 February 2005

Links for compiled demo versions, all required resources and source code are included at the end of this article.

Plus, get the complete eBook in Adobe Acrobat 7 format ... all here.


 

23) The toolbar ZoomCombo

We'll need a way to specify the zoom amount and instead of dealing with the annoyance of validating freeform text we'll let the user pick from values in a combo. Add a combobox to our toolbar is a piece of cake but it's a drag that so many controls don't automatically use the XP flat style with flyover color changing.

Rather than jumping through the hoops of COMCTL swapping with a manifest pointing to COMCTL6, I prefer a usercontrol that lets me change all the properties AND that looks flat on any version of Windows. The code for mine is here on Smithvoice.com, it's an old fashioned VB constituent control ported up from VB5 and it works just fine ;-).

Add a new usercontrol named "svFlatDropDownCombo" and paste in the code from that page. Rebuild the project so the usercontrol is available for use and update the AddxxxToolbarButtons subs to stick an instance in between the down and up zoom buttons (note the added labels for spacing):

 

...
 
ctl = New Button
ctl.Name = "butZoomMinus"
ctl.Text = "zoom out"
ctl.Width = 23
CType(ctl, Button).FlatStyle = FlatStyle.Popup
CType(ctl, Button).ImageList = ilToolbars
CType(ctl, Button).ImageIndex = ToolbarIconIndexes.ZoomMinus
.Controls.Add(ctl)
 
'Combobox starts here
 
'spacers are just labels
ctl = New Label
ctl.Width = 2
CType(ctl, Label).BorderStyle = BorderStyle.None
.Controls.Add(ctl)
 
ctl = New svFlatDropDownCombo
ctl.Name = "svcboZooms"
ctl.Text = "0"
ctl.Width = 40
CType(ctl, svFlatDropDownCombo).DropBoxItemsClear()
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("5")
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("10")
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("20")
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("50")
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("75")
CType(ctl, svFlatDropDownCombo).DropBoxItems.Add("100")
CType(ctl, svFlatDropDownCombo).Text = "20"
.Controls.Add(ctl)
 
'spacers are just labels
ctl = New Label
ctl.Width = 2
CType(ctl, Label).BorderStyle = BorderStyle.None
tbrSource.Controls.Add(ctl)
'Combobox ends here
 
ctl = New Button
ctl.Name = "butZoomPlus"
ctl.Text = "zoom in"
ctl.Width = 23
CType(ctl, Button).FlatStyle = FlatStyle.Popup
CType(ctl, Button).ImageList = ilToolbars
CType(ctl, Button).ImageIndex = ToolbarIconIndexes.ZoomPlus
.Controls.Add(ctl)
 
...

F5 and test...

Next: Back to VB3, hooking up widgets

Robert Smith
Kirkland, WA

added to smithvoice march 2005


jump to:

  • 1) The spec
  • 2) Setting up the workspace
  • 3) Feature 1: Loading an image
  • 4) Custom Exceptions
  • 5) "Fax images" and Multipage TIFFs
  • 6) Custom events
  • 7) Selecting specific fax pages
  • 8) Feature 2: Rotating image displays
  • 9) The most useful tool in GDI+: DrawImage
  • 10) Feature 3: Zooming
  • 11) Handling the unhandleable exception
  • 12) Fixing the squish
  • 13) Zooming to fit the control
  • 14) You're already beating the Pros
  • 15) Feature 4: Cropping
  • 16) Bonus Feature: StickyMouse
  • 17a) Final Cleanup
  • 17b) Passing the current display image
  • 18) Making the application
  • 19) Source and result viewports
  • 20) A better toolbar
  • 21) Hooking the toolbar to the project
  • 22) Adding ImageEditors
  • 23) The toolbar ZoomCombo
  • 24) The final solution
  • 25) Saving to image files
  • 26) An integer-only textbox
  • 27) Passing save options between forms
  • 28) Dealing with that last exception
  • 29) Offer more options with menus
  • 30 The downloads and ebook


  • home     who is smith    contact smith     rss feed π
    Since 1997 a place for my stuff, and it if helps you too then all the better smithvoice.com