Tuesday, January 06, 2009
Home
.Net
Return of the Repeater
Complete image control & app
Part 2 - Starting the control
Part 3 - Loading images
Part 4 - Custom exceptions
Part 5 - Fax/Multipage tifs
Part 6 - Custom events
Part 7 - Selecting fax pages
Part 8 - Rotating displays
Part 9 - The power of GDI+
Part 10 - Zooming
Part 11 - .Net's fatal exception
Part 12 - Fix the squishies
Part 13 - Zoom to fit
Part 14 - You beat the pros
Part 15 - Cropping
Part 16 - Bonus: StickyMouse
Part 17 - Finishing touches?
Part 18 - Make the application
Part 19 - Adding viewports
Part 20 - A better toolbar
Part 21 - Connect the toolbar
Part 22 - Adding ImageEditors
Part 23 - Toolbar ZoomCombo
Part 24 - VB3 style ease
Part 25 - Saving images to files
Part 26 - Integer-only textBox
Part 27 - Passing save settings
Part 28 - The last exception
Part 29 - Menus offer more
Part 30 - Book, app & source
Couple of CS Snippets
XML processing quickies
File extension extensions
McAfee.Not
cs IntBox
Floating Holidays
Code snippets
Flexible sorts
Converted deserializations
Autodeploy not found
Autodeploy just stops
VB must be killed
Media file attributes
Fastest file searches
Webservicing custom objects
Aspect correct resize
Funky thumbnails
Wide interval timing
VB2005 or bust?
Recurring events
Single instances
Proper proper casing
Simple address formating
Combo filling reminder
Easy gradient forms
Grrrr on interops?
Winform memory usage
Windows service your ISP
Pretty up VS code printing
Remote configs with no BS
GDI+ printing cd cases
Your own flat combo
Where's the splitter?
Full autoemail
ReessppoonncceeWwrriittee
Kill the back cache
Color to hex
Source to web
Recode without recompile
Prop snippet for VS2008
Database tricks

Your own image control

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


Print  

pagecomment
  Add Comment



Submit Comment
  View Ratings
50.00%0
40.00%0
30.00%0
20.00%0
10.00%0

Number of Comments 0 , Average of Ratings
  View Comments
No comment.


Privacy Statement  |  Terms Of Use
Copyright 2008 by Robert C. Smith