error with MFC in visual studio 2005

Hi,

I'am using visual studio 8 beta2, i think it's missing a lots of things.
One of them is mfc code of MFC.

When i am using CCommandBar, when i compile with emulator. It make
an error like that:
f:beta2\vctools\vc7libsce\ship\arlmfc\src\mfc\barcmd.cpp

how can i get this packet?

Thank

[316 byte] By [JulienT] at [2008-2-13]
# 1
I think MFC for pocket pc 2003 in visual studio 2005 beta 2 is downed.
I think if Microsoft don't want client use C++ instead of Dot.Net. Microsoft
should throw MFC and other C++ in vs 8.

I spent almost one days to try to work with MFC in vs 8 for pocket pc 2003.
It is so stupid.

In the end, i have to return to evc++ to make MFC.

Dot.Net is also greate, but all my source code needs the time of running.

JT

JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 2
Hi,

To use CCommandBar for pocket pc 2003 using visual studio 8.
You have to open barcmd.cpp, go to line 384.

add this line:

mbi.dwFlags = SHCMBF_HMENU;

So you can see the Menu Bar after when you use method,
InsertMenuBar

For expert, i think that you can easy using SHCreateMenuBar

Good Luck.

JT

JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 3
Hi Julien,

Can you explain what you are trying to do please? I can't reproduce the compiler errors you mention. Could you give me step-by-step details, for example:

1) Create Smart Device MFC Dialog Project
2) Add a CCommandBar to dialog class
3) etc, etc...

Also, are you attempting to rebuild the MFC DLL? I ask because barcmd.cpp is a source file and so changes to it would not be picked up by MFC projects unless you rebuilt the LIB and DLL.

Feel free to email me directly for a quicker reply (ritchieh at ... microsoft.com)

Thanks,

Ritchie

RitchieHughes at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 4
barcmd.cpp is part of the source for MFC. By default, it is installed to the following:

C:\Program Files\Microsoft Visual Studio 8\vc\ce\atlmfc\src\mfc\

RitchieHughes at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 5

Hi,

I knew it.
I sent you a letter so i think you can make a test with it.
Thank you so much.

JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 6
Hi Julien, I didn't get your email. Perhaps it was blocked by a spam filter. Can you reply here with the same message please?

Thanks.

