From: mosfet on
PS : sorry for cross-posting (I have posted on wxforum.shadonet.com) but
I prefer newsgroup

Hi,

I am trying to use wxwince with xrc. So basically I have a wxdialog
defined in a XRC and when I load it I get the following message
:SHCreateMenuBar failed

wxwidgets:

CApplicationDlg::CApplicationDlg( wxWindow* parent )
{
wxXmlResource::Get()->LoadDialog(this, parent, _("ApplicationDlg"));
}





It comes from here :
tbarwce.cpp:
wxwidgets:

bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const
wxSize& WXUNUSED(size), wxMenuBar* menuBar)
{
....
#if defined(WINCE_WITHOUT_COMMANDBAR)
// Create the menubar.
SHMENUBARINFO mbi;

memset (&mbi, 0, sizeof (SHMENUBARINFO));
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = (HWND) GetParent()->GetHWND();
#ifdef __SMARTPHONE__
mbi.nToolBarId = 5002;
#else
mbi.nToolBarId = 5000;
#endif
mbi.nBmpId = 0;
mbi.cBmpImages = 0;
mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR;
mbi.hInstRes = wxGetInstance();

if (!SHCreateMenuBar(&mbi))
{
wxFAIL_MSG( _T("SHCreateMenuBar failed") );
return false;
}

SetHWND((WXHWND) mbi.hwndMB);
#else
HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND)
GetParent()->GetHWND(), GetId());
SetHWND((WXHWND) hWnd);
#endif
....
}



Should i declare a toolbar in my xrc ?
Or do I need to do something different ?.
Or Maybe I should recompile wxwidgets with WINCE_WITHOUT_COMMANDBAR
[/syntax]

Where is declare this id of 5000 ?
From: Vincent RICHOMME on
Ok I have found from an old post this :
Unfortunatelly lack of menubar in WM5 is know limitation. The problem is
that we develop wxWinCE port mainly using WinCE 4(.NET). We do want to
upgrade sources to WM5 asap and we already investigated problem of
hidden menubar, see:
http://lists.wxwidgets.org/cgi-bin/ezmlm-cgi?5:sss:71710
Since there is not enough manpower among developers, improving wxWinCE
port to WM5 is one of our selections for Google Summer of Code, see:
http://wxforum.shadonet.com/viewtopic.php?p=36278


Ok I understand but why when we create a dialog, we should also create a
menubar.
This is two different operations. So if there is some developper around
here, I would have some feedback to give to improve the wince port.


1)when you download wxwidgets-2.8.0.zip, the setup.h for the wince port
is MISSING. We have to get it from CVS (not very handy).

2)You provide embedded visual project but it doesn't work due to the
number of files. it always hang and cpu is 100%.
Only Visual studio 2005 is able to support it, so you should provide VS
2005 projecnd and workspace(if you like mine).

3)Now wince5 compiler support exceptions so you can use it

4)Files in the zip format(supposed to be used by windows developper) are
in unix format and Visual do not know how to handle this for project.

I am ready to help to improve the port but I won't have a time to submit
my fixes through CVS or patch.
I can only post some code here...

For now I would remove CreateToolbar from wxDialog::Create

bool wxDialog::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
....
#if defined(__SMARTPHONE__) && defined(__WXWINCE__)
SetLeftMenu(wxID_OK, _("OK"));
#endif
#if wxUSE_TOOLBAR && defined(__POCKETPC__)
CreateToolBar();
#endif
}

Besides on Smartphone you may want to have something different from OK
on the left menu.
You can always create the menubar in the
MyDialog::OnInitDialogFunction(wxInitDialogEvent& event).

Am I wrong ?






