|
U mean type casting the CString ??
CString strTest;
To convert this to const char* ,can i use (LPCSTR)strTest ??
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
|
NiceNaidu wrote: CString strTest;
To convert this to const char* ,can i use (LPCSTR)strTest ??
const TCHAR *pStr = strTest; .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
NiceNaiduTo convert this to const char* ,can i use (LPCSTR)strTest ??
Yes, but the cast is unnecessary. Others have explained this.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
neither of those two methos r correct, because both of them return LPTSTR OR LPTSTR, but they r different to char *, when UNICODE is defined beforehand, then LPTSTR equiles w_char *. so I think u should judge if the UNICODE is defined to decide how to convert to char *
life is like a box of chocolate,you never know what you r going to get.
|
|
|
|
|
Hai,
I am to use a .h file in .c file. In the .h file i have to give a definition for a c++ class. I have to use that .h file in the .c file not .cpp file. how can i use that. To say in simple words, i have to use c++ code in a c code( that too in linux) Can any one help me???
Any help appreciated
Saravana Kumar
|
|
|
|
|
C does not support Class concept,
So replace all the Classes with structures and try.
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
|
whhich compiler u r using ?
if u r using a C compiler make the class definition in
#ifdef __cplusplus
// class Definition
#endif
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
Ya Thanks Sarath. It works i am to use cc compiler.
Saravana Kumar
|
|
|
|
|
An article I found at OldNewThings
Beware the C++ Implicit Conversion[^]
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
CMenu* menu = GetSubMenu(2);
for(int i = 0; i < menu->GetMenuItemCount(); i++)
{
EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);
}
DrawMenuBar();
I used this code to disable my second menu.But the error comes like..
'GetSubMenu' : function does not take 1 parameters
'EnableMenuItem' : function does not take 2 parameters
I think the parameters are correct,then why its coming like this.
-- modified at 2:13 Thursday 1st June, 2006
I changed the code as this..
CMenu* pMenu = AfxGetMainWnd()->GetMenu();
CMenu* Menu = pMenu->GetSubMenu(2);
for(int i = 0; i < Menu->GetMenuItemCount(); i++)
{
EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);
}
DrawMenuBar();
This time the error is come only EnableMenuItem()
|
|
|
|
|
CMenu m_Menu;
m_Menu.GetSubMenu(position);
------------------
GetSubMenu(hMenu,Postion);
------------------
CMenu m_Menu;
m_Menu.EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);
------------------
EnableMenuItem(hMenu,i, MF_BYPOSITION | MF_GRAYED);
whitesky
|
|
|
|
|
I could not understand what is hMenu..Is that handle for Menu.
|
|
|
|
|
HMENU is handle to point a menu.
it is used in Win32.
in MFC we are using CMenu instead.
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
there are a lot of articles and sample snippets included in MSDN. If u r using an old MSDN look at MSDN.com
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
|
|
|
|
|
if you use one project Win32 use
GetSubMenu(hMenu,Postion); that hMenu is one handle to menu if your project is MFC
you can use CMenu Menu; and you dont need to parameter hmenu for menu functions m_menu.GetSubMenu(pos)
whitesky
|
|
|
|
|
U should pass HMENU which points the parent menu.
e.g:
<br />
CMenu* pMenu = pMain->GetMenu();<br />
CMenu* pSubMenu = pMenu->GetSubMenu<br />
<br />
pMenu->DeleteMenu(0, MF_BYPOSITION);<br />
for(int i = 0; i < pSubMenu->GetMenuItemCount(); i++)<br />
{<br />
pSubMenu->EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);<br />
}<br />
DrawMenuBar();<br />
}<br />
I think u need to add MF_DISABLED flag, else it will just change the menu color to gray. it wont disable the menu item
SaRath
"D on't blindly follow rules you read somewhere without verifying that it makes sense for your situation!"
-- modified at 2:19 Thursday 1st June, 2006
|
|
|
|
|
SaRath C wrote: I think u need to add MF_DISABLED flag, else it will just change the menu color to gray. it wont disable the menu item
Good point. I think you might actually need both, so it's disabled and grayed (MF_DISABLED | MF_GRAYED).
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
GetSubMenu and EnableMenuItem are members of CMenu, so you need to get access to the main menu like (this is from MSDN):
CMenu* menu = AfxGetApp()->m_pMainWnd->GetMenu()->GetSubMenu(2);
and then:
menu->EnableMenuItem(i, MF_BYPOSITION | MF_GRAYED);
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hey Anu, before u ask the forum, just Check the MSDN for such small syntax errors. No Offence.
Syntax of GetSubMenu ,
It Looks like this :
HMENU GetSubMenu( HMENU hMenu,<br />
int nPos<br />
);
where hMenu can be retreived by
HMENU GetMenu(this->m_hWnd);
EnableMenuItem syntax Looks like this :
BOOL EnableMenuItem( HMENU hMenu,<br />
UINT uIDEnableItem,<br />
UINT uEnable<br />
);
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
Hi fellows.
I realized that with Visual C++ 8 it is possible to add comments in a C#-style:
<br />
class CMyClass<br />
{<br />
...<br />
};<br />
and that the compiler generates an .xml file, such as in C#. My question is the following: is there any tool such as NDoc that could process this .xml file into an HTML file?
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
The classic free tool which does (something like) this is Doxygen. It can parse C++ by itself and so doesn't require compiler support.
Steve
|
|
|
|
|
But Doxygen does not support <summary>...</summary> comments, does it?
I know there are other tools, particularly I prefer C++ Doc (www.cppdoc.com), but I'm looking for a tool that works with VC++ 8 comments.
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
Doxygen has a bewildering array of tags, although the syntax is different. It supports any C++ compiler.
Steve
|
|
|
|