|
"The typename keyword is required if a dependent name is to be treated as a type. This is a breaking change in the Visual C++ .NET 2003 compiler, made in order to conform to the ISO C++ standard."
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Thanks, you have been a big help.
Rugby League: The Greatest Game Of All.
|
|
|
|
|
IIRC, this also affected the WTL 7.0 source, specifically the printing stuff, so Nenad had to change the code in exactly the same way. Nice to know that MS get caught out just like us mortals....
Steve S
|
|
|
|
|
I'm creating a Time Series Viewer, an I'd like to let the user chose the path he wants (where he has his data).
The problem is I'm not used to MFC, and I'd like to know if there is a way to avoid creating a complicated dialog box.
If I am to do it, how do I include it to my other project, that's to say: how do I tell my main project to call this dialog box when I want it to do so, and how do I get the input in memory to use it?
Thanks
|
|
|
|
|
|
|
I have a small problem...
...and suggesting pills off the internet will earn a slapping!
I can setup a draggable menu, and respond to the WM_MENUDRAG message just fine.
I can even do a DoDragDrop and drag menu items to (e.g.) a toolbar.
But the menu is still there!
What I want to do is to dismiss the menu as soon as the dragging operation
starts (which I should be able to do responding to the WM_MENUDRAG message)
so I can drag to a toolbar covered up by the menu.
I know this is a pedantic niggle, but its been bugging me for ages!
If this is too vague, I'll upload a zipped mini-project and post a URL in
the morning. There's a bit too much code involved to just post here...
Any hints / pointers / examples appreciated,
Iain.
|
|
|
|
|
I helped with a similar problem on CG a while back. You can do it like this:
Use SetFocus() on a different control
Use SendInput() and set the dwFlags input to MOUSEEVENTF_LEFTDOWN
Use PostMessage(WM_LBUTTONDOWN, 0, 0)
Use WM_CANCELMODE
The original thread is http://www.codeguru.com/forum/showthread.php?s=&threadid=291063[^]
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Thanks for your help Roger. I'm dealing with the MainFrame menu rather than a TrackMenuPopup one,
but that shouldn't make any great difference. I'll have a play and see what's going on.
Going to Brussels in Sept?
Iain.
|
|
|
|
|
Iain Clarke wrote:
Going to Brussels in Sept?
So Brussels got the final vote then? I will have to visit the article on it.
I hope to go. I just mislaid (or lost ) my passport recently. I really have to go looking for it.
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
Looking at the sample, a mouse hook, and ::EndMenu / the cancel menu stuff you quote should
solve my problem nicely. And I'd no longer need a drag / drop menu either!
I knew there had to be an elegant solution out there. When I started to (metaphorically)
bang my head against a brick wall I knew I was using the wrong approach...
Thanks again,
Iain.
|
|
|
|
|
Thanks for that Roger. Using a mousehook to imitate a draggable menu, and the WM_CANCELMODE lets
me do what I want. Rather a roundabout method, but it works...
I can feel a flurry of small articles coming on from this pet project. I had to write a
FindMenuItemFromPoint function while may prove useful to others. Or not!
Iain.
|
|
|
|
|
I'm want to make a control that can be used in VB and I'm wondering what the best approach would be? Would it be best to use MFC, ATL, something else? The control wont have any UI. Thanks for any tips, suggestions, help.
- Aaron
|
|
|
|
|
ATL. There's no such thing as MFC interop with VB.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
What is your control supposed to do ?
What operations does it need ?
Does it have a message pump ?
If it doesn't have an UI, what is it's purpose ?
You could consider developing a COM component. Such component can be easily used in VB, without much effort. Windowless (UI-less) controls are common in the ActiveX world, so ATL would be a valid approach also. Using ATL offers platform-independence and smaller executables than MFC, which also requires the correct version of MFC Runtime installed.
So, for a coherent answer: develop an ATL control without a window. You can use it easily in VB by just registering the component, referencing it in VB, then utilizing it. I have little experience in using COM components in VB (or VB altogether), so I can't give you any definite steps on how to utilize the component in VB.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I'm trying to create dynamic menus with MFC's MDI interface. I've used CMenu's AppendMenu() or InsertMenu() function to insert a popup menu at the end of another menu in the MainFrame. The problem is that this works when the ChildFrame is first expanded when I create the menus, but if I try to create the menus when the ChildFrame is not expanded, they are not created properly. I read in the MSDN documentation that this is because the offsets of the menus are shifted by one when the MDI window is expanded. Therefore, I attempted to fix the code so it isn't position dependant, but this didn't seem to work. I think I don't understand the menu placement quite right. If anyone knows more about this, could you see where I'm going wrong in this code below and let me know?
Here's where I create the dynamic menu:
void CDoc::AddMenuUpdate()
{
CString sAddChan;
CMenu* pConfMenu = NULL;
CMenu* pTopMenu = AfxGetMainWnd()->GetMenu(); // Will this get the right top-level menu?
// Locate the configuration submenu to put the popup menu under
for (int iPos = pTopMenu->GetMenuItemCount()-1; iPos >= 0; iPos--)
{
CMenu* pMenu = pTopMenu->GetSubMenu(iPos);
if (pMenu && pMenu->GetMenuItemID(0) == ID_PROJECT_PROJECTSETUP)
{
pConfMenu = pMenu;
break;
}
}
ASSERT(pConfMenu != NULL);
// If a popup menu already exists, remove it to replace it with an updated one.
for (int iAddPos = pConfMenu->GetMenuItemCount()-1; iAddPos >= 0; iAddPos--) {
CMenu* pAddMenu = pConfMenu->GetSubMenu(iAddPos);
if(pAddMenu && pAddMenu->GetMenuItemID(0) == ID_CHANOFFSET) {
if(!pConfMenu->DeleteMenu(iAddPos, MF_BYPOSITION)) {
TRACE(_T("Error removing the existing popup menu..."));
}
break;
}
}
mAddCmds.clear(); // clear out the old command to hierarchy mappings
// And then create and add the new popup menu
CMenu addMenu;
VERIFY(addMenu.CreatePopupMenu());
VERIFY(pConfMenu->AppendMenu(MF_POPUP, (UINT)addMenu.m_hMenu, _T("Add Channel")));
// Get the list of items to add to the menu...
int iLoc = 0;
for(int i = 0; i < NEW_MENU_CMDS; i++) {
mAddCmds.insert(std::make_pair(ID_CHANOFFSET + iLoc, i));
// For each heirarchy, add an item to the popup menu
addMenu.AppendMenu(MF_STRING | MF_ENABLED, ID_CHANOFFSET + iLoc, "Genero Menu Cmd");
++iLoc;
}
HMENU hMenu = addMenu.Detach(); // Do I need to detach this here? Will it make a copy when I insert it into the pConfMenu?
}
|
|
|
|
|
I am in the process of writing an article which covers many of the areas your question covers.
The main issue is:
When you get a menu from the mainframe, it has a system menu inserted at the front of it. So if you did GetSubMenu(0) on it you would get the system menu when the menu was in use (one of the documents of that type were active) or the File menu (if none of the doucment types were active).
The best way to do what you need is to go directly to the CDocTemplate::m_hMenuShared member and modify the menu. If you do the mods in the InitInstance() of your app before the menu is officially used, then all your dynamic changes will be picked up correctly.
I wrote a nice function to do menu iserting to any popup level, but its not on my work PC. I may get chance to post it tonight
Roger Allen - Sonork 100.10016
Strong Sad:
Clever I am? Next to no one.
Undiscovered and soggy.
Look up. Look down. They're around.
Probably laughing. Still, bright, watery.
Listed among the top. Ten.
Nine. Late night. Early morn.
Early mourn. Now I sleep.
|
|
|
|
|
A while ago, I posted a question concerning the problems a customer was seeing related to this message. The destination window was recieving a bad pointer to the data that WM_COPYDATA sends. The solution was to remove the NVIDIA tray application. Once that was done, the problems went away.
Now, I'm seeing the exact same problem with XP when I use "WindowBlinds" by Object Desktop. When it is loaded (doesn't matter which skin I use), the WM_COPYDATA pointer is bogus.
Any idea what is going on here? Why do these programs affect the way the WM_COPYDATA operates?
|
|
|
|
|
I saw a similar situation many years ago where a 3rd party DLL that we were using had installed a hook of some sort. That hook was intercepting messages, but not passing them on to the next message queue in the chain. Our application never saw the messages. Once we removed that DLL from the picture, all was well.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I'm writing a MFC program in Visual Studio 6.0. When I run it on my Windows XP cumputer it works great, but if I try it on my other computer with Windows 98 the program starts to "eat" memory at a very fast rate.
I have traced the problem to the following function (if I comment it out the program stops using up all the memory on the Windows 98 computer)
CClientDC dc(this);
CDC buffer;
buffer.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, SKARM_BREDD, SKARM_HOJD);
buffer.SelectObject(&bitmap);
CBrush vit(RGB(255, 255, 255));
CRect rect(0, 0, SKARM_BREDD, SKARM_HOJD);
buffer.FillRect(&rect, &vit);
for(int i = 0; i < sidor.size(); i++)
{
buffer.MoveTo(skarmKoord.at(sidor.at(i).hornPunkter.at(0)));
for(int j = 1; j < sidor.at(i).hornPunkter.size(); j++)
buffer.LineTo(skarmKoord.at(sidor.at(i).hornPunkter.at(j)));
buffer.LineTo(skarmKoord.at(sidor.at(i).hornPunkter.at(0)));
}
dc.BitBlt(5, 5, SKARM_BREDD, SKARM_HOJD, &buffer, 0, 0, SRCCOPY);
Is it something wrong with this code?
|
|
|
|
|
jonsson_84 wrote:
When I run it on my Windows XP cumputer it works great... with Windows 98 the program starts to "eat" memory...
How are you verifying these?
jonsson_84 wrote:
buffer.SelectObject(&bitmap);
Where is the call to restore the bitmap?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Actually I don't know if Windows 98 is the problem. I can hear when Windows starts to swap memory to the hardsisk.
I don't restore the bitmap. Is that the problem? How do I restore it?
Update: I have tried it on one more Windows 98 computer now, the results are the same.
|
|
|
|
|
jonsson_84 wrote:
I can hear when Windows starts to swap memory to the hardsisk.
Hardly a valid test, don't you think? While increased disk activity does indicate something is happening, without the proper tools in place, it would be really hard to pinpoint anything specific.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Of course I know that many things can increase the disk activity but it "felt" like a memory leak and it seems like I was right.
|
|
|
|
|
You must unselect bitmap from buffer , you are leaking GDI-resources.
Change:
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, SKARM_BREDD, SKARM_HOJD);
buffer.SelectObject(&bitmap);
to
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, SKARM_BREDD, SKARM_HOJD);
CBitmap* oldbitmap = buffer.SelectObject(&bitmap);
and add (after the BitBlt )
buffer.SelectObject( oldbitmap );
|
|
|
|