mosfet a �crit :
> PS : sorry for cross-posting (I have posted on wxforum.shadonet.com) but
> I prefer newsgroup
>
> Hi,
>
> I am trying to use wxwince with xrc. So basically I have a wxdialog
> defined in a XRC and when I load it I get the following message
> :SHCreateMenuBar failed
>
> wxwidgets:
>
> CApplicationDlg::CApplicationDlg( wxWindow* parent )
> {
> wxXmlResource::Get()->LoadDialog(this, parent, _("ApplicationDlg"));
> }
>
>
>
>
>
> It comes from here :
> tbarwce.cpp:
> wxwidgets:
>
> bool wxToolMenuBar::MSWCreateToolbar(const wxPoint& WXUNUSED(pos), const
> wxSize& WXUNUSED(size), wxMenuBar* menuBar)
> {
> ...
> #if defined(WINCE_WITHOUT_COMMANDBAR)
> // Create the menubar.
> SHMENUBARINFO mbi;
>
> memset (&mbi, 0, sizeof (SHMENUBARINFO));
> mbi.cbSize = sizeof (SHMENUBARINFO);
> mbi.hwndParent = (HWND) GetParent()->GetHWND();
> #ifdef __SMARTPHONE__
> mbi.nToolBarId = 5002;
> #else
> mbi.nToolBarId = 5000;
> #endif
> mbi.nBmpId = 0;
> mbi.cBmpImages = 0;
> mbi.dwFlags = 0 ; // SHCMBF_EMPTYBAR;
> mbi.hInstRes = wxGetInstance();
>
> if (!SHCreateMenuBar(&mbi))
> {
> wxFAIL_MSG( _T("SHCreateMenuBar failed") );
> return false;
> }
>
> SetHWND((WXHWND) mbi.hwndMB);
> #else
> HWND hWnd = CommandBar_Create(wxGetInstance(), (HWND)
> GetParent()->GetHWND(), GetId());
> SetHWND((WXHWND) hWnd);
> #endif
> ...
> }
>
>
>
> Should i declare a toolbar in my xrc ?
> Or do I need to do something different ?.
> Or Maybe I should recompile wxwidgets with WINCE_WITHOUT_COMMANDBAR
> [/syntax]
>
> Where is declare this id of 5000 ?
From: Vincent RICHOMME on
VZ> It doesn't hang, it just takes a really long time to rebuild
dependencies.And there is nothing we can do about it, please complain to
Microsoft.

tell it to my boss. "No problem boss I just need to wait half an hour
to be able to click"

VZ> Currently you have to import eVC project into VS2005. In the future
we hope to be able to generate them automatically.

VZ> > No idea to be honest but I don't understand how creating the
menubar here(and not in Create) helps? Could you please explain?

What I don't understand first is where does this id of 5000 come from ?
Secondly why are you trying to create a menubar in the create dialog method?
I would have done something like that in MFC:


// in a dialog
void CApplicationDlg::OnInitDialog()
{
//The first way. Using CCeCommandBar class.
CCeCommandBar *pCommandBar = (CCeCommandBar*)m_pWndEmptyCB;
pCommandBar->InsertMenuBar(IDR_MENUBAR);

/* //The second way. Using SHCreateMenuBar function.
SHMENUBARINFO info;
info.cbSize = sizeof(info);
info.hwndParent = m_hWnd;
info.dwFlags = 0;
info.nToolBarId = IDR_MENUBAR;
info.hInstRes = ::AfxGetInstanceHandle();
info.nBmpId = 0; info.cBmpImages = 0;
SHCreateMenuBar(&info); */
}

So could we imagine something similar under wxwidgets ?
So I would'nt try to create automatically a menubar but I would let it
to developper choice.












