|
Bücher,C undC#TrainingsfürProgrammierer c schulungen, C# Schulungen, Bücher über c mit Visual Studio
|
bet | 4/8 | Sana | 20.02.2024 | Hajmi | 1,28 Mb. | | #159175 |
Bog'liq www rkaiser de c-winforms-tutorial
Next, a simple Winforms application is to be created based on the previous explanations. It contains a button and TextBoxes for input and output:
However, you do not have to create this project yourself. If you install the Visual Studio extension
a project template with exactly this project is available in Visual Studio:
You can use this project as a basis for many applications by adding more controls and functions.
The main purpose of this project is to show how the application logic is separated from the user interface:
The functions, classes, etc. of the application logic are written in standard C and are contained in a header file that is added to the project. The instructions for the user interface, on the other hand, are written primarily in C/CLI and are often included in the form class in Form1.. The functions of the header file are called when clicking a button.
The following is a simplified version of chapter 2.11 from my book „C mit VisualStudio 2019undWindowsForms-Anwendungen“. There I recommend such a project for the solutions of the exercises. In the header file of such a project you can include the solutions of several exercises or distribute them to different header files. For each subtask you can put a button (or menu options) on the form. This way you don’t have to create a new project for each subtask.
Of course, outsourcing your own instructions to an extra file (as in 3.) and accessing the controls via function parameters is somewhat cumbersome: however, it leads to clearer programs than if all instructions are located in the form file within the Form1 class. This saves many programming errors that lead to obscure error messages, and makes it easier to search for errors.
Create a new project with File|New|Project|CppCLR_WinformsProject (see section 1.1 .
The following examples assume a project named CppCLR_Winforms_GUI.
|
| |