The structure of the simplest Windows program with a graphical interface. Basic elements of the graphical interface. User interaction with the application

Structure Windows applications

The program consists of several clearly marked blocks (sections):

  • preprocessor operator groups;
  • section of prototypes of applied functions used in the program;
  • main function WinMain();
  • window function of the main window.

Let's consider these blocks sequentially.

The program begins with two #include preprocessor directives, with the help of which header files are included in the program. As already noted, the WINDOWS.H header file (as well as a whole group of additional header files included “from inside” the WINDOWS.H file) ensures that the compiler understands the meaning of types Windows data, constants and macros and connecting this file to the source code of the program is mandatory. Some of the definitions used in programs (for example, the GetStockBrush() macro and others similar to it, or the HANDLE_MSG macro, which will be discussed below) are contained in the WINDOWSX.H file, which also must be included in almost all Windows applications.

Following the preprocessor operators in our example is the prototype section, where the prototype of the only application function in this program, WndProc(), is defined. In fact, the program must indicate prototypes of all functions used, both applied and system. We have quite a lot of calls to Windows system functions: RegisterClass(), CreateWindowQ, GetMessage(), etc. However, the prototypes of all these functions are already defined in the header files of the programming system. Thus, the prototype of the WinMain() function is described in the WINBASE.H file:

Int WINAPI WinMain(
HINSTANCE hlnstance,//Handle to the current application instance
HINSTANCE hPrevInstance,//Descriptor of the previous application instance
LPSTR lpszCmdLine,//Pointer to parameters command line
int nCmdShow//Constant characterizing the initial view of the window
) ;

It's easy to see that the WinMain() function header in our program exactly matches the prototype above (except that we've omitted unused parameters). Otherwise it can not be. It is enough to change even a little the characteristics of our WinMain() function, and the program will either not go through the compilation stage, or will not be loaded for execution, or will be loaded but will not work.

The prototypes of the remaining Windows functions used in the program are defined in the file WINUSER.H. This way you don't have to worry about prototyping Windows functions. The situation is different with the window function WndProc(). This is an application function, its name can be anything, and the programming system does not know this name. Moreover, 120 Win32. Programming Basics When an application has multiple windows (and this is almost always the case), the program describes several window functions, one for each window class. For all window functions used in the program, their prototypes must be specified.

On the other hand, the format of a window function, that is, the number and types of input parameters of the function, as well as the type of value it returns, are determined by the Windows system and cannot be arbitrarily changed. Indeed, the window function is called from Windows when a message arrives at the application. When it is called, Windows passes it a very specific list of parameters, and the function must be able to accept these parameters and work with them. Therefore, in the interactive reference book of the programming system, a template is given for a window function, which in appearance is very similar to the prototype, but is not a prototype of a specific function, but a template for the application programmer:

LRESULT CALLBACK WindowProc(
HWND hwnd,//Window handle
UINT uMsg, 11 Message code
WPARAM wParam, //First parameter of the message
LPARAM lParam //Second message parameter
) ;

Again, you can see that our window function, having a different name, exactly matches the above template: it takes 4 parameters of the specified types and returns (on Windows) a result of type LRESULT. In addition, it is declared with the CALLBACK specifier. What does this descriptor mean?

In the WINDEF.H file, the symbolic notation CALLBACK is declared to be equivalent to keyword the C++ stdcall language, which defines the rules for the interaction of functions with calling procedures. In Win32, almost all functions use the so-called standard calling convention. This convention specifies that when a function is called, its parameters are pushed onto the stack in such an order that the last parameter is at the bottom of the stack, and the first is at the top. The function itself, of course, knows about this arrangement of its parameters and selects them from the stack in the correct order. For 16-bit Windows functions, the Pascal convention is that the order in which parameters are pushed onto the stack is reversed.

Definition 1

Graphical User Interface(Graphical User Interface, GUI) is a type of user interface in which interface elements are presented to the user on the display in the form of graphic images.

The graphical interface allows the user to control all interface elements using manipulators (keyboard, mouse, joystick, etc.). Elements of the graphical interface are designed in such a way as to display their purpose and properties to facilitate understanding and mastery of programs by users of any level.

Classification