Vadim Zeitlin a �crit :
> On Mon, 12 Feb 2007 20:16:49 +0100 Vincent RICHOMME <richom.v(a)free.fr> wrote:
>
> VR> 1)when you download wxwidgets-2.8.0.zip, the setup.h for the wince port
> VR> is MISSING. We have to get it from CVS (not very handy).
>
> This should be corrected in 2.8.1 and (upcoming) 2.8.2.
>
> VR> 2)You provide embedded visual project but it doesn't work due to the
> VR> number of files. it always hang and cpu is 100%.
>
> It doesn't hang, it just takes a really long time to rebuild dependencies.
> And there is nothing we can do about it, please complain to Microsoft.
>
> VR> Only Visual studio 2005 is able to support it, so you should provide VS
> VR> 2005 projecnd and workspace
>
> Currently you have to import eVC project into VS2005. In the future we
> hope to be able to generate them automatically.
>
> VR> 3)Now wince5 compiler support exceptions so you can use it
>
> Err, great. But we don't use them and starting to use exceptions is not
> something that you can just do like that.
>
> VR> 4)Files in the zip format(supposed to be used by windows developper) are
> VR> in unix format and Visual do not know how to handle this for project.
>
> I'm not sure but I think this is fixed in later 2.8 releases too. Please
> try 2.8.2-rc.
>
> VR> I am ready to help to improve the port but I won't have a time to submit
> VR> my fixes through CVS or patch.
>
> Sorry, but it takes exactly 30 seconds to make a patch using "cvs diff".
> If you really don't have enough time for this I'm afraid it's going to be
> very difficult and even impossible to find time to make good changes too.
>
> VR> Besides on Smartphone you may want to have something different from OK
> VR> on the left menu.
>
> Yes, but "Ok" is default.
>
> VR> You can always create the menubar in the
> VR> MyDialog::OnInitDialogFunction(wxInitDialogEvent& event).
> VR>
> VR> Am I wrong ?
>
> No idea to be honest but I don't understand how creating the menubar here
> (and not in Create) helps? Could you please explain?
>
> Thanks,
> VZ
>
From: Vincent RICHOMME on
> First, let me say that I didn't write this code so I had no idea
about this neither. So I actually looked up SHCreateMenuBar() in MSDN
and learnt that nToolBarId was a resource id. Armed with this
information, I opened include/wx/msw/wince/wince.rc and found that there
is indeed a menu with this id there. Of course, using hard coded 5000
instead of a symbolic constant is a bad idea. But OTOH it would surely
have taken less time to find what does this constant stand for than to
send a message here and waitfor my reply.

Ok you are right, I am bit lazy. I admit it.
Besides I have already searched for it but since I am used to MFC I was
looking for a .h and not directly in .rc.

Anyway I will investigate why it fails and keep you informed and maybe
if I am in a good day I will post a patch.





Vadim Zeitlin a �crit :
> On Mon, 12 Feb 2007 23:28:09 +0100 Vincent RICHOMME <richom.v(a)free.fr> wrote:
>
> VR> VZ> It doesn't hang, it just takes a really long time to rebuild
> VR> dependencies.And there is nothing we can do about it, please complain to
> VR> Microsoft.
> VR>
> VR> tell it to my boss. "No problem boss I just need to wait half an hour
> VR> to be able to click"
>
> Tell your boss that VS2005 is better than eVC4. But, anyhow, what does it
> have to do with wxWidgets?
>
> VR> What I don't understand first is where does this id of 5000 come from ?
>
> First, let me say that I didn't write this code so I had no idea about
> this neither. So I actually looked up SHCreateMenuBar() in MSDN and learnt
> that nToolBarId was a resource id. Armed with this information, I opened
> include/wx/msw/wince/wince.rc and found that there is indeed a menu with
> this id there. Of course, using hard coded 5000 instead of a symbolic
> constant is a bad idea. But OTOH it would surely have taken less time to
> find what does this constant stand for than to send a message here and wait
> for my reply.
>
> VR> Secondly why are you trying to create a menubar in the create dialog method?
>
> Good question. I don't know the answer. However I lso still don't know
> why should it fail when done from here nor why should it work if done later.
>
>
> [~100 lines of quoted text snipped]
>
> Regards,
> VZ
>
From: Vincent RICHOMME on
Vadim Zeitlin a �crit :
> On Tue, 13 Feb 2007 00:19:27 +0100 Vincent RICHOMME <richom.v(a)free.fr> wrote:
>
> VR> Anyway I will investigate why it fails and keep you informed and maybe
> VR> if I am in a good day I will post a patch.
>
> Thanks! From what I can see from here, it's a really embarrassing problem
> and it would be great to have it fixed. Unfortunately I don't have any need
> for menus in wxWinCE port myself right and so it's difficult to justify
> spending time on it but if you have other questions about the current
> source, I'll do my best to answer them.
>
> Good luck!
> VZ
>
Hey But you are working for a french company not very far from me!
About my problem I suppose it comes from the fact I need to include
wince.rc in my project.
I will test tomorrow.