Wo liegt denn der Unterschied zwischen einem Dialog und einem Fenster?



  • Irgendwie erkenne ich den Unterschied / Nutzen dieser zwei Typen nicht richtig!
    Ein Dialog ist ja erstmal nichts anderes als ein Fenster, was macht dieses Fenster also zum Dialog?

    Außerdem kann man in Visual Studio Dialoge mit dem Ressourcen-Editor gestalten, Fenster aber nicht.
    Deshalb erscheint es mir auch schon fast zweckmäßiger, meine Anwendung direkt Dialog-basierend aufzubauen.
    Oder spricht da etwas dagegen?



  • A dialog box is a temporary window an application creates to retrieve user input. An application typically uses dialog boxes to prompt the user for additional information for menu items. A dialog box usually contains one or more controls (child windows) with which the user enters text, chooses options, or directs the action.

    Windows also provides predefined dialog boxes that support common menu items such as Open and Print. Applications that use these menu items should use the common dialog boxes to prompt for this user input, regardless of the type of application.

    Most applications use dialog boxes to prompt for additional information for menu items that require user input. Using a dialog box is the only recommended way for an application to retrieve the input. For example, a typical Open menu item requires the name of a file to open, so an application should use a dialog box to prompt the user for the name. In such cases, the application creates the dialog box when the user clicks the menu item and destroys the dialog box immediately after the user supplies the information.

    Many applications also use dialog boxes to display information or options while the user works in another window. For example, word processing applications often use a dialog box with a text-search option. While the application searches for the text, the dialog box remains on the screen. The user can then return to the dialog box and search for the same word again; or the user can change the entry in the dialog box and search for a new word. Applications that use dialog boxes in this way typically create one when the user clicks the menu item and continue to display it for as long as the application runs or until the user explicitly closes the dialog box.

    To support the different ways applications use dialog boxes, there are two types of dialog box: modal and modeless. A modal dialog box requires the user to supply information or cancel the dialog box before allowing the application to continue. Applications use modal dialog boxes in conjunction with menu items that require additional information before they can proceed. A modeless dialog box allows the user to supply information and return to the previous task without closing the dialog box. Modal dialog boxes are simpler to manage than modeless dialog boxes because they are created, perform their task, and are destroyed by calling a single function.

    To create either a modal or modeless dialog box, an application must supply a dialog box template to describe the dialog box style and content; the application must also supply a dialog box procedure to carry out tasks. The dialog box template is a binary description of the dialog box and the controls it contains. The developer can create this template as a resource to be loaded from the application's executable file, or created in memory while the application runs. The dialog box procedure is an application-defined callback function that the system calls when it has input for the dialog box or tasks for the dialog box to carry out. Although a dialog box procedure is similar to a window procedure, it does not have the same responsibilities.

    An application typically creates a dialog box by using either the DialogBox or CreateDialog function. DialogBox creates a modal dialog box; CreateDialog creates a modeless dialog box. These two functions load a dialog box template from the application's executable file and create a pop-up window that matches the template's specifications. There are other functions that create a dialog box by using templates in memory; they pass additional information to the dialog box procedure as the dialog box is created.

    Dialog boxes usually belong to a predefined, exclusive window class. The system uses this window class and its corresponding window procedure for both modal and modeless dialog boxes. When the function is called, it creates the window for the dialog box, as well as the windows for the controls in the dialog box, then sends selected messages to the dialog box procedure. While the dialog box is visible, the predefined window procedure manages all messages, processing some messages and passing others to the dialog box procedure so that the procedure can carry out tasks. Applications do not have direct access to the predefined window class or window procedure, but they can use the dialog box template and dialog box procedure to modify the style and behavior of a dialog box.



  • Ja, schön und gut. Aber meine Frage beantwortet das nicht so ganz.
    Wieso gibt es diese zwei Typen? Ein Window könnte auch den Job einer Dialog-Box übernehmen.



  • Ich hab mir jetzt nicht alles von rofler durchgelesen, aber was für mich immer ein wichtiger Unterschied war/ist: Beim Dialog gibst du alle Ausmaße in Dialog-Einheiten an, bei normalen Fenstern in Pixeln. Die Dialog-Einheiten skalieren je nach System und Auflösung, damit soll der Dialog überall gleich aussehen (oder so).
    Zusätzlich meine ich mich noch zu erinnern, dass "durch-'Tab'en" nativ nur mit Dialogen geht.

    Ach, und Dialoge kannst du aus Ressourcen erstellen, was vor allem bei mehrsprachiger Software von Vorteil ist.



  • soviel zu _sinnvollen_ beiträgen, was rofler... 🙄

    zum thema: ein dialog hat noch ein paar speziefische eigenschaften mehr als ein window. ist ja vom window(fenster) abgeleitet.

    also ist afaik ein dialog ein fenster mit mehr eigenschaften.. 😉



  • Vom fenster abgeleitet, so ein schwachsinn. ein dialog IST ein fenster. so einfach ist das. Machine tue mir einen Gefallen und halt deine Klappe. Du bist hier überflüssig.



  • Ihr habt beide Recht!

    In der OOP ist Vererbung, also eben die Ableitung einer Klasse von einer Anderen, eine "IST"-Beziehung.
    Ein Dialog ist ein Fenster!

    🙂



  • Noch eine Frage zum "Message-Handling". Darf man Dialog-Messages von DispatchMessage() an die DLGPROC übergeben lassen?
    In den Beispielcodes von der MSDN machen die das immer mit IsDialogMessage(). Gänge das über die normale Nachrichtenschleife nicht auch?

    Mit IsDialogMessage hat man irgendwann ne Menge zu tippen, wenn man viele Dialoge haben will.



  • Dialoge lassen sich mit der WinApi Funktion CreateDialog erstellen. Möchte man ein Fenster erstellen, benutzt man die Funktion CreateWindow.


  • Mod

    Noch ein paar Anmerkungen:
    Ein Dialog ist ein Fenster mit der Klassennummer/name #32770. Es ist eine normale globale Klasse wie ein Static, Listbox etc. auch.

    Man kann solche Klassen auch direkt erstellen mit CreateWindow. CreateDialog ist nur eine "abkürzende" WinAPI Funktion. Und Die modalen Funktionen eben implementieren auch nich eine eigene MessageLoop.

    In der MFC werden modale Dialoge "nicht modal erzeugt" und anschließend wird eine eigene Nachrichtenschleife in der MFC genutzt.



  • Ein Dialog muß immer eine eigene DialogProc haben, ein Fenster kann auch von der Hauptprozedur (meistens WndProc) bedient werden. Natürlich kann man einem Fenster auch die Funktionalität eines Dialogs geben.
    Ich würde mal sagen, der Hauptunterschied liegt in der Anwendung. Ein Fenster Ein Dialog ist ein Fenster, das Elemente zur Kommunikation mit dem Programm vorgibt. Ein Fenster ist ein allgemeiner Bestandteil eines Programms.


  • Mod

    Elektronix schrieb:

    Ein Dialog muß immer eine eigene DialogProc haben,

    Nein! Die kann IMHO NULL sein.

    Elektronix schrieb:

    ein Fenster kann auch von der Hauptprozedur (meistens WndProc) bedient werden. Natürlich kann man einem Fenster auch die Funktionalität eines Dialogs geben.
    Ich würde mal sagen, der Hauptunterschied liegt in der Anwendung. Ein Fenster Ein Dialog ist ein Fenster, das Elemente zur Kommunikation mit dem Programm vorgibt. Ein Fenster ist ein allgemeiner Bestandteil eines Programms.

    Man kann auch die Dialog Klasse superclassen und seine eigene WndProc verpassen.
    Man kann auch das erzeugt Dialog Fenster subclassen und drüber alle Child Nachrichten bearbeiten (wie es die MFC macht).
    Die DialgProc ist überflüssig und kein Kennzeichen eines Dialoges. Sie ist ein Feature...



  • Ok, dann können wir jetzt lange herumstreiten, um die Unterschiede zu definieren, oder festhalten, daß es offenbar gar keine gibt- außer höchstens in der Art der Anwendung.


Anmelden zum Antworten