Getting started with Windows desktop

Home / Support / Tutorials / Getting Started / Getting started with Windows desktop

Required tools and SDKs

For Windows desktop development we recommend Visual C++ 6.0 or Visual C++ 2005 which will be covered by this tutorial. The Express edition of Visual C++ 2005 can be downloaded for free. You will also need an additional platform SDK.

Installation

After installing the C++ compiler we need to the platform SDK and set up the header and library folders. When installing the platform SDK, select the Windows XP SP2 SDK and install it in the default folder. Installing the platform SDK will also enable Visual C++ 2005 express to create Win32 applications.

Adding additional include/library folders in Visual C++ 6.0

To set up the include/library folders for the platform SDK, open Visual C++ and go to: tools -> options. Select the tab "Directories" to add include and library paths.

VC6 directories
VC6 directories

Click on the dotted rectangle to add a new folder. Link the include and library folders of the platform SDK and everything should be set.

Adding additional include/library folders in Visual C++ 2005

To add include/library folders in this compiler, go to tools -> options to open a new window. After that, select projects and Solutions -> VC++ directories. Choose Win32 as the platform, and choose include files or library files to add these new folders.

Visual C++ 2005 directories
Visual C++ 2005 directories

Click on the yellow folder icon to add a new folder. Link the include and library folders of the platform SDK, then everything should be set.

Set up a Visual C++ 6.0 project workspace

After creating a project folder and installing EDGELIB and Microsoft Visual C++ 6.0, you can create a workspace. A workspace contains a source code structure for building Windows desktop applications. Open Visual C++ and create a new workspace with file -> new.

Creating a new project in Visual C++ 6.0
Creating a new project in Visual C++ 6.0

When creating a new workspace you can choose various types of applications. We will create a new Win32 application for our helloworld application at: C:\projects\helloworld\workspace. After that, create an empty project and finish. The workspace should be ready.
When the workspace has been created, we will create a new folder inside the helloworld project. This folder will be C:\projects\helloworld\code and will contain all source files. Create a helloworld.cpp from file -> new, make sure it is created inside the code folder. The next thing to do is to tell the compiler where to locate the EDGELIB header files and libraries. Go to project -> settings and click on the tab "C/C++".

Project settings in Visual C++ 6.0
Project settings in Visual C++ 6.0

First select "all configurations" from the "settings for" selection box at the left side of the window, this will make sure the new project settings take effect for both debug and release builds. Then select "preprocessor" category, right below the tab. A new option called "additional include directories" will appear. You can enter .,..\..\edge\include (relative path) or .,C:\projects\edge\include (absolute path), so the compiler can find the EDGELIB header files. The same thing can be done for libraries. Go to the "link" tab and to the input category to change the option "additional library path". This path should point to the correct library, which is in this case: ..\..\edge\lib\pc-x86

Set up a Visual C++ 2005 project solution

Creating Windows Desktop projects in Visual C++ 2005 is a little bit different than using Visual C++ 6.0. All editions of Visual C++ 2005 are able to create a Win32 project, an application that can be built for Windows desktop. This project will be created in a new folder inside the helloworld project folder: C:\projects\helloworld\workspace_2005. Create a new project with file -> new -> project.

Creating a new project in Visual C++ 2005 express
Creating a new project in Visual C++ 2005 express

Select general, then empty project and click OK. Adding a .cpp file can be done by right clicking on the source folder in the solution explorer. Choose Add -> New Item to create a new file or Add -> Existing item to add an already existing .cpp file. Add helloworld.cpp, which will be located in this folder: C:\projects\helloworld\code. The final step is to set up the project properties. Right click on the project (on the left side of the screen) and select "properties".

Project settings in Visual C++ express
Project settings in Visual C++ express

The additional include and library directories will be the same for every configuration. This can be set by using the selection boxes at the top of the screen. To set the additional include directory, open configuration properties -> C/C++. Set it to .,..\..\edge\include. Also add the additional library directories which can be changed by opening configuration properties -> Linker -> General. This additional library directory will be set to ..\..\edge\lib\pc-x86_vc2005. To disable the "can't find libc.lib" warning, go to configuration properties -> Linker -> Input and add libc to the ignore specific library list.

Create a helloworld example

It's time to create a working sample that's able to run on a Windows PC. Open helloworld.cpp and paste the following code inside the editor window:

