|
Ok: the following should work for 98 or later and 2000 or later. Change the style of your menu to MNS_NOTIFYBYPOS (see ::SetMenuInfo ), this will make the menu send WM_MENUCOMMAND messages instead of WM_COMMAND . WM_MENUCOMMAND provides the index of the item selected, so you don't need different command IDs any more (use whatever unique ID you want): just handle WM_MENUCOMMAND and enjoy.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thats very useful info. I should say that I am making this "menu" merely for the user to see his choices. The menu does not respond when clicked. SO when I add my menu items shall I leave the nID position as NULL?
CString myMApKeyString = "somekey";
menuPopup. APpendMenu(MF_STRING, NULL, myMapKeyString)
Thanks...
Appreciate your help,
ns
ANother thing I need to know. AFter I make this popup menu, I want it to show up when the user presses a toplevel menu. THeres no command handler that one can associate witha top level menu right? SO where shal I do the trackpopupmenu? SHould I try to do get clientrect on the menu item? How in the world do you get the clientrect of a menuItem rectangle?
|
|
|
|
|
If the app is not going to process any command, then you need nothing of the previous answer, just use 0 as nIDNewItem and you should be done.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I'm trying that. Thanks.
I think I might be on a wrong approach. MAybe I dont want to create a popup menu here? CAn I append directly to a toplevel menu? That one I have an ID for, but I didnt find an example that does that.....all these menu functions I've found are doing stuff with a CMEnu popUpMenu object.
I am writing a commands handler for my top level menu because when the user clicks it I want the popupmenu submenu to drop down....but how shhall I get the x and y for TrackPopupMenu? I want to show the popup directly under my toplevel menu item....
Probably theres another way right?
Same question: when I create my flyout menu, also a popup menu, how will i tell it to show up exactly lined up with the submenu item (like a flyout...)
Appreciate your help,
ns
|
|
|
|
|
I've always handled WM_STUFF Through the classwizard. I'm not sure about what you mean when you say "use whatever unique ID you want" , and dont know how to write the code to handle WM_MENUCOMMAND.
Is it like in the .h file you put an afx_void OnMenuCommand();<br />
<br />
ANd in the cpp messagemaps you put <br />
<br />
ON_COMMAND(WHAT_ID_HERE, OnMenuCommand);
Would you please amplify on this? I think this the way I'm going to have to put in my flyout subsubmenus, once I get this information. Thank you greatly!
Appreciate your help,
ns
|
|
|
|
|
If your submenus are for display purposes only (i.e. the app won't do anything when they're selected), then there's no need to write any command handler. Apart from this, check your docs for ON_COMMAND , they should be self-explanatory.
(I'm away from my VS now, can't help more.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Here is the problem. I need to use a dll compiled with VC6. This dll exposes a function which arguments are of type std::wstring. My main app needs to be compiled with VC.NET. However, std::wstring in VC.NET is not the same as std::wstring in VC6, and I have a nice little crash every time I try to call this function. I thought that I could solve this problem by linking to VC6 libraries from VC.NET.
The question is: How to set VC.NET project to link to msvcp60d.dll and msvcrt.dll instead of msvcp70d.dll and msvcr70d.dll?
|
|
|
|
|
Set the UseOfMfc project property to None, and add the appropriate libraries in the link tab.
If you are not using the VC7 libraries (stl7, mfc7, atl7, ...), then I don't know why you use VC7 at all. If you own the source code of this dll, then it's way much better to upgrade this dll to be full compliant with VC7.
|
|
|
|
|
I tried it already, and it doesn't work.
.S.Rod. wrote:
If you are not using the VC7 libraries (stl7, mfc7, atl7, ...), then I don't know why you use VC7 at all. If you own the source code of this dll, then it's way much better to upgrade this dll to be full compliant with VC7
Trust me: I need to use VC.NET with a VC6 compiled library
|
|
|
|
|
Nemanja Trifunovic wrote:
Trust me
No.
Nemanja Trifunovic wrote:
I need to use VC.NET with a VC6 compiled library
Write a bootstrap then. That's a dll compiled with VC6, which exposes a simple set of functions, with no stl signature at all. Doing so, the underlying dll is not facing stl7 in VC7.
|
|
|
|
|
.S.Rod. wrote:
Nemanja Trifunovic wrote:
Trust me
No.
LOL.
.S.Rod. wrote:
Write a bootstrap then
That's a good idea, thanks. If I don't find out how to use VC6 libs, I might do just that.
|
|
|
|
|
In my debug version, it does fine. rElease crashes on exit. Its an MFC MDI app, which spawns CDialog derived windows. These get pushed on to a vector and popped off when they are closed (they postmessage to the CView that spwaned them.). ANyways all I do is spawn one (modeless ) window, and close it. Then exit and it crashes, but only in the release version. I dont know where to start looking for the trouble. I dont rknow if the foll. helps.....
void CImageDisplay::OnClose(void)
{
std::vector<CImageDisplay*>::iterator itV = pImageDisplayVector.begin();
for (int i = 0 ; i < m_imageDisplayVectorIndex ; ++i , ++itV);
pImageDisplayVector.erase(itV);
imageDeque.pop_back();
m_pParentWnd->PostMessage(UDM_UPDATEDISPLAY);
CDialog::OnClose();
}
Its not the pop_back because it still crashes if I comment it out.
In the function that creates the window:
CImageDisplay* pImageDisplay = new CImageDisplay();
if (pImageDisplay == NULL) return;
BOOL ret = pImageDisplay->Create(IDD_DIALOG1, this);
if(!ret)
{
AfxMessageBox("Error creating Dialog");
delete pImageDisplay;
return;
}
pImageDisplay->ShowWindow(SW_SHOW);
pImageDisplayVector.push_back(pImageDisplay);
imageDeque.push_back(image);
m_imageIndexHi = m_imageIndexLo + imageDeque.size() - 1;
UpdateDisplay();
image.SetRawImagePointer(0);
Appreciate your help,
ns
|
|
|
|
|
I dont have an OnDEstroy or anything in the mainframe so dont know how to debug it...
Appreciate your help,
ns
|
|
|
|
|
In my MFC MDI app, I switch views. The views merely switch, they dont get recreated, so OnInitialUpdate doesnt run each time y ou switch. In View1 I have a top level menu item "User Choices" . INitially when clicked, it says nothing selected. I now go to view 2. I get information from the user in View 2, then I switch. By the time I get back to View 1, I want View 1 to have the menu ITem "User Choices" to be populated. So now when the user clicks it, a submenu drops down. Each submenu item then has its own flyout menu. WHen the user goes back to View 2 and makes new choices and returns, the menu should now have the new stuff in it.
SO should I send a message which runs a function in View 1 which then magically creates the menu using the info I gathered in View 2 and stored in a doc variable?
How do I destroy the old menu choices , so that the new ones get filled in on return to view1? In case the user cancels from View2, View 1 should retain the previous choices.
Appreciate your help,
ns
|
|
|
|
|
Anyone who knows if the file oledblob.h is avalible for the Visual Studio .NET enviroment?
(oledblob.h is an OLE DB consumer class dealing with updating and inserting blob data)
|
|
|
|
|
Is there away for an executable to modify itself, for example append data at the end of the executable or modify some internal data.
Thanks
|
|
|
|
|
If you can get to modify the flags for file opening (I mean getting rid of the flag "file in use so i cannot modify it"), you may do something like that. But it's hot stuff. What do you want to do ? A virus or something ? Anyway, there have to be a better solution to your problem than directly modifying the .exe
~RaGE();
|
|
|
|
|
Please could someone provide me with a working sample of using UpdateResource on the string table of an external exe app. Ive read several articles from MSDN in regards to string table blocks containing 16 strings etc, and allocation of the string, however no matter what i try i always seem to either overwrite the entire string block table or create an entirely new one.
My goal is to update a single string item within the string table with the contents of a user entered string.
Any help would be much appreciated.
Thanks
zebbedi
|
|
|
|
|
Hello,
I have the following code to pull HTML data from a website.. Everything works fine except that I have a small memory leak.. can someone tell me why there is a memory leak in CStdioFile..
here is the dump of the memory leak
Detected memory leaks!
Dumping objects ->
{44} client block at 0x00D226A0, subtype 0, 20 bytes long.
a CStdioFile object at $00D226A0, 20 bytes long
Object dump complete.
LPSTR url = "http://www.codeproject.com";
LPSTR filename = "C:\\codeproject.txt";
int numbytes;
char httpbuff[2048];
CInternetSession mysession;
CFile* myfile = new CFile();
CStdioFile* remotefile = new CStdioFile();
remotefile = mysession.OpenURL(url,
1,
INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
myfile->Open(filename,
CFile::modeCreate|CFile::modeWrite|CFile::typeBinary);
while (numbytes = remotefile->Read(httpbuff, 2048))
myfile->Write(httpbuff, numbytes);
myfile->Close();
remotefile->Close();
delete myfile;
delete remotefile;
Rob
|
|
|
|
|
you don't need this
RobJones wrote:
CStdioFile* remotefile = new CStdioFile();
because
RobJones wrote:
mysession.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
returns a CStdioFile pointer
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
If I do a ...
CStdioFile* remotefile = mysession.OpenURL(url, 1, INTERNET_FLAG_TRANSFER_BINARY|INTERNET_FLAG_RELOAD);
I still have a memory leak...
|
|
|
|
|
you still need to delete the remotefile pointer
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
Ahhhhhh.. Ok thanks.. that fixed it
Thanks,
Rob
|
|
|
|
|
I'm looking for some code examples for using SCP to transfer files. I'm going to throw together a dialog for browsing remote directories using SCP [basic version of WinSCP[^]] if a MFC one doesn't already exist out there as I'll need this feature in a project I'll do in the near future.
I was just wondering if anybody knows of something similar or if it's been implemented elsewhere. I can't seem to find anything but I'm probably just being blind and it's probably right under my nose.
Regards,
Brian Dela
Run naked in the snow until you're sweating like a stuck pig and can't seem to catch your breath. When the flu becomes pneumonia, they can cure that with a shot. - Roger Wright
|
|
|
|
|
You can't really browse anything with scp AFAIK. You can only do transfers.
But here's a link to PuTTY which is a set of ssh-tools for windows. Sources are available. http://www.chiark.greenend.org.uk/~sgtatham/putty/[^]
--
Eventhough the forrest is full of trees, there's still no tree between the trees.
|
|
|
|