Visualizzazione dei risultati da 1 a 7 su 7
  1. #1

    [C++] Differenze nel creare uan finestra

    Salve,

    volevo sapere quali fossero le principali differenze nel creare una finestra direttamente tramite codice usando la classe WNDCLASSEX oppure usando il file di resource e quindi caricandolo tramite DialogBoxParam()...c'è un metodo da preferire?

    grazie
    Alla batteria dai retta ballA

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,481
    La funzione DialogBoxParam crea unicamente una dialog box modale.

    Con le API, puoi creare qualsiasi tipo di finestra.
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  3. #3
    Originariamente inviato da oregon
    La funzione DialogBoxParam crea unicamente una dialog box modale.
    Quindi può essere una base per la mia finestra principale della mia applicazione (dove poi ci saranno i vari controlli sempre definiti nel file resource.ec) ?? oppure la finestra madre può essere creata solo con la classe che ho citato prima??
    Alla batteria dai retta ballA

  4. #4
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,481
    Originariamente inviato da gianvituzzi
    Quindi può essere una base per la mia finestra principale della mia applicazione (dove poi ci saranno i vari controlli sempre definiti nel file resource.ec) ?? oppure la finestra madre può essere creata solo con la classe che ho citato prima??
    WNDCLASSEX non è una classe, ma una struttura.

    Puoi usare la DialogBox per la tua finestra principale, a patto che ti vada bene una "dialog box" con tutte le sue caratteristiche (per cui ti rinvio a MSDN).
    No MP tecnici (non rispondo nemmeno!), usa il forum.

  5. #5
    http://en.wikibooks.org/wiki/Windows...g/Dialog_Boxes

    Modeless
    Modeless dialog boxes are able to be deselected, and control can be taken away from a modeless dialog box and transferred to some other window. Modeless dialog boxes are frequently used as a fast and easy way to create a window, without having to register a window class. Modeless dialog boxes are common in the Windows control panel.
    Quindi posso creare una normalissima finestra e "disegnare" il suo contenuto (+menu) nei files "resource.rc" e "resource.h" e gestire completamente l'architettura dei messaggi (WM_)

    perfetto
    Alla batteria dai retta ballA

  6. #6
    purtroppo però il codice seguente non mostra nella finestra il menu creato nel file di resource:

    resource.rc
    codice:
    #include <windows.h>
    #include <commctrl.h>
    #include <richedit.h>
    #include "resource.h"
    
    sample MENU
    BEGIN
         MENUITEM "&Soup", 9100
         MENUITEM "S&alad", 9101
         POPUP "&Entree"
         BEGIN
              MENUITEM "&Fish", 9200
              MENUITEM "&Chicken", 9201, CHECKED
              POPUP "&Beef"
              BEGIN
                   MENUITEM "&Steak", 9301
                   MENUITEM SEPARATOR
                   MENUITEM "&Prime Rib", 9302, GRAYED
              END
         END
         MENUITEM "&Dessert", 9103
    END
    
    MioDialogo DIALOG DISCARDABLE 0, 0, 200, 200
    STYLE DS_CENTER | DS_FIXEDSYS | WS_VISIBLE | WS_BORDER | WS_CAPTION | 
    WS_DLGFRAME | WS_POPUP | WS_SYSMENU
    CAPTION "Larry"
    FONT 8, "Ms Shell Dlg 2"
    BEGIN
        GROUPBOX        "General", IDC_STATIC, 7, 10, 172, 84
        EDITTEXT        IDC_EDIT1, 53, 34, 55, 12, ES_AUTOHSCROLL
        EDITTEXT        IDC_EDIT2, 53, 57, 55, 12, ES_AUTOHSCROLL | ES_PASSWORD
        LTEXT           "User", IDC_STATIC, 16, 36, 16, 8, SS_LEFT
        LTEXT           "Password", IDC_STATIC, 16, 59, 32, 8, SS_LEFT
        PUSHBUTTON      "Cancel", IDC_BUTTON1, 130, 102, 50, 14
        PUSHBUTTON      "Save", IDC_BUTTON2, 75, 102, 50, 14
    END
    resource.h
    codice:
    #ifndef IDC_STATIC
    #define IDC_STATIC (-1)
    #endif
    
    #define IDD_DIALOG1                             100
    #define IDC_EDIT1                               1002
    #define IDC_EDIT2                               1003
    #define IDC_BUTTON1                             1004
    #define IDC_BUTTON2                             1005
    main.cpp
    codice:
    #define STRICT
    #include <windows.h>
    #include "resource.h"
    
    BOOL CALLBACK unaDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM 
    lParam)
    {
     if(uMsg==WM_CLOSE)
     {
      EndDialog(hwndDlg, 0);
      return TRUE;
     }
     return FALSE;
    }
    int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, 
    int nCmdShow)
    {
     return DialogBoxParam(0,"MioDialogo",0,unaDlgProc,0);
    }
    Il codice viene compilato correttamente e la finestra visualizzata
    Alla batteria dai retta ballA

  7. #7
    Può essere per questo motivo?

    http://msdn.microsoft.com/en-us/libr...px#window_menu

    Dialog Box Window Menu

    The system gives a dialog box a window menu when the template specifies the WS_SYSMENU style. To prevent inappropriate input, the system automatically disables all items in the menu except Move and Close. The user can click Move to move the dialog box. When the user clicks Close, the system sends a WM_COMMAND message to the dialog box procedure with the wParam parameter set to IDCANCEL. This is identical to the message sent by the Cancel button when the user clicks it. The recommended action for this message is to close the dialog box and cancel the requested task.

    Although other menus in dialog boxes are not recommended, a dialog box template can specify a menu by supplying the identifier or the name of a menu resource. In this case, the system loads the resource and creates the menu for the dialog box. Applications typically use menu identifiers or names in templates when using the templates to create custom windows rather than dialog boxes.
    Alla batteria dai retta ballA

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.