Y'herd thisun? 

“We well know, from repeated experience, how much misery and hardship men will undergo in their own country, before they can determine to desert it; and how often the most tempting proposals of embarking for new settlements have been rejected by people who appeared to be almost starving.”

from Principle of Population, Chapter 10 by Thomas Malthus

Your own image control and App part 18

TaggedCoding, VB, Imaging

Originally published December 2002 on 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.


18) Making the application

In your fresh new instance of Visual Studio, pick the Windows Application template to create a new WinForm project. Name the project "ImageTool". Rename "Form1" to "frmMain" and pull it open a bit to give room for two svImageEdit controls.

How big is big enough?

When it comes to imaging applications, the question of default form size is an important one. Unlike a typical database front-end that should easily fit in an unmaximized form, users will need forms big enough to show enough of their images at a realistic zoom to get their jobs done, and typically they'll maximize an imaging application as soon as it starts. Knowing that users will likely try to use as much of their display as possible when running your app, doesn't it make sense to design it for the typical resolution? If so, then what is the "typical resolution"?

I've got a nice viewpoint for this question because my wife works at a retail software company whose main products are very graphics intensive and whose target audience is regular people. The apps that they release, and they've got sales in the millions, all default to full screen. For development planning, her company does and/or buys market research on screen usage and the public information I've seen boils down to this:

  1. In the past couple of years, 640x480 has finally stopped being the most common resolution on end-user PCs
  2. 800x600 which is the typical target for developers even though it has consistently come in third behind 640x480 and 1024x768 for several years is NOT the new #1, 1024x768 is currently the most common end-user screen setting
  3. A significant percentage of machines built by the major vendors in the past year, especially new laptops, don't even support 640x480 on their pre-installed cards
  4. Because of high user demand and lower mass-production costs, LCD screens will soon pass by CRTs as the most common type of bundled display for mid and high pricepoint end-user systems
  5. LCD screens perform best at specific resolution with the current most typical native resolution being 1024x768 for 15inch entry-levels and 1280x1024 for mid and high point 17 and 19inch units
  6. Users tend to stick with the default resolution because they don't know how to change it or, in the case of LCDs, because they find the interpolations of lower resolutions unsatisfying.

Sounds logical. And yet, I know, it's so hard to get companies to believe it and default even an imaging app that could use the room to 1024x768. Go figure. Well, here's hoping those numbers might help get some older IT departments to move out of the silly 640x480 mentality.

For this demonstration, simply because I need to make screenshots for web and print I'll default to an unrealistically small 600x400 and you should make yours fit real end-user screen dimensions.

Toolboxing the control

Right click on the toolbox and select "Add Tab", in the new blank tab type "Custom Controls" and press Enter. Click on the new Custom Controls tab to slide it open, then right click on the new tab's area and select "Add Remove Items". When the "Customize Toolbox" dialog appears, verify that the ".Net Framework Components" tab is selected and press the "Browse" button (lower right of the dialog). Navigate to the compiled release version of the svImageEdit.dll file, select/highlight the file and click on "Open". Verify that the file has indeed been added to the components list.

Click on OK to close the dialog and verify that the control has been added to the toolbox. You can add an instance to your form to check things are ok but if you do delete it before moving on, we have to do other stuff first.

Setting the stage

Control sizing is important in this kind of app and because we know that eventually we'll have menus it's best to get one on the form straight off at least as a placeholder. Add a MainMenu to the form, rename it "mnuMain" and click on its visual builder to add a traditional "&File" item and using the property sheet rename this to "mnuFile".

That's enough to keep the menubar visible. As long as we're right there, go ahead and add a subitem for loading images and closing the app (Name="mniFile_Load" Text="&Load picture" and Name="mniFile_Exit" Text="E&xit"). Double click on the Exit item and add the Me.Close to its click event, we'll do the load stub in a minute.

Next: Adding the viewports

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