Dem Prohekt hinzufügen -> .net



  • Hi!

    Ich finde das immer wieder in irgendwelchen FAQs oder sonstigen Artikeln.

    Projekt -> Dem Projekt hinzufügen -> VC Controls und Komponenten.

    Ich finds einfach nicht. Der Splashscreen war ein Beispiel dafür....
    *seufz* Ich seh den Wald vor lauter Bäumen nicht !!! 😞



  • Den Splash hab ich auch nicht gefunden.
    Allerdings kann man andere ActiveX etc. mit Klasse hinzufügen auswählen



  • geht es um diese FAQ ???

    Wie kann ich einen Begrüßungsbildschirm anzeigen lassen so wie es bei z.B. Word oder Excel ist?
    Das Schild soll erst wieder weg gehen wenn die anwendung geladen ist.

    Ich brauche das da meine Anwendung fast 6 SEkunden zum Start braucht

    --------------------
    Ich hoffe ich konnte euch helfen...
    ...oder ihr mir 😉
    JensMinor@T-Online.de
    --> http://jensminor.gu1.info <--

    --------------------------------------------------------------------------------
    Beiträge: 4489 | Registriert seit: Feb 2002 | IP: gespeichert
    Unix-Tom
    Moderator
    Mitglied # 275

    erstellt 22.04.2002 20:33
    --------------------------------------------------------------------------------
    Nennt sich Splashscreen und geht nur in MDI,SDI
    Menü zum Project/dem Proj. hinzufügen/Komponenten und Steuerelem./
    Ordner Visual C++ Components/Begrüßungsbildschirm

    --------------------
    Thomas
    Moderator für Linux und MFC



  • Es sieht wirklich so aus, als gäbs diese Hinzufüge-Assistenten bei VC .NET nicht mehr.
    Echt schade, haben ne Menge Arbeit abgenommen!



  • ich arbeite mit vc7 und habe dort schon gesucht, ohne ergebnis.

    wie schaut der code aus der vom assis. hinzugefügt wird ?

    volker



  • Würde mich auch Interessieren 🙂

    thx schon mal für die Antworten 🙂



  • Eine Möglichkeit wäre:

    Singleton erstellen.
    Dialog erstellen mit einer Bitmap oder sonst was drauf.

    Im SingleTon 2 Methoden anlegen:
    1 zum Anzeigen des Dialoges
    1. zum ausblenden des Dialoges.

    In der <MeinProject>.cpp bei InitInstance() ruft man dann die Methode
    auf die den Dialog erzeugt.
    Beispiel:

    void Singleton::ViewSplashScreen(void)
    {
        Screen = new SplashScreen;
        Screen->Create(IDD_SPLASH);
        Screen->ShowWindow(SW_SHOW);
        Screen->UpdateWindow();  
    }
    

    Bei MainFrame::OnCreate macht man es wieder zu.

    Hoffe das hilft irgendwie.... *verschlafen schau*



  • header

    // CG: This file was added by the Splash Screen component.
    
    #ifndef _SPLASH_SCRN_
    #define _SPLASH_SCRN_
    
    // Splash.h : header file
    //
    
    /////////////////////////////////////////////////////////////////////////////
    //   Splash Screen class
    
    class CSplashWnd : public CWnd
    {
    // Construction
    protected:
        CSplashWnd();
    
    // Attributes:
    public:
        CBitmap m_bitmap;
    
    // Operations
    public:
        static void EnableSplashScreen(BOOL bEnable = TRUE);
        static void ShowSplashScreen(CWnd* pParentWnd = NULL);
        static void PreTranslateAppMessage(MSG* pMsg);
    
    // Overrides
        // ClassWizard generated virtual function overrides
        //{{AFX_VIRTUAL(CSplashWnd)
        //}}AFX_VIRTUAL
    
    // Implementation
    public:
        ~CSplashWnd();
        virtual void PostNcDestroy();
    
    protected:
        BOOL Create(CWnd* pParentWnd = NULL);
        void HideSplashScreen();
        static BOOL c_bShowSplashWnd;
        static CSplashWnd* c_pSplashWnd;
    
    // Generated message map functions
    protected:
        //{{AFX_MSG(CSplashWnd)
        afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        afx_msg void OnPaint();
        afx_msg void OnTimer(UINT nIDEvent);
        //}}AFX_MSG
        DECLARE_MESSAGE_MAP()
    };
    
    #endif
    

    cpp

    // CG: This file was added by the Splash Screen component.
    // Splash.cpp : implementation file
    //
    
    #include "stdafx.h"  // e. g. stdafx.h
    #include "resource.h"  // e.g. resource.h
    
    #include "Splash.h"  // e.g. splash.h
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char BASED_CODE THIS_FILE[] = __FILE__;
    #endif
    
    /////////////////////////////////////////////////////////////////////////////
    //   Splash Screen class
    
    BOOL CSplashWnd::c_bShowSplashWnd;
    CSplashWnd* CSplashWnd::c_pSplashWnd;
    CSplashWnd::CSplashWnd()
    {
    }
    
    CSplashWnd::~CSplashWnd()
    {
        // Clear the static window pointer.
        ASSERT(c_pSplashWnd == this);
        c_pSplashWnd = NULL;
    }
    
    BEGIN_MESSAGE_MAP(CSplashWnd, CWnd)
        //{{AFX_MSG_MAP(CSplashWnd)
        ON_WM_CREATE()
        ON_WM_PAINT()
        ON_WM_TIMER()
        //}}AFX_MSG_MAP
    END_MESSAGE_MAP()
    
    void CSplashWnd::EnableSplashScreen(BOOL bEnable /*= TRUE*/)
    {
        c_bShowSplashWnd = bEnable;
    }
    
    void CSplashWnd::ShowSplashScreen(CWnd* pParentWnd /*= NULL*/)
    {
        if (!c_bShowSplashWnd || c_pSplashWnd != NULL)
            return;
    
        // Allocate a new splash screen, and create the window.
        c_pSplashWnd = new CSplashWnd;
        if (!c_pSplashWnd->Create(pParentWnd))
            delete c_pSplashWnd;
        else
            c_pSplashWnd->UpdateWindow();
    }
    
    void CSplashWnd::PreTranslateAppMessage(MSG* pMsg)
    {
        if (c_pSplashWnd == NULL)
            return;
    
        // If we get a keyboard or mouse message, hide the splash screen.
        if (pMsg->message == WM_KEYDOWN ||
            pMsg->message == WM_SYSKEYDOWN ||
            pMsg->message == WM_LBUTTONDOWN ||
            pMsg->message == WM_RBUTTONDOWN ||
            pMsg->message == WM_MBUTTONDOWN ||
            pMsg->message == WM_NCLBUTTONDOWN ||
            pMsg->message == WM_NCRBUTTONDOWN ||
            pMsg->message == WM_NCMBUTTONDOWN)
        {
            c_pSplashWnd->HideSplashScreen();
        }
    }
    
    BOOL CSplashWnd::Create(CWnd* pParentWnd /*= NULL*/)
    {
        if (!m_bitmap.LoadBitmap(IDB_SPLASH))
            return FALSE;
    
        BITMAP bm;
        m_bitmap.GetBitmap(&bm);
    
        return CreateEx(0,
            AfxRegisterWndClass(0, AfxGetApp()->LoadStandardCursor(IDC_ARROW)),
            NULL, WS_POPUP | WS_VISIBLE, 0, 0, bm.bmWidth, bm.bmHeight, pParentWnd->GetSafeHwnd(), NULL);
    }
    
    void CSplashWnd::HideSplashScreen()
    {
        // Destroy the window, and update the mainframe.
        DestroyWindow();
        AfxGetMainWnd()->UpdateWindow();
    }
    
    void CSplashWnd::PostNcDestroy()
    {
        // Free the C++ class.
        delete this;
    }
    
    int CSplashWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
        if (CWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
    
        // Center the window.
        CenterWindow();
    
        // Set a timer to destroy the splash screen.
        SetTimer(1, 3000, NULL);
    
        return 0;
    }
    
    void CSplashWnd::OnPaint()
    {
        CPaintDC dc(this);
    
        CDC dcImage;
        if (!dcImage.CreateCompatibleDC(&dc))
            return;
    
        BITMAP bm;
        m_bitmap.GetBitmap(&bm);
    
        // Paint the image.
        CBitmap* pOldBitmap = dcImage.SelectObject(&m_bitmap);
        dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &dcImage, 0, 0, SRCCOPY);
        dcImage.SelectObject(pOldBitmap);
    }
    
    void CSplashWnd::OnTimer(UINT nIDEvent)
    {
        // Destroy the splash screen window.
        HideSplashScreen();
    }
    

    in der Mainframe

    #include "Splash.h"
    

    bei OnCreate

    // Hiers steht der andere Code  und zum Schluß
    
        CSplashWnd::ShowSplashScreen(this);
    


  • Vielen Dank 🤡



  • Könnte man das o.g. von Unix in den Beitrag aus der FAQ hinzufügen ?

    thx



  • Hallo Unix-Tom,

    ich bekomm die Daten nicht zum laufen.

    Ich öffne eine MFC Anwendung in SDI und füge dann die Splash.cpp,
    Splash.h ein und die Include in die main und den rest da in die OnCreate, aber irdendwie funzt das nicht.

    Kannst Du mir nen Tipp geben.

    Danke

    Test-User



  • Hallo Unix-Tom,

    ich bekomm die Daten nicht zum laufen.

    Ich öffne eine MFC Anwendung in SDI und füge dann die Splash.cpp,
    Splash.h ein und die Include in die main und den rest da in die OnCreate, aber irdendwie funzt das nicht.

    Kannst Du mir nen Tipp geben.

    Danke

    Test-User


Anmelden zum Antworten