toolbar creation fails for windows mobile 5 (pocketpc)
Selçuk Cihan
selcukcihan at gmail.com
Sun Feb 3 11:14:09 PST 2008
Hi, i am having the following debug alert when running a wxwidgets
application targeting winmobile: wxAssertFailure failed in
wxToolMenuBar::MSWCreateToolbar(): SHCreateMenuBar failed.
in msdn http://msdn2.microsoft.com/en-us/library/aa453678.aspx it says
Windows Mobile Remarks
In Windows Mobile 5.0, a soft key bar will be automatically created if
the specification passed to SHCreateMenuBar function contains 2 or
less top level menu items and those menu items do not contain images.
If the specification passed to SHCreateMenuBar function contains
images or more than 2 top level menu items, the behavior is as
follows.
* SHCreateMenuBar will fail for a Windows Mobile 5.0-based Smartphone
* SHCreateMenuBar will create a traditional style menu bar for a
Windows Mobile 5.0-based Pocket PC
ok i am not using more than two top level menu items. In fact, i have
built and run the minimal sample of wxwidgets for windows mobile and
it runs without any problems. I have decided to use the same code for
toolbar creation in my application just to see what happens and i
still get the same error. I am working on someone else's code and i am
porting it to mobile platform that is why there may be other portions
of the code leading to the debug alert but i can not figure out what
causes the error. I am using the same preprocessor definitions as in
minimal sample. Can anyone give me ideas please, what may be the cause
of the error? The application has one frame and in the frame following
initialization code is used in which i get the error:
// frame constructor
wxFacePlayerFrame::wxFacePlayerFrame(const wxString& title, const
wxPoint& pos, const wxSize& size ,wxString p_appPath , long style)
: wxFrame(NULL, -1, title), m_bNoControls(false)
{
wxImage::AddHandler(new wxPNGHandler());
m_appPath=p_appPath;
wxConfigBase *pConfig = wxConfigBase::Get();
pConfig->Read(_T("Window/NoControls"), &m_bNoControls, false);
wxString statusText;
pConfig->Read(_T("Window/StatusText"), &statusText, _T("XfacePlayer
by ITC-irst"));
if(!m_bNoControls)
{
wxMenu *fileMenu = new wxMenu;
// the "About" item should be in the help menu
wxMenu *helpMenu = new wxMenu;
helpMenu->Append(Quit, _T("&About...\tF1"), _T("Show about dialog"));
fileMenu->Append(About_Menu, _T("E&xit\tAlt-X"), _T("Quit this program"));
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(fileMenu, _T("&File"));
menuBar->Append(helpMenu, _T("&Help"));
// ... and attach this menu bar to the frame
SetMenuBar(menuBar); // HERE I GET THE ERROR
}
wxPanel *panel = new wxPanel(this, -1);
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
wxSlider* pSlider = 0;
if(!m_bNoControls)
{
topsizer->Add( new wxStaticLine(panel, -1), 0, wxGROW );
wxSize sliderSize(60,40);
// Create Slider
pSlider = new wxSlider(panel, Fap_Slider, 0, 0, 100,
wxDefaultPosition, sliderSize, wxSL_HORIZONTAL | wxSL_LABELS);
}
if(!m_bNoControls)
{
topsizer->Add( new wxStaticLine(panel, -1), 0, wxGROW );
wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL );
wxSize buttonSize(10,10);
// PLAY Button
wxButton* playBtn = 0;
wxString dummy=m_appPath;
dummy.append(_T("res\\play.png"));
wxBitmap playImg(dummy, wxBITMAP_TYPE_PNG);
if(playImg.Ok())
playBtn = new wxBitmapButton( panel, Start_Playback,
playImg,wxDefaultPosition,buttonSize);
else
playBtn = new wxButton(panel, Start_Playback, _T("Play"));
playBtn->SetToolTip(_T("Playback current FAP file"));
button_sizer->Add(playBtn,
0, // make horizontally unstretchable
wxALL, // make border all around (implicit top alignment)
2 ); // set border width to 2
// STOP Button
wxButton* stopBtn = 0;
dummy=m_appPath;
dummy.append(_T("res\\stop.png"));
wxBitmap stopImg(dummy, wxBITMAP_TYPE_PNG);
if(stopImg.Ok())
stopBtn = new wxBitmapButton( panel, Stop_Playback,
stopImg,wxDefaultPosition,buttonSize);
else
stopBtn = new wxButton( panel, Stop_Playback, _T("Stop"));
stopBtn->SetToolTip(_T("Stop playback"));
button_sizer->Add(stopBtn, 0, wxALL, 2);
// OPEN Button
wxButton* openBtn = 0;
dummy=m_appPath;
dummy.append(_T("res\\open.png"));
wxBitmap openImg(dummy, wxBITMAP_TYPE_PNG);
if(openImg.Ok())
openBtn = new wxBitmapButton( panel, Open_FapWav,
openImg,wxDefaultPosition,buttonSize);
else
openBtn = new wxButton( panel, Open_FapWav, _T("Open"));
openBtn->SetToolTip(_T("Open animation file."));
button_sizer->Add(openBtn, 0, wxALL, 2);
// BROWSE Slider
button_sizer->Add(pSlider, 0, wxALL, 5);
// NETWORK listener
dummy=m_appPath;
dummy.append(_T("res\\TrafficGreen.png"));
wxBitmap TCPOnImg(dummy, wxBITMAP_TYPE_PNG);
dummy=m_appPath;
dummy.append(_T("res\\TrafficRed.png"));
wxBitmap TCPOffImg(dummy, wxBITMAP_TYPE_PNG);
if(TCPOnImg.Ok() && TCPOffImg.Ok())
{
wxCustomButton* serverBtn = new wxCustomButton(panel, Listen_TCP,
TCPOffImg,wxDefaultPosition,buttonSize);
serverBtn->SetBitmapSelected(TCPOnImg);
serverBtn->SetToolTip(_T("Start/Stop Server Mode"));
button_sizer->Add(serverBtn, 0, wxALL, 2);
}
else
{
wxToggleButton* serverBtn = new wxToggleButton(panel, Listen_TCP,
_T("Server"));
serverBtn->SetToolTip(_T("Start/Stop Server Mode"));
button_sizer->Add(serverBtn, 0, wxALL, 2);
}
// SOUND_ON toggle
dummy=m_appPath;
dummy.append(_T("res\\volume.png"));
wxBitmap sndOnImg(dummy, wxBITMAP_TYPE_PNG);
dummy=m_appPath;
dummy.append(_T("res\\volumeNo.png"));
wxBitmap sndOffImg(dummy, wxBITMAP_TYPE_PNG);
if(sndOnImg.Ok() && sndOffImg.Ok())
{
wxCustomButton* soundBtn = new wxCustomButton(panel, Sound_On,
sndOnImg,wxDefaultPosition,buttonSize);
soundBtn->SetBitmapSelected(sndOffImg);
soundBtn->SetToolTip(_T("Sound On/Off"));
button_sizer->Add(soundBtn, 0, wxALL, 2);
}
else
{
wxToggleButton* soundBtn = new wxToggleButton(panel, Sound_On, _T("Sound"));
soundBtn->SetToolTip(_T("Sound On/Off"));
button_sizer->Add(soundBtn, 0, wxALL, 2);
}
// SAVE AVI Button
wxButton* aviBtn = 0;
dummy=m_appPath;
dummy.append(_T("res\\camera.png"));
wxBitmap aviImg(dummy, wxBITMAP_TYPE_PNG);
if(aviImg.Ok())
aviBtn = new wxBitmapButton( panel, Save_AVI,
aviImg,wxDefaultPosition,buttonSize);
else
aviBtn = new wxButton( panel, Save_AVI, _T("Save AVI"));
aviBtn->SetToolTip(_T("Save as AVI"));
button_sizer->Add(aviBtn, 0, wxALL, 2);
topsizer->Add(button_sizer, 0, wxALIGN_CENTER );
}
// SetSizer( topsizer ); // use the sizer for layout
panel->SetSizer( topsizer );
panel->SetAutoLayout( TRUE );
topsizer->SetSizeHints( this ); // set size hints to honour minimum size
// create a status bar
CreateStatusBar(2);
SetStatusText(statusText);
//SetDropTarget(NULL);//new DropFAPFileTarget(this));
}
More information about the wx-users
mailing list