• 3. A header file for the application logic
  • Design the user interface (the form)




    Download 1,28 Mb.
    bet5/8
    Sana20.02.2024
    Hajmi1,28 Mb.
    #159175
    1   2   3   4   5   6   7   8
    Bog'liq
    www rkaiser de c-winforms-tutorial

    2. Design the user interface (the form)


    The form is then designed to contain all the controls needed to input and output information and start actions. This is done by dragging appropriate controls from the toolbox onto the form.
    For many projects (e.g. the exercises from my book) the following controls are sufficient:

    A multiline TextBox (see Section 2.3.2 of my book) to display the results.
    A single-line TextBox for entering data
    One or more buttons (or menu options, etc.) to start the instructions
    A TextBox becomes multiline TextBox by the value true of the MultiLine property. The TextBox for output is to be named out_textBox:
    The TextBox for entering data will be named in_textBox:
    Since the function plus_1 is called when the button is clicked, it is given the caption „plus 1“ and the name button_plus1:

    3. A header file for the application logic


    The functions, declarations, classes etc. of the so-called application logic are placed in a separate header file, which is added to the project with
    Project|Add new element|Visual C |Code as header file(.h) with the name Header1.h. In practice, however, you should group functions and classes that belong together conceptually in a header file, and then give the header file a more meaningful name than Header.h.
    The application logic is then included in the header file. These are mostly functions, classes, etc. written in C. In our first example, this should be a function with the name plus_1, which returns the value of the argument increased by 1
    In a C Windows Forms project, the application logic consists primarily of functions, classes, etc. written in C, without C/CLI language elements. In our first example, this should be a function named plus_1, which returns the value of the argument incremented by 1
    int plus_1(int x)
    { return x + 1;
    }
    Diese Datei wird dann vor dem namespace des Projekts mit einer #includeAnweisung in die Formulardatei (z.B. Form1.h) aufgenommen:
    This file is then included in the form file (e.g. Form1.h) before the namespace of the project with an #include statement:
    #pragma once
    #include "Header1.h" // <-- manuell einfügen. nach dem Eintippen von
    // "#include " bietet Visual Studio die Datei an.
    namespace CppCLRWinFormsProject { using namespace System;
    ...
    }

    Download 1,28 Mb.
    1   2   3   4   5   6   7   8




    Download 1,28 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Design the user interface (the form)

    Download 1,28 Mb.