|
Why do we need to use this function ?
Thank you.
|
|
|
|
|
You might not need to, unless this is an MFC application. It was merely a suggestion. Do you know for certain that it is not needed?
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Because it will enable/initialize the richedit support.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi everybody,
I have created an PopUp Menu in a CDialog...it works OK.
Now I want to create a PopUp Menu inside an ActiveX every time I click Button RIGHT of the mouse...
I have copied the code inside the function WM_RBUTTONDOWN...The problem is that it shows the Menu but it is DISABLED (it is shown but I can not select an option).
How can I do it to solve it...to make it enable?
Thanks
Javier
|
|
|
|
|
The menu items will be disabled until you write the code for the menu items. When the handlers are written, then the menu items will be enabled.
Artificial intelligence is no match for natural
stupidity.
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
But...I have already written the handlers...or at least...this is what I think
I enclose the code here :
HMENU hMenu = ::CreatePopupMenu();
if (NULL != hMenu)
{
// add a few test items
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 1, "Change Color");
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 2, "Hide");
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 3, "Item 3-");
ClientToScreen(&point);
int sel = ::TrackPopupMenuEx(hMenu,
TPM_CENTERALIGN | TPM_RETURNCMD,
point.x,
point.y,
m_hWnd,
NULL);
CString s;
s.Format("The selected item is %d", sel);
TRACE(s);
::DestroyMenu(hMenu);
}
Thanks
|
|
|
|
|
javi_jmc wrote:
::AppendMenu(hMenu, MF_ENABLED | MF_STRING & !MF_GRAYED, 1, "Change Color");
Do you have a function that the application would call when you click the "Change color" menu item? If not, that's what you need to do. Without a function to call, the menu item will be disabled.
Artificial intelligence is no match for natural
stupidity.
Never argue with an idiot. They will drag you down to their level where they are an expert.
|
|
|
|
|
But...why do I need a function to call ? I have "sel" which gives the value of the item selected. With "sel", I can manage the selection with, for instance, a CASE
But...if it is not possible and I have to do it as you are saying...how can I link a function to a selection?
Thanks you very much.
|
|
|
|
|
javi_jmc wrote:
But...why do I need a function to call
I hate to tell you this, but that's the way it is. When you click on a menu item, that's an event that the application will receive. If the app isn't going to handle the events then the menu items won't even be enabled. There's nothing to map the events to so there isn't any sense in enabling the menu item. Your case statement won't handle the menu event.
|
|
|
|
|
OK, so I have a header file which I call NewTypes.h that has definitions for several struct s. In particular, I have a struct PPLoutput , and I have overloaded the << operator so I can output it easily. The signature I am using for the operator is:
std::ostream& operator<<(std::ostream& s, const PPLoutput& p);
If I have the definition for this function in the header file, then I get the errors at the bottom (all files compile cleanly. I am having problems in the linking phase). Of course, I need to have NewTypes.h #include d in multiple files. I have two multiple-include guards (#pragma and #ifndef ). So, the file looks like:
#pragma once<br />
<br />
#ifndef NEWTYPES_H<br />
#define NEWTYPES_H<br />
<br />
<br />
<br />
struct PPLoutput<br />
{<br />
<br />
};<br />
<br />
std::ostream& operator<<(std::ostream& s, const PPLoutput& p)<br />
{<br />
<br />
};<br />
<br />
#endif
If I move the definition of operator<< to a different file (Combo.cpp ), then it compiles and links fine. How do I get it to link while keeping it in NewTypes.h ? I am using Visual Studio .NET 2003.
Errors below:
Combo.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
ComboDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNP.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
LNPDlg.obj : error LNK2005: "class std::basic_ostream<char,struct std::char_traits<char> > & __fastcall operator<<(class std::basic_ostream<char,struct std::char_traits<char> > &,struct PPLoutput const &)" (??6@YIAAV?$basic_ostream@DU?$char_traits@D@std@@@std@@AAV01@ABUPPLoutput@@@Z) already defined in 3PLComboDlg.obj
Release/3PLCombo.exe : fatal error LNK1169: one or more multiply defined symbols found
--
Marcus Kwok
|
|
|
|
|
|
Thanks. I tried cleaning and then rebuilding but I still get the same error.
|
|
|
|
|
Hello,
Your problem is clear! You should separate the definition of functions from the declaration. The definition (aka implementation) should be in a compilation unit (*.cpp file) the declaration should be in the header file.
if you separate those, you should have no problem.
I also got the blogging virus..[^]
|
|
|
|
|
Thanks, that worked. So, if I have the declaration in the header file but the implementation in the cpp file, then any file that includes the header file should be able to see the function?
--
Marcus Kwok
|
|
|
|
|
The problem was that your #ifdefs only protect against the header being included multiple times from the same source file. Since it is being included multiple places in your project, std::ostream& operator<< is getting defined multiple places, and therefore compiled into many different .OBJ files. The linker does not like this when it tries to tie it all together.
When you separate the header and implementation, the CPP file with the function definition gets compiled only once, so the linker is happy.
|
|
|
|
|
ricecake wrote:
So, if I have the declaration in the header file but the implementation in the cpp file, then any file that includes the header file should be able to see the function?
Yep.
When you declare something in the *.cpp file, it has internal linkage. This means that only the code after the declarating is able to see this. When you put the declaration in the *.h file, you give it external linkage. This means that all your code is able to use it as long as the header file is included.
I also got the blogging virus..[^]
|
|
|
|
|
Hi, I'm trying to allocate memory in DOS using Borland Turbo C.
I need about 1MB but the system only gives me 64Kb.
does anybody know how can I change the memory model to get more memory?
thanks in advance.
Daniel Cespedes
"There are 10 types of people, those who understand binary and those who do not"
"Santa Cruz de la Sierra Paraiso Terrenal!"
daniel.cespedes@ieee.org
|
|
|
|
|
if i remember correctly, you have to choose different memory model. "small" supports only 64kb for stack and 64kb for data. try choosing 'compact' (64kb code, 64 kb static data and stack, 1 Mb heap) or 'large' (like 'compact', but 1Mb for code).
you can change this from 'options' menu: Options -> compiler -> model.
you can read more about this in Turbo C online help.
|
|
|
|
|
Turbo C is a 16-bit compiler. I do not know of an answer but try using the large or huge memory model.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Let's do the time warp again!
(danananananana)
Anyway.
You need to use XMS or EMS or some other DOS memory extender if you want to go beyond 640K. Thankfully (for me, not you) I never did any heavy duty DOS programming. Even staying within the lower 640K was a nightmare I don't ever want to repeat.
So unless there are fancier tools available now, do some googling on expanded or extended memory. DOS/4GW was one too, I think? Several games used that IIRC.
|
|
|
|
|
Hello,
I want to catch Keyboard events of MS-Word in my MFC application without any global hooking or subclassing. Is there any other way to catch these events without the above-mentioned techniques?
Regards
Noman
|
|
|
|
|
Can someone help me, please.
I am using DOM xml parser and I have to read
node attribute. There is no problem but
when attribute has some spaces inside
i get string without it.
for example:
XML node has arrtibute: <song id=" 125 ">
and i obtaind string "125"
..spaces are trimed
And I need these spaces as well
I there any DOM parameter or way how to set "don't trim"
Thank you
viliam
|
|
|
|
|
I add CToolBar to a dialog box easily but the bar's tooltip does not show when mouse moves over its butons.
do u have solution for this?
thx
includeh10
|
|
|
|
|
Hello,
I have seen your's reference on code project. I am new to CHM format and i need to
create a CHM viewer. I have some queries regarding the same
a) what is binary TOC and binary index ( I have been able to parse the HHc and HHk fie). How i should parse the same
b) What are merged files. How i can read them
c) How how CHI, CHw and CHQ files can be created. How reading of these files will be different form the reading CHM file.
Please help me out by answering my queries.
Thanks,
Ritu
|
|
|
|
|