RitchieHughes at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 7
Hi,
Sorry cos i am a little busy last week.
So we can begin with a very simple program like that.
1) Run Visual Studio 2005, i create a new MFC project for ppc2003 ( Dialog ) whose
name is Test.
2) In solution explorer, open TextDlg.h
Add variable mytest in class TextDlg like public:
...
public:
CCommandBar mytest;
3) Return TextDlg.cpp, in method OnInitDialog() add code like that:
mytest.InsertMenuBar (IDR_MYMENU);
You can make an IDR_MYMENU to test.
4) after that when debuging the program you will see the error in emulator.
Actually i don't think it's a bug in visual studio 2005, i think that i don't know how to use it.
So now i use directly SHCreateMenuBar to create a MenuBar but i met some problem when i want to insert Toolbar with SHCreateMenuBar ( can you show me how to do it ? )
In the past, with evc++ 4.0, cos i always downcast m_pWndEmptyCB ( a Command bar control in CDialog - i don't see it anymore in source code of vs 2005) to CCeCommandBar. Example like below:
CCeCommandBar *pCommandBar = (CCeCommandBar*)m_pWndEmptyCB; pCommandBar->LoadToolBar(IDR_MYTOOLBAR); pCommandBar->InsertMenuBar(IDR_MYMENUBAR);
And it works.
And Many thanks for your attention.
JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 8
If in step 3 of previous message.
I force to create CCommandBar like below:
mytest.Create(this);
After that i see that
mytest.InsertMenuBar(IDR_MYMENU);
will always reponds false. So we don't have the menubar in emulator
JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 9
Hi again Julien,
Your analysis regarding SHCMBF_HMENU is correct and this was a bug in our Beta 2 build. It was fixed a while ago for our final release build using the following code in CCommandBar::InsertMenuBarEx (in barcmd.cpp):
if ((hRsrc = ::FindResource(hInstance, pszMenu, RT_RCDATA)) == NULL)
{
mbi.dwFlags |= SHCMBF_HMENU;
}
This code is checking to see if the MENU resources has an associated SHMENUBAR resource (which is really just a typedef for RCDATA). If it doesn't, we set the SHCMBF_HMENU flag telling the OS it's just a regular menu, as you correctly pointed out. SHMENUBAR is a special resource for defining how buttons and menus are placed on the command-bar.
This is fixed for our final RTM release, but for the Beta 2 build you will need to work-around the bug by defining an SHMENUBAR resource. I hope this helps!
===================================================
Define something similar to this in your xxxxxppc.rc2 file:
===================================================
IDR_MYMENU SHMENUBAR DISCARDABLE
BEGIN
IDR_MYMENU,
3,
// Number of root menu items
I_IMAGENONE, ID_MENU1, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU1, 0, 0,

I_IMAGENONE, ID_MENU2, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU2, 0, 1,
I_IMAGENONE, ID_MENU3, TBSTATE_ENABLED, TBSTYLE_DROPDOWN | TBSTYLE_AUTOSIZE, IDS_MENU3, 0, 2,

END
===================================================
To explain:

The first "3" indicates how many menu buttons there are on the command bar (and therefore how many entries this resource has). This is followed by the 3 entries, each containing:

I_IMAGENONE: This menu's root button isn't an image
ID_MENU1: The unique command ID to fire when pressed (define it in resourceppc.h)
TBSTATE_ENABLED: The button's state
TBSTYLE_DROPDOWN: This button pop's up a menu taken from the IDR_MYMENU "MENU" resource
TBSTYLE_AUTOSIZE: Sized to the string's width
IDS_MENU1: The string resource to use as a label
0: I'm not sure what this is for, sorry!
0: The index of the POPUP element to use from your MENU resource defined in resourceppc.rc
===================================================

Please tell me if this helps unblock your application development or not. You will be able to remove this SHMENUBAR resource when you build using the final public release of Visual Studio 2005. Feel free to email me directly for additional help if this isn't useful (ritchieh@... the obvious domain! :-)

Regards,

Ritchie

--
Visual C++ for Devices Team

RitchieHughes at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 10
Hi, Ritchie
Many thank for your help.
Actually, i also did like you described last two days, but many thank for your detail.
Allow me to explain the params 0 you said that you was not sure what this is for.
0: If i understand exactly it is "string resource ID of tooltip".
Now, i need a popup menu which each item has a bitmap and a string, example like below:
_
| Bitmap1 string of bitmap1 |
--
| Bitmap2 string of bitmap2 |
--
|Menu |
But unfortunately in vs 8 i don't know how i have to add in custom resource SHMENUBAR? If you have any idea, i am happy to hear that.
Have a good weekend.
JulienT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 11
If you mean to draw icons on the command bar, just use CCommandBar.InsertToolBar(...). However, I think you mean icons on the actual drop-down menus (like Office and Visual Studio do) then you'll have to write your own code. I'm pretty sure Pocket PC, Smartphone or Windows CE don't support that by default. I don't know the best way to do that, but I suspect you'll have to attach a message ID to the command bar's button and then create and draw the popup window yourself.
RitchieHughes at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 12
I've a similar problem regarding command bar. I'm unable to hide the command bar.
I can hide sip button and menu but the space and blue bitmap remain on top.
Anyone can help?
ValerioMaarek at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...
# 13

The workaround (resource file changes) worked in beta 2, but now that I'm using the release version I'm still having the same problem AND the workaround doesn't work anymore. Any ideas?

ScottAnderson at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices Native C++ Development...