Show wxDialog without taskbar/task switch icon from hidden wxFrame?

Volker Bartheld dr_versaeg at freenet.de
Fri Oct 26 09:35:51 PDT 2007


Hi!

>>Subject says it all. As a kind of "progress notification" my app operates
>>a hidden wxFrame. Depending on its state, this frame shows a stacked pile
>>of "bare" dialogs growing from the right bottom of the screen. [...]
>>Is there a way to have a hidden app and show a window that is neither listed
>>in the taskbar nor with the task switch menu?

> Maybe you shouldn't use a dialog/frame, just a normal window.

A normal window still didn't do the trick. At least for some
LINUX-derivates, it was either showing up not at all or just in the
taskbar or had a title that I couldn't remove/shrink.

But - after some iterations - I was lucky with wxMiniFrame - see
below. NB that I had to tweak m_miniTitle to make the title bar
disappear for wxLin. There was also a need for the wxFRAME_NO_TASKBAR
style as otherwise the widget showed up in the task-bar.

I'm probably going to add that sample to the wiki if there's interest and
when I have time.

Cheers,
Volker



<minstackframe.cpp>
#include <wx/wx.h>
#include <wx/minifram.h>
#include <map>

class ProgressWidget : public wxMiniFrame
{
public:
  ProgressWidget(wxWindow* parent) : wxMiniFrame(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSTAY_ON_TOP|wxSIMPLE_BORDER|wxFRAME_NO_TASKBAR), m_iPos(-1), m_pAnimCtrl(NULL)
  {
    for(int i=0; i<9; ++i) if(m_stack.end()==m_stack.find(i)) { m_stack[m_iPos=i]=GetId(); break; }
    if(-1==m_iPos) { Destroy(); return; }
    #ifndef __WXMSW__
    m_miniTitle=0;
    #endif    
    wxBoxSizer* pSizer=new wxBoxSizer(wxHORIZONTAL);
    SetSizer(pSizer);
    wxStaticText* pText=new wxStaticText(this, wxID_ANY, wxString::Format(wxT("label %i"), m_iPos));
    pText->SetClientSize(200, 16);  
    pSizer->Add(pText, 0, wxALL|wxFIXED_MINSIZE|wxALIGN_CENTER, 1);
    Fit();
  } 
  ProgressWidget::~ProgressWidget() { m_stack.erase(GetId()); }
  bool ProgressWidget::Show(bool show=true)
  {
    int w, h, x, y;
    wxClientDisplayRect(&x, &y, &w, &h);
    wxSize s(GetSize());
    wxPoint offs;
    if(!m_iPos) offs=wxPoint(w+x-s.GetWidth()-2*wxSystemSettings::GetMetric(wxSYS_BORDER_X), h+y);
    else offs=GetParent()->FindWindow(m_stack[m_iPos-1])->GetPosition();
    offs.y-=s.GetHeight();
    Move(offs);
    return wxMiniFrame::Show(show);
  }
private:
  int m_iPos;
  static std::map<int, wxWindowID> m_stack;
}; // class ProgressWidget : public wxDialog
std::map<wxWindowID, int> ProgressWidget::m_stack=std::map<wxWindowID, int>();


class MyFrame : public wxFrame
{
public:
  MyFrame(const wxString& title) : wxFrame(NULL, wxID_ANY, title)
  {
    timer.SetOwner(this);
    timer.Start(1000);
  }
  void OnTimer(wxTimerEvent&)
  {
    ProgressWidget* pProgressWidget=new ProgressWidget(this);
    pProgressWidget->Show();
  }
private:
  MyFrame() {}
  wxTimer timer;
  DECLARE_EVENT_TABLE()
}; // class MyFrame : public wxFrame
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_TIMER(wxID_ANY, MyFrame::OnTimer)
END_EVENT_TABLE()

class MyApp : public wxApp
{
public:
  virtual bool OnInit()
  {
    if(!wxApp::OnInit()) return false;
    MyFrame *frame=new MyFrame(_T("Stacked Widgets App"));
    return true;
  }
}; // class MyApp : public wxApp
IMPLEMENT_APP(MyApp)
</minstackframe.cpp>


-- 
mailto:  V B A R T H E L D at G M X dot D E






More information about the wx-users mailing list