Creating a frame that only displays for a while and delete itself Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
abhilekh_gautam
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Dec 22, 2021 12:29 pm

Creating a frame that only displays for a while and delete itself

Post by abhilekh_gautam »

Hi there, I want my app to have a frame that displays my app name and logo and disappear after few seconds and I call it landingFrame

Code: Select all

   #include "landingframe.h"
   #include "optionframe.h"
   #include <wx/wx.h>
   
      landingFrame :: landingFrame(const wxString& title = "")
       :wxFrame(nullptr, wxID_ANY,title, wxDefaultPosition, wxDefaultSize, wxMAXIMIZE){
  
       wxImage::AddHandler(new wxPNGHandler);
       wxStaticBitmap* logo = new wxStaticBitmap(this, wxID_ANY, wxBitmap("presplash.png"), wxDefaultPosition);
       wxBoxSizer* logo_container = new wxBoxSizer(wxVERTICAL);
  
       logo_container->AddStretchSpacer(1);
       logo_container->Add(logo, 0, wxALIGN_CENTER | wxALIGN_CENTER_HORIZONTAL);
       logo_container->AddStretchSpacer(1);
  
     SetSizerAndFit(logo_container);
  }

And I have another frame which should be my parent frame which is optionframe

so I defined OnInit as

Code: Select all

  bool myapp:: OnInit(){
    landingFrame* frame = new landingFrame ("");
    optionFrame* options = new optionFrame("");
  
   frame->Show(true);
   SetTopWindow(frame);
   sleep(5);
   delete frame;
   options->Show(true);
   SetTopWindow(options);
   return true;
  }

But I only get a single frame which is optionFrame
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7479
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Creating a frame that only displays for a while and delete itself

Post by ONEEYEMAN »

Hi,
Check the "splash" sample and wxSplashScreen class.

Thank you.
Post Reply