The following types of graphical interface are distinguished:

  • simple: has standard screen forms and standard elements interfaces provided by the graphical interface subsystem itself;
  • true-graphic, two-dimensional: has non-standard interface elements and original metaphors that are implemented by the application’s own tools or a third-party library;
  • three-dimensional.

Note 1

One of the requirements for a good graphical interface of a software system is the DWIM (Do What I Mean) concept. This concept requires that the system work predictably so that the user can intuitively understand the actions that the program will perform after receiving his command.

Advantages

The graphical interface is intuitive and “friendly” for users of any level; For working with graphics processing programs, the graphical interface is the only possible one.

Flaws

The GUI uses more memory consumption compared to the text interface; the comparative complexity of organizing remote work; automation of work is impossible unless it was intended by the program developer; The GUI is difficult for users who have worked with the command line interface to get used to.

Basic GUI Elements

Interface element, control, widget– a graphical user interface primitive that has a standard appearance and performs standard actions.

Picture 1.

Window is one of the main elements of the Windows operating system interface. Desktop, on which programs and tools are located in the form of icons or icons. Window Windows folders have the same appearance or interface, which makes it easier to work on a PC.

Figure 2. View of the folder window and its elements

Dialog window– in a graphical interface, it is a special interface element designed to display information and (or) receive a response from the user. Carries out a two-way “dialogue” between the user and the PC.

Figure 3. Example dialog box

There are dialog boxes modal And non-modal, depending on the blocking or ability of the user to interact with the application (or the system as a whole) before receiving a response from it.

The simplest type of dialog box is a message box, which displays a message and asks the user to confirm that he has read the message by clicking OK. A message box informs the user of the completion of an action that was being performed, an error, or a similar event that does not require any choice from the user.

IN dialog boxes, which are dedicated to parameter settings, there are special icons - switches and switches:

Switch– an icon (checkbox) in the form of a “tick” in a square window, which indicates that the installed element is enabled.

Accordingly, the absence of a “tick” means that this element is disabled. The switch is turned on/off by clicking on the name of the corresponding command. The switch can be installed for several teams at once.

Switch– an icon in the form of a black circle in a round window, installed to the left of the command. Turning on/off, like a switch, occurs with a mouse click, but unlike a switch, it can only be turned on for one command from the list.

Application window. Applications are usually called application programs. Every application has a main window. As you work with the application, additional subwindows may open.

Figure 4. Application window – graphic editor Paint

Document window cannot exist independently; it is controlled by some application. Such windows are called child windows. They are placed only inside the main application window and disappear when the main window is closed.

Figure 5. Document window controlled by MS Word

Menu is an important element of the graphical user interface, with which you can select one of several listed program options.

Menu item selection can be made by the user using any of the pointing input devices provided electronic device(using a mouse, keyboard, touchpad, etc.).

Context menu is an element of the operating system graphical interface in the form of a list of commands, which is called by the user to select the required action on the selected object. Context menu commands apply only to the object for which this menu is called.

Operating room graphical interface elements Windows systems also are:

  • Icons that represent programs and documents. To start, double-click the mouse button on the icon.
  • Shortcuts that are used for quick access to a program that may not be stored on the Desktop or even on another drive.
  • The taskbar is located at the bottom of the screen. It contains the Start button, buttons open windows, indicators and time.

The interaction between a person and a modern PC is carried out using an object-oriented graphical interface, in which:

  • all objects are presented in the form of icons;
  • operations on objects are carried out in windows;
  • main element program control is the menu;
  • The main element of hardware control is various manipulators.
