Creating a Windows Program in CodeWarrior - C++

Congratulations, reader; you’re in for a treat. You’re about to enter a whole new world of programming in the land of Microsoft. Programming for Windows is much more exciting than boring, old console applications because you get to see most of what you do right away. Also, because about 98 percent of computer users work on Windows, your programs will be highly portable.

The steps to generating a Windows program are inherently different from those of a console application. In “Starting the Journey,” we tell you to open the New Project dialog box (the one right after you choose the project name) and choose C++ Console App. This step tells CodeWarrior that you do not want your program to be a Windows application. Now, however, you explore one of the other options in this dialog box, Win32 C++ App.

To help you become familiar with this process, we now walk you through it step by step. In this set of steps, you create a program that displays the message Hello from Win32 onscreen.

  1. Open CodeWarrior and choose New from the File menu. The New dialog box opens with the Project tab selected.
  2. In the Project name text box, enter WinHelloWorld as the name of the project.
  3. You can designate your project’s name, location, and type in the New dialog box.

    You can designate your project’s name, location, and type in the New dialog box.

  4. In the Location text box, type an appropriate directory or click the Set button to browse to the directory.
  5. In the directory at the right side of the New dialog box, select Win32 C/C++ Application Stationery as the type of project.
  6. Click OK to open the New Project dialog bo.
  7. The New Project dialog box.

    The New Project dialog box.

  8. Select Win32 C++ App from the list of options.
  9. Click OK. The project window opens, which means that you have finished creating the skeleton application.
  10. The project window displays the source code for a Windows program.
  11. This window displays the skeleton code that CodeWarrior generates for a Windows program.

    This window displays the skeleton code that CodeWarrior generates for a Windows program

  12. Compile and run the program the same way you compile and run a console application. The CodeWarrior Win32 Stationery window appears with the message Hello from Win32 shown onscreen . You have now completed your first Windows application.
  13. The skeleton code generated by CodeWarrior produces a window that can be moved, maximized, minimized, and resized.

    The skeleton code generated by CodeWarrior produces a window that can be moved, maximized, minimized, and resized

Though more is involved, Windows programs aren’t too difficult to create. In the next few sections, you examine the skeleton code that CodeWarrior generated in the preceding steps.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

C++ Topics