helloworld.cpp (88 lines)
  1. /////////////////////////////////////////////////////////////////////
  2. // Code/helloworld.cpp
  3. // One of the EDGELIB tutorial samples for Windows desktop
  4. //
  5. // Copyright (c) 2006-2017 Elements Interactive Mobile B.V.
  6. // http://www.edgelib.com
  7. //
  8. // Show "hello world" on the screen and exit by tapping the screen or
  9. // hitting a key
  10. /////////////////////////////////////////////////////////////////////
  11.  
  12.  
  13. /////////////////////////////////////////////////////////////////////
  14. // Include and link the library                                    //
  15. /////////////////////////////////////////////////////////////////////
  16.  
  17. //Include EDGELIB
  18. #include "edgemain.h"
  19.  
  20. //Link the EDGELIB static library
  21. #pragma comment(lib, "edge.lib")
  22.  
  23. //Include internal resources
  24. #include "resource.h"
  25.  
  26. /////////////////////////////////////////////////////////////////////
  27. // Class definition                                                //
  28. /////////////////////////////////////////////////////////////////////
  29.  
  30. //The main class
  31. class ClassMain : public ClassEdge
  32. {
  33.     public:
  34.         ClassMain(void);
  35.         ~ClassMain(void);
  36.         ERESULT OnDisplayConfig(EDISPLAYCONFIG *config);
  37.         ERESULT OnNextFrame(ClassEDisplay *display, unsigned long timedelta);
  38.         void OnButtonDown(unsigned long bnr, EBUTTONLIST *blist);
  39.         void OnStylusDown(POINT pnt);
  40. };
  41.  
  42.  
  43. /////////////////////////////////////////////////////////////////////
  44. // ClassMain: public                                               //
  45. /////////////////////////////////////////////////////////////////////
  46.  
  47. //ClassMain: constructor
  48. ClassMain::ClassMain(void)
  49. {
  50. }
  51.  
  52. //ClassMain: destructor
  53. ClassMain::~ClassMain(void)
  54. {
  55. }
  56.  
  57. //Configure display
  58. ERESULT ClassMain::OnDisplayConfig(EDISPLAYCONFIG *config)
  59. {
  60.     ClassEStd::StrCpy(config->caption, "Hello World!");
  61.     return(E_OK);
  62. }
  63.  
  64. //Callback: Called every frame
  65. ERESULT ClassMain::OnNextFrame(ClassEDisplay *display, unsigned long timedelta)
  66. {
  67.     display->buffer.DrawFont(0, 0, &display->fontinternal, "Hello World!");
  68.     return(E_OK);
  69. }
  70.  
  71. //Callback: Called when the user pressed a key or button
  72. void ClassMain::OnButtonDown(unsigned long bnr, EBUTTONLIST *blist)
  73. {
  74.     Quit();
  75. }
  76.  
  77. //Callback: Called when the user points the stylus down or clicks the left mouse button
  78. void ClassMain::OnStylusDown(POINT pnt)
  79. {
  80.     Quit();
  81. }
  82.  
  83.  
  84. /////////////////////////////////////////////////////////////////////
  85. // The program entry point                                         //
  86. /////////////////////////////////////////////////////////////////////
  87.  
  88. ClassEdge *EdgeMain(EDGESTARTUP *data){ return(new ClassMain); }

This sample code has been written specifically for Windows desktop. A multi-platform version can be found at the multi-platform section.
Build and run the sample with build -> execute. Run it, and it should show "Hello World!" at the top of the screen. Click the mouse or press a key to quit.

Adding resources

Resource scripts can be used to add an icon to your application or add other internal resources. To create a new resource script go to: file -> new. The resource script should be added to your workspace folder, instead of the code folder. Include resource.h inside your code to be able to access them.

When the resources are added, a new tab called "ResourceView" appears on the workspace browser at the bottom left of the screen. To add an icon: click on this new tab, right click on the resource folder and select "insert". A new icon can be created. A good idea is to create a new folder like C:\projects\helloworld\res to separate your resources from your source code. You can draw your icon using the internal icon editor, build in embedded visual C++. The icon can be linked to the program by adding the following line to ClassMain::OnDisplayConfig: config->icon = IDI_MAIN.

Note: Resources can't be created in Visual Studio Express editions. Skip the above when using one of these compilers.

After adding the resource file, the Visual C++ express compiler may complain about a missing "afxres.h" file. Add this file to the solution folder with the following text:

afxres.h (3 lines)
  1. //Fix for Visual Studio 2005 express
  2.  
  3. #include <windows.h>

Download tutorial project

Here is a sample that can be downloaded which contains the result of this tutorial.

Getting started tutorials

Latest forum posts