(SOFTWARE DEVELOPMENT TECHNOLOGY)
  • GUI Application Development
    Basics of working with the tkinter module The Python language allows you to create applications with a graphical interface; various graphics libraries are used for this1. Let's take a look at the tkinter standard graphics library "For more details, see: https://wiki.python.org/moin/GuiProgramming. ...
    (TECHNOLOGIES AND METHODS OF PROGRAMMING)
  • MS PowerPoint 2010 Application User Interface
    The MS PowerPoint 2010 application is launched from the MS Office Main Menu, the application shortcut on the Desktop, or from the Explorer program (if you have a ready-made presentation on your computer). PowerPoint 2010 creates a presentation file with a .ppt extension. Application...
    (Informatics for economists)
  • Description of the graphical interface of Windows OS
    The graphical user interface is implemented and supported by the operating system. The main concept of the GUI is the “window”, the diagram of which is shown in Fig. 8.2. On the screen, windows represent certain areas (usually rectangular) in which information is entered and output and...
  • Implementation of a GUI in .Net
    The .NET platform uses various technologies such as Windows Forms and Windows Presentation Foundation (WPF) to implement the GUI. This tutorial covers only Windows Forms technology. This technology includes many types (classes, structures, enumerations, delegates) that...
    (Object-oriented programming)
  • Example of a simple GUI program
    A typical Windows application contains several forms, which are created using Form class objects. This class is also an control unit and inherits from the Control base class. Some application forms open during operation, others close. At any given moment, the screen can open...
    (Object-oriented programming)
  • Lesson #12.
    Topic: "Windows Graphical Interface".
    Lesson objectives:

    - help students understand the concept of a graphical interface, control methods in Windows, and give the basic concepts necessary to work on a computer.
    - nurturing students’ information culture, attentiveness, accuracy, discipline, perseverance.
    - development of cognitive interests, skills in working with a mouse and keyboard, self-control, and note-taking skills.

    Equipment:
    board, computer, computer presentation.

    Lesson plan:
    I. Org. moment. (1 min)
    II. Testing and updating knowledge. (2 minutes)
    III. Theoretical part. (12 min)
    IV. Practical part. (16 min)
    V. D/z (2 min)
    VI. Questions from students. (5 minutes)
    VII. Lesson summary. (2 minutes)

    During the classes:
    I. Org. moment.

    Greetings, checking those present. Explanation of the lesson.

    II. Updating knowledge.
    Currently, all operating systems for personal computers provide user interaction using a graphical interface.

    This allows even a novice computer user to work confidently in the operating system environment (perform file operations, run programs, and so on).

    In this lesson we will look at how to manage this most important and complex program, i.e. Windows OS.

    III. Theoretical part.

    A graphical interface allows a person to interact with a computer in the form of a dialogue using windows, menus and controls (dialogue panels, buttons, and so on).
    The interface is an intermediary, a translator, whose task is to transform all the internal “control levers” of Windows into a graphical form that people can understand. One can argue endlessly about the numerous shortcomings and shortcomings in certain elements Windows interface. You can, shaking dusty historical reference books, prove that Microsoft simply copied all the best things contained in it from its competitors - Unix, MacOS, Linux, OS/2... But why? In any case, what we see during a session with Windows looks not only logical and convenient, but in some cases it is also simply beautiful!

    The Windows interface is simple and accessible, and almost everyone can solve almost all of its riddles.

    To work with the graphical interface, a mouse or other coordinate input device is used, and the user must be able to:
    left click - pressing and releasing the main (usually left) mouse button once;
    right click - pressing and releasing an additional (usually right) mouse button once;
    double click - two clicks of the main mouse button with a minimum time interval between them;
    dragging (dragging) - pressing left or right button mouse and moving an object with the button pressed.

    Windows GUI Elements :
    Desktop.
    The name “Desktop” was chosen well. On it, like on a regular desktop, there are various programs and tools presented in the form of icons or icons.
    Icons.
    Icons in Windows represent programs and documents. Launch is done by double-clicking on the icon. The program can be located directly on the Desktop, or it can be hidden deep on the disk, but even in this case it is presented on the Desktop in its own way - a shortcut.
    Labels.
    A program shortcut is not the program itself, but only its image, an indication of the place on the disk where it is located. Double click the shortcut also causes the program to launch. Labels differ from icons by having a small arrow at the bottom left.
    Task bar.
    Located at the bottom of the screen. It contains: the Start button, buttons for open windows, indicators and a clock.
    Window.
    A window is one of the main elements of the Windows interface.

    Desktop. How to find the Desktop? - many novice users ask. No way. In the sense that it is simply impossible not to find a desktop. For everything you see on your screen after Windows startup- that’s what he is.

    The name “Desktop” was chosen extremely well. On their regular desktop, people keep all the tools, documents, and so on they need. The Windows virtual desktop also contains the programs and tools you need most, presented in the form of icons.

    There are only a few small icons on our desktop so far. Some of them look like rectangular yellow folders, some are indicated by other pictures. Some have an arrow icon in the lower left corner, others don’t... It’s easy to get confused.

    In addition to icons, the Desktop can contain windows context menu and much more.

    Badges . Both programs and documents are indicated by similar icons. By clicking on any of them, you can launch the program you need and immediately open a document in it. It's simple - sit back and click on the icons!

    The icon corresponds to one file - a document or program. A program often consists of several hundred files, but Microsoft believes (with good reason) that the user does not need to see all of them. One thing is enough - the file that launches the program. And this is often reasonable.

    Document icons replace file extensions. So in the icon caption you will only see the file name.
    Each program installed on Windows has its own, original icon. And this icon, as a rule, is present to one degree or another in the icon of a document created using this program. This way, by looking at the icon, you will always know which file type it corresponds to.

    An icon can represent not only a file, but also a folder. Or a catalog, or a directory - whatever you are used to. By clicking on it with the left mouse button, you can open the folder in the form of a window. In this case, all files living in this folder will be represented by a kind of “portrait gallery” - a row of icons with captions.
    By clicking on the program icon, you give a command to execute it - as computer scientists say, “run”.

    You can rename any icons, move from folder to folder, delete or copy using the mouse. However, remember that any operations on icons are operations on the original program files or document. By deleting an icon from the Desktop or from any folder, you thereby physically delete the file from the disk - and this is worth doing only if you are absolutely sure that the need for this action.

    Shortcuts . There are, however, other types of icons, any operations with which will not affect the original files in any way - shortcuts. These icons differ from regular ones by having a small black arrow in the lower left corner.

    Translating the English term shortcut into the word “shortcut” is not entirely successful. It would be more accurate to say “pointer”, since this very shortcut on the Desktop, pointing to a file located in another location, serves as its shadow, reflection.

    The fact is that, despite all the colorfulness and novelty of the Windows graphical interface, underneath it hides the usual, familiar to us all, “directory tree” structure. Each program is in its own directory. And our Desktop is, in fact, a real catalog.

    What happens if we want to mark some program on our Desktop, for example, Microsoft Word? The program is launched by the winword.exe file, which is located along with other Word files in the C:\Program Files\Microsoft Office\Office\ folder. And you cannot move the file to any other folder, including the Desktop - the program will not work... But you can create a pointer on the Desktop - a shortcut! This icon will differ from the icon of the program itself only with an arrow in the corner, but it will provide the user with unlimited possibilities! The icon can be safely renamed or deleted without fear for the fate of the program or document itself - with any changes they will remain in good health.
    Shortcuts do not require the presence of the program itself in the folder where we will place this shortcut. Inside the shortcut is not the program itself, but only a link containing the exact address of the program.

    For quick access to disks, the printer, and frequently used documents, it is advisable to create shortcuts on the desktop. A shortcut differs from an icon in that it represents an object that is actually located not on the Desktop, but in some other folder. The arrow means that we do not have the object itself, but a link to it. Shortcuts are created by dragging object icons onto the desktop.

    Task bar. At the bottom of the screen is the Taskbar, which contains the Start button, buttons for running tasks and open folders, indicators and a clock. The Start button allows you to call the Main Menu, which provides access to almost all system resources and contains commands for launching applications, system settings, searching for files and documents, accessing the help system, etc.

    Windows is multitasking operating system, that is, several applications can be executed in parallel. Each running application is indicated by a button on the taskbar, and the transition from working in one application to working in another can be done by clicking on the button. A running (active) application is displayed on the taskbar as a pressed button.

    You can display different panels on the taskbar. On the far right side of the taskbar is the language bar, which allows you to select your input language. For example, the Ru indicator indicates that the Russian keyboard layout is currently being used.
    The notification area (tray) is used to display icons for some programs related to the operation of the computer. To avoid cluttering the taskbar, an arrow button may be visible instead of icons for rarely used items presented in the notification area. To display all icons, click this button.
    The digital clock on the taskbar shows the current time. To see the current date, month and year, just move your mouse pointer over the clock.

    Window . The most important element of the Windows graphical interface is windows, indeed “windows” means “windows”. There are two main types of windows - application windows and document windows.
    A window is a framed portion of the screen that displays an application, document, or message.
    Application windows. The application window runs any running application or displays the contents of a folder. Opening or closing an application window is the same as launching or ending a program. Application windows can be moved to any place on the desktop, maximized to fill the entire screen, or minimized to buttons on the taskbar.

    The main elements of the application window are :
    workspace: the inner part of the window, contains subfolders or document windows;
    border: a frame that encloses a window on four sides. The window size can be changed by moving the border with the mouse;
    title: the line immediately below the top border of the window containing the title of the window;
    system menu icon: the button on the left in the title bar opens a menu for moving and resizing the window;
    menu bar: located directly below the header, contains menu items, provides access to commands;
    toolbar: located below the menu bar, it is a set of buttons that provides quick access to some commands;
    the Collapse, Maximize/Restore, and Close buttons are located in the upper right part of the window.
    scroll bars. If the text or picture does not completely fit in the program window, then to view it, scroll bars appear at the bottom or on the right, which can be moved, revealing areas that do not fit on the screen.

    Document windows. Document windows are designed for working with documents and “live” inside application windows. You can expand, collapse, move, or resize these windows, but they always remain within their application window. The document window has the same control buttons as the application window.

    A document window contains a title area (containing the name of the document) and often scroll bars (appearing when the document does not fit entirely in the window) and rulers.

    A window is active (current) if there is this moment the user is working. Otherwise the window will be passive (in a passive state). If the window is in a passive state (the title area is not highlighted), then by clicking on any part of it with the mouse, you can switch it to the active state.

    A menu is one of the main elements of a graphical interface and is a list of commands (usually grouped thematically) from which you need to make a choice (by placing the mouse pointer on the menu item and clicking). Selecting a menu item causes a specific command to be executed. If a menu command is followed by an ellipsis, selecting it will cause a dialog box to appear that allows the user to obtain or enter additional information.

    Questions:
    What is a graphical user interface?
    How is control done in Windows?
    What actions can you perform with the mouse?
    List the elements of the Windows GUI.
    What is a desktop?
    What is the difference between icons and labels?
    How to access all programs installed on your computer and all Windows settings?
    Where is the digital clock?
    How to switch input language using mouse?
    How to find out the current date?
    List the main elements of a window.

    III. Practical part.

    Today in the practical part we will continue working with the Notepad program and learn how to copy and move text. For these purposes we will use the clipboard. The clipboard is an area of ​​RAM designed to temporarily store data when transferred from one place to another. This memory is allocated to us by the operating system.

    To place some data on the clipboard, you must first select it. You can select text in Notepad different ways, For example:
    while holding down the button, move through the text using the arrow buttons;
    select text while holding down the left (main) mouse button;
    to select multiple parts of text, select them with the mouse while holding down the button on the keyboard;
    To select all the text, use the Edit command→ Select all;
    To select all text, you can use the special key combination +[A]…

    To remove a selection, simply click the left mouse button anywhere in the text or press any cursor key without pressing .

    But what to do after the text is selected? Let's go to Notepad's help system and find information about copying text. Students work with help...
    To cut, copy, paste or delete text:
    To cut a piece of text to move to another location, select the text you want, and then choose Cut from the Edit menu.
    To copy a piece of text to paste it elsewhere, select the text you want, and then choose Copy from the Edit menu.
    To paste copied or cut text, place the cursor where you want to paste it, and then choose Paste from the Edit menu.
    To delete text, select it and select Delete from the Edit menu.

    And now the task: a certain student Ivan Ivanov memorized a poem by A.S. for a literature lesson. Pushkin’s “Winter Morning”, but during the lesson I got confused and mixed up all the lines. Help Ivanov remember the poem.
    File with the verse (with mixed up lines) – C:\Our lesson\Lesson 12 Practice.txt. Save the result of your work in your folder under the name “Winter Morning”.
    Students complete the task.

    IV. D/z
    Know the elements of the Windows graphical interface, be able to work with windows. Students who have computers at home should continue to master the “ten-finger touch typing method.”

    Additional task: learn how you can create an additional panel with shortcuts to the programs you frequently use.

    V. Questions from students.
    Answers to student questions.

    VI. Lesson summary.
    Summing up the lesson. Grading.
    In this lesson we looked at the elements of the Windows graphical interface. We also learned how to move some text using the Windows clipboard.

    After Windows boots, an electronic Desktop, on which graphic objects are placed - icons (icons) of folders and files, shortcuts, etc. Document file icons replace the file extension (only the name is present in the icon signature), and since each program installed in Windows has its own original icon, then it is present in the icon of the document created by the corresponding program.

    Label is a link to an object (file or folder) located in a different location and its icon differs from the object icon only by the presence of a black arrow in the lower left corner. Any actions performed on a shortcut (copying, renaming, deleting, etc.) do not affect the object associated with it. Opening a shortcut means opening the object associated with it. By viewing the properties of a shortcut, you can always find out where the object with which the shortcut is associated is located. The most common use of shortcuts is to launch applications.

    At its core, the Desktop is a folder with the disk address C:\DocumentsandSettings\ “username”\Desktop, which contains the files, folders and shortcuts depicted on it. If we consider the place of the Desktop in the hierarchical structure of the “folder tree”, then it is the top level of the structure (Fig. 3.1).

    Fig.3.1. Desktop in the “folder tree”

    The set of objects on the Desktop depends on the computer settings. Typically it contains icons of the following standard (system) folders:

    « My computer"- a folder that provides access to all computer resources. You cannot remove a single icon from this folder.

    "Network environment"- a folder that provides access to available network resources. If the computer is connected to a local network, then from this folder you can access any computer on the network. You can also add Internet sites to this folder.

    "Basket"- the folder that contains all objects deleted from hard drives. The amount of disk space that the Recycle Bin occupies is set through its properties. You can empty the Recycle Bin using the corresponding command from its Context Menu.

    The list of operations that can be applied to a Desktop object depends on its type and is displayed in the object's right-click context menu.

    The main object of the Windows GUI is window- a framed rectangular area on the monitor screen in which the contents of a folder, application, document or message are displayed.

    Windows have a set of controls that allow you to work within the windows. The window can be expanded to fill the entire screen or minimized to an icon; you can resize it and move it around the Desktop. Depending on what is displayed in the window (folder contents, application, etc.), its controls are different. The following examples of window elements can be given:

      title bar with system menu button and standard operation buttons;

      control (main menu), the items of which open drop-down menus containing groups of commands united by functionality;

      toolbars;

      status bar containing information about application operating modes.

      vertical and horizontal stripes(rulers) scroll bars, used to view the contents of the window vertically and horizontally;

    “Dialog” windows also contain: tabs, command buttons, selection buttons (“switches” and “checkboxes”), list fields, etc., and in the folder window there are “Address Bar” and “Links” panels, and navigation buttons.

    The user can customize the appearance of the window, for example, when customizing a folder window, you usually set the way its contents are displayed and its ordering, which panels are displayed, etc. It is also possible to configure the properties of the folder window (displaying a list of typical tasks or a folder structure (tree), showing “hidden” objects, etc.).

    At the bottom of the Desktop there is a line called Task bar(Fig. 3.2) (the user can change its properties, as well as change its size and position).

    Rice. 3.2. Windows taskbar

    On the left side of the Taskbar there is a button that opens start menu, which contains a list of installed programs and links to the most important Windows controls. By changing the properties of the menu, the user can set its style (Fig. 3.3).

    Rice. 3.3. Windows Main Menu (Windows XP and Classic style)

    The Start menu consists of items that open corresponding objects (programs, windows of corresponding folders, etc.), and can also contain files, folders and shortcuts.

    On the right side of the taskbar is Display panel(notification area), where icons are located for automatically (when the computer is turned on) downloaded programs that run in the background; the system time clock, a sound volume control icon, and a keyboard layout indicator are also displayed there.

    The taskbar displays task icons (running applications). You can also place toolbars on it, including them from the context menu list or creating them yourself. The most commonly used panel is the “Quick Launch” panel, on which shortcuts are placed to quickly launch the most necessary programs.

    If toolbar elements do not fit on the Taskbar, they are automatically “collapsed” into a small arrow (when you click on the arrow, the elements expand in a vertical list), and on the Indicator Panel the same thing happens with unused icons.