Code Examples
  Home arrow Code Examples arrow Populating a dropdown box from a database....
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Populating a dropdown box from a database. Then incorporate a Javascript Jump Menu (OnChange Event)
By: Steve Hughes
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 46
    1999-10-10

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    [italic]This pre-publication chapter is from the book [/italic]DirectX8 and VB.NETDevelopment[italic], by Keith Sink (0672322250). [/italic][bold]In This Chapter[/bold]What Is DirectX?A HistoryWhy Visual Basic and DirectX? DirectX Uses The DirectX Components [bold]What Is DirectX? [/bold]DirectX is the building block used to create many of the Windows-based video games and multimedia applications we all enjoy today. It is a collection o ...[italic]This pre-publication chapter is from the book [/italic]DirectX8 and VB.NETDevelopment[italic], by Keith Sink (0672322250). [/italic][bold]In This Chapter[/bold]What Is DirectX?A HistoryWhy Visual Basic and DirectX? DirectX Uses The DirectX Components [bold]What Is DirectX? [/bold]DirectX is the building block used to create many of the Windows-based video games and multimedia applications we all enjoy today. It is a collection of ActiveX objects that encompass many of the elements used in video game and multimedia development. DirectX provides graphics support for animation, music and sound effects support for game excitement, and multiplayer support for network games. It also contains libraries that access the game devices and gives you the ability to work in 3D graphics. In a nutshell, DirectX is a collection of technologies designed to encapsulate much of multimedia development.[bold]A History[/bold]To better understand the architecture of DirectX, you need to understand how it came about and why it was needed.[bold]The Early Days[/bold]Since the early days of video game development, game developers had to relyon detailed knowledge of the hardware they were working with. This knowledgecame from lots of experimentation and electronics know-how. For example, to create some of the earliest games, such as Pong or Asteroids, game designers had to have a good understanding of what each chip on the game motherboard could give them. They needed to know how much memory they had to work with, what colors were available, and how to produce them. In some cases, they had to go to manufacturers and ask for help designing chips to achieve what they wanted to accomplish. Sound and graphics capabilities were primitive at best, but they managed. Because these early games were truly a pioneering endeavor, they also had to create new user controls to work with. These efforts resulted in a unique developers: part designer, part engineer. Because of the advanced knowledge needed to create arcade games in this environment, there were very few game designers.[bold]The DOS Days[/bold]From the early technologies of arcade game developers and computer scientistsarose the personal computer. With this invention, the need to know the chips wasreplaced with the need to know a programming language. As computers andprogramming languages evolved, more and more software people turned to gamedevelopment. Some of the early computer games were very simple. They reliedheavily on text-based and rudimentary graphics, much like the early arcade days.As computers developed in their capabilities, so did the games.Early DOS games required knowledge of machine and assembly languages toaccess the operating system's lower levels. As time went on, moreuser-friendly languages were created, such as BASIC and LOGO; however, theydidn't have the power of assembly language. Then came such languages asPascal and C. With C, game developers could write advanced code routines withouthaving to write tons of assembly code, thus making development efforts easier. Csoon became the preferred language of game developers. Through all these language changes, one problem remained. To write good games, developers still needed an in-depth knowledge of the hardware they were working with. They no longer had to know each chip's capabilities, but they had to understand things such as video cards, sound cards, and input devices. They also had to deal with memory constraints, which were becoming a hindrance to game development.[bold]Along Came Windows[/bold]With the development of Microsoft Windows and other operating systems,creating standards in the computer industry became much easier. These standardsincluded hardware interfaces, video memory standards, sound standards, and CPUmemory specifications. However, there was still a lot of dissension in theindustry, and not all hardware behaved as advertised on the Windows operatingsystem. As a result, many games written in Windows had problems and sufferedfrom performance hits. Microsoft realized this problem early on and focused itsefforts on standardizing its environment and working to increase performance forthe parts of the operating system that pertain to game and multimedia needs.These efforts were demonstrated in Windows 95, one of the first operatingsystems that made consistent hardware-software interaction a reality. Becauseall hardware manufacturers had to meet a similar standard and Microsoftcontrolled how its operating system communicated to the hardware, developmentbecame standard as well. In the DOS days, you had to create your own drivers foreach type of video card, but with Windows, you had to develop to only onestandard. Instead of spending time creating and understanding so many hardwarespecifications, developers relied on Microsoft to do all that for them andpackage it for their use in the OS. There was one flaw with all of this. Windows was originally designed for the home and office, not for multimedia development. It lacked a few essential items that had become standard in the multimedia market—particularly graphics speed, which could no longer be achieved in the Windows environment as it had been in DOS. It was the same hardware, but there were many more layers between the developers' code and the hardware they wanted to control. The result was that many developers abandoned the idea of Windows game development and relied on the Windows ability to shell out to DOS. [bold]Then There Was DirectX[/bold]After Microsoft realized that game developers agreed with its concepts butweren't willing to give up the performance they had become accustomed to inDOS, Microsoft began researching ways to enable developers to get to thathardware layer. Some of the early attempts included WinG, WinToon, and OpenGL.WinG came into the software spotlight around the time of Windows 3.1 andWindows for WorkGroups. WinG was the first attempt at a full-blown graphics API(Application Programming Interface) library to overcome the limitations of theWindows API. WinG supported high-performance graphics techniques that opened upthe Windows game development world to those people who worked exclusively inDOS. WinToon was an early API for Windows 95 that provided the capability of easyanimation playback. On top of full-screen playback capabilities, this API alsooffered quicker performance than existing Windows 95 APIs did. This technologyhelped improve the multimedia playback capabilities of animation programs suchas kids' games and teaching programs.OpenGL is a powerful set of APIs that allowed developers to cut through theWindows red tape to get to some of the hardware capabilities of 2D and 3Danimation. Surprisingly, OpenGL was not created by Microsoft, but by SiliconGraphics, Inc. Silicon Graphics is one of the pioneers in 3D special effects,however, so it's not that surprising. Several games today still use OpenGLas well as DirectX because many video cards support both these technologies.These technologies were a great boost, but ultimately came up short. As thegame market exploded and the need for more games on the Windows 95 platformincreased, developers at Microsoft went back to the drawing board. What theycame up with was the Windows 95 Game Software Developer's Kit (SDK), whichcontained the first version of DirectX. DirectX was initially just for thecomputer game industry but has evolved to include other areas, such asinnovations in the arcade industry and handheld Windows CE devices. As DirectXhas developed, Microsoft has added network support, force feedback support, and3D graphics capabilities. When innovations are needed, the DirectX team hascontinued to increase the capabilities of this remarkable software library. Microsoft has also made it easier for DirectX to be used by more than one language. C and C++ had become the game developer's language of choice, so DirectX and the examples included with the SDK were designed with C developers in mind. As DirectX has become more accepted, and Visual Basic (VB) taken more seriously as a programming language, DirectX and Visual Basic have finally come together. It also hasn't hurt that Microsoft has been encouraging VB users to start using DirectX 7 in their applications.[bold]Why Visual Basic and DirectX?[/bold]So we come down to the question of why DirectX is now available to Visual Basic developers but wasn't available before. To understand this issue, you need to see how VB has evolved as a viable programming language.[bold]The Evolution of Visual Basic[/bold]Visual Basic is an offshoot of an early programming language: BASIC. Personalcomputer users have always used BASIC and other languages like Pascal to createtheir own simple, personal games. However, BASIC was not widely accepted as anefficient enough language to create serious, mass-produced video games. After the creation of the Windows OS, most developers still found themselvesconfined to low-level languages such as C to create applications for this newplatform. Microsoft, seeing that it needed as many developers on its side aspossible, invested in a new language called Visual Basic. Visual Basic offeredan easy-to-use interface, a language that was simple for first-time programmersto grasp, and the ability to create Windows programs quickly.Although early versions of Visual Basic were not respected in the programming industry, VB soon found its own niche. After outside companies began making new controls and add-on modules for the VB environment, Visual Basic developers became more in demand. They could create a Windows application in half the time a C developer could. The Visual Basic environment, however, was too slow to handle graphics-intensive programming like games. Early VB game programmers had to rely on puzzle games and card games. Until recently. VB didn't have anywhere near C's speed or reliability, but that has changed. With Visual Basic 6, the gap is closing. Many consider Visual Basic 6 to be almost as fast as C++ code. It still lacks some of the true object-oriented aspects of C++, but it's giving C++ a run for its money. [bold]DirectX for the Masses[/bold]It was a logical next step for the DirectX team. The bottom line is that the more people use DirectX, the more popular it will be and the quicker it will become the industry standard. DirectX came home to Visual Basic in the form of DirectX 7. First with DirectX 7 and now with version 8, Microsoft has continued and enhanced its commitment to the VB community. DirectX 8 now includes a DirectX type library for VB users and ActiveX-compliant programs to access the advanced graphics, sound, and multiplayer technologies reserved for the C developers. This addition has opened the floodgates for DirectX development. With DirectX, VB developers can now create the games they always wanted, the multimedia projects they had to rely on C++ for, and much more. [bold]DirectX Uses[/bold]DirectX has the power to create and manipulate complex images and sounds. These features, combined with the ability to register user input and its network capabilities, make it a powerful library. With this library, you can create Kiosks that show off your latest products, games that have surround sound and stereo audio effects, and many other multimedia applications. The possibilities are limited only by your imagination.[bold]Showcasing Products[/bold]One of the best uses of the DirectX object model is to create applications that can show off your products. For example, you could create a fully interactive demonstration to showcase a product such as a new car. You could change the car's exterior color or upholstery color. You could also see what the dash would look like with different options, such as the latest sound system, installed. Figure 1.1 shows how DirectX could be used to showcase a vintage car.[bold]Figure 1.1 Showcasing a product.[/bold] [bold]Musicand Sound[/bold]With sound, you could take the previous example a little further. How would you like to let the people looking at the car in your kiosk be able to listen to their new sound system? With DirectX, you could allow users to turn on the virtual stereo and listen to the difference in the types of sound systems your company offers. Figure 1.2 shows an example of a music selection program.[bold]Figure 1.2 Music and sound.[/bold] [bold]UserInteractions[/bold]What good is a program if users can't interact with it? One of the foundations of multimedia is the process of incorporating users' input into the experience. This feature draws users into your application and lets them decide the course of action. They can choose what doors to open on your virtual car, or they can move a joystick to defend the galaxy from its worst enemies. Through multimedia interaction, you can pull the user into your application. In Figure 1.3, the user interface allows the user to choose an answer to a trivia question.[bold]Figure 1.3 Trivia question user interaction.[/bold][bold]Screensaversand Multimedia[/bold]One of the fascinating things that can be done with DirectX is creating screensavers. Through Visual Basic, screensavers and similar multimedia applications have been around for some time. The advantage of DirectX coming onto the scene is that the graphics are much faster and smoother, the sound quality is much better, and the overall experience is much more enjoyable. Figure 1.4 shows a simple screensaver with animated bouncing balls.[bold]Figure 1.4 Screensavers.[/bold][bold]GameProgramming[/bold]Game programming, of course, is a big part of the DirectX experience. With DirectX, games can be created for the Windows platform with less code. Because DirectX uses standard hardware drivers, there is better control over the hardware itself, which results in better hardware performance. Figure 1.5 showcases a simple game with a snowman as the main character.[bold]Figure 1.5 Snowman game. [/bold][bold]SynchronizingData[/bold]One of the really remarkable features of DirectX is its ability to synchronize data across modems, a network, or even the Internet. With this feature, it's possible for developers to make complex programs that send and receive transmission packets across the great divide. A good example of synchronizing data can be seen in Figure 1.6, which shows an application that allows users to talk with each other instantly across the Net.[bold]Figure 1.6 Synchronizing data.[/bold][bold]TheDirectX Components[/bold]The DirectX architecture is made up of many components. You can work with 3D graphics by way of Direct3D. DirectDraw gives you access to many of the animation technologies used in the game industry for decades. DirectInput enables you to understand user input from the keyboard, mouse, and joystick devices. DirectMusic and DirectSound give you access to the sound used in games today. Network capabilities, which are popular in many of today's games, come to you in DirectPlay. DirectX has not forgotten about ease of setup, either, so DirectSetup, which supplies an easy-to-install interface for DirectX, is included with the other DirectX components. Figure 1.7 shows a hierarchical layout of all the components that make up DirectX.[bold]Figure 1.7 An architectural overview of the DirectX object model.[/bold][bold]Direct3D[/bold]For those of you who love 3D animations, Direct3D is a fantastic addition to DirectX. With Direct3D, you can use DirectX to create complex 3D graphics on hardware that supports 3D rendering. The Direct3D component includes lighting effects, materials, and shading. Direct3D is also referred to as the DirectX Graphics component.[bold]DirectDraw[/bold]DirectDraw is the heart and soul of DirectX 2D graphics, giving you many of the features needed for basic animation, such as blitting, clipping, and flipping. DirectDraw provides the methods for developers to talk directly to the graphics hardware without having to learn how each piece of hardware works. It allows for complete hardware independence.[bold]DirectInput[/bold]DirectInput enables the developer to open up communication with the input devices needed in computer games and multimedia. DirectInput supports keyboard, mouse, and joystick devices. DirectInput can also control the features of ForceFeedback devices, such as the Microsoft SideWinder Force Feedback game controller.[bold]DirectMusic[/bold]If your program needs music, then DirectMusic is for you. DirectMusic offers complex composition abilities as well as complete playback for multimedia applications. You can also add Direct Music soundtracks to multimedia applications to make them more appealing to users.[bold]DirectPlay[/bold]Network games and applications are becoming an essential part of the game genre. To that end, DirectX has a component called DirectPlay that provides easy network access to your games. DirectPlay supports Lobbies, Messaging, and Management. It also supports TCP/IP, internetwork packet exchange (IPX), modems, and serial connections. With this technology, developers can take their games to the Net quickly and easily. This technology can also be used to create messaging applications similar to MSN Messenger Service or AOL's Instant Messenger.[bold]DirectSetup[/bold]DirectSetup enables you to easily distribute DirectX with your application. With this component, your application can be packaged into a nice neat setup; when it's installed, all the libraries and support files are there where the user needs them. [bold]DirectSound[/bold]Sound is what makes a game seem more realistic, so the more realistic the sound, the better the game. DirectSound provides mixing, hardware acceleration, and direct access to the sound device. You can use this component to make car doors slam, horns honk, and birds chirp.[bold]Summary[/bold]This chapter has given you an overview of the history of DirectX. You havetaken a look at the early days of programming for multimedia and seen how theneed for faster graphics and better-quality games and multimedia helped drivethe creation of DirectX.To help you understand why Visual Basic is currently the language of choiceand why DirectX is now available, this chapter has discussed the reasonsmultimedia and games were developed in languages besides Visual Basic for manyyears.You have also briefly explored the common uses of DirectX, such as showcasingproducts with kiosks with information for consumers; incorporating userinteraction; creating screensavers, games, and other multimedia applications;and synchronizing data. You've also learned about the DirectX features available for multimediadevelopment. The DirectX components enable you to incorporate 3D features withDirect3D; use the animation capabilities inherent in DirectDraw; register userinput with DirectInput; add soundtracks to your application with DirectMusic;create a multiuser application with the network and modem capabilities ofDirectPlay; package your DirectX application with DirectSetup; and use soundeffects with DirectSound.This chapter concludes your evaluation of DirectX from a bird's-eyeview. In the next chapter, you will see how Visual Basic and DirectX worktogether.© Copyright Pearson Education. All rights reserved.
    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More Code Examples Articles
    More By Steve Hughes

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM – Taking Web 2.0 to Work

    You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Best Practices: The Integrated Project and Portfolio Management Platform.

    Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan.
    FREE! Go There Now!


    NEW! Best Practices in Integrated Requirements Management

    Poor Requirements Management capabilities in an Enterprise have been linked to excessive project failures, escalating IT costs, and failure to deliver competitive advantage into the marketplace. Join Brianna M Smith from IBM Rational and learn about how successful organizations align IT and Business stakeholders through collaborative processes and tools for effective requirements management, and how an integrated approach across the IT lifecycle can provide unparalleled visibility and traceability to ensure that project teams are delivering on the business vision by "doing the right things" and "doing things right."
    FREE! Go There Now!


    NEW! Don't wait! Try the Rational Application Developer (RAD) v7.5 open beta code today

    Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems.
    FREE! Go There Now!


    NEW! Download IBM Data Studio V1.1

    Visit IBM developerWorks to download the latest trial version of IBM Data Studio V1.1 at no cost. IBM Data Studio is a comprehensive data management solution that helps you effectively design, develop, deploy and manage your data, databases, and database applications throughout the data management life cycle utilizing a consistent and integrated user interface. Unlike other client-side data management solutions that focus on only one aspect of the application lifecycle or database administration, Data Studio complements the Rational Software Delivery platform, providing unparalleled flexibility for a heterogeneous data server environment across platforms.
    FREE! Go There Now!


    NEW! Hacking 101

    Join us for this web seminar to learn how you can defend your web applications from attack. Learn about the 3 most common web application attacks, including how they occur and what can be done to prevent them. We’ll also discuss manual versus automated approaches for scanning and identifying web application vulnerabilities and how IBM Rational AppScan, an automated vulnerability scanner, can help you automate more of what you are doing manually today.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Manual Tester V7.0.1

    Try the latest version of IBM Rational Manual Tester V7.0.1 by downloading a free trial from IBM developerWorks. This manual test authoring and execution tool promotes test step reuse to reduce the impact of software change on testers and business analysts and addresses the needs of teams performing at least a portion of their testing manually.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for Process

    Visit IBM developerWorks to try the IBM SOA Sandbox for process. The SOA Sandbox for process focuses on providing a trial environment with the necessary tooling and components required to gain a better understanding of business processes and how to best improve existing business processes to derive value quickly.
    FREE! Go There Now!


    NEW! Webcast: Accelerating Software Innovation with System z

    Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time.
    FREE! Go There Now!


    NEW! Webcast: IBM Rational Build Forge - Beyond the Build

    The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    CODE EXAMPLES ARTICLES

    - Bipartite Graphs
    - Connectivity in Graphs
    - The Ford-Fulkerson Algorithm
    - Critical Paths
    - The Bellman-Ford and Roy-Floyd Algorithms
    - Shortest Path Algorithms in Graphs
    - Minimum Spanning Tree
    - Articulation Edges and Vertexes
    - Circles and Connectivity in Graphs
    - Depth-First Search in Graphs
    - Breadth-First Search in Graphs
    - The Prufer Code and the Floyd-Warshall Algor...
    - An Insight into Graphs
    - Coding a Custom Object with WSC
    - Creating a Custom Object with WSC





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek