|
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
|
|
|
|
|
Thanks Steve. Normally, I use cppdoc; of course, Doxygen is an option -as many others. However, I'd like to know if there is a tool for the file generated by Visual C++ 8, the xml file.
Regards,
FG.
A polar bear is a bear whose coordinates has been changed in terms of sine and cosine.
|
|
|
|
|
Hi All,
I have implemented context menu extension on my Namespace Extension icon. I have added 4 menus in my QueryContextMenu function. This works fine in Windows 2k. But I am able to see only the first menu added by me when I test it on WinXP or on Win2k3.
Also, explorer crashes when the user selects the "Create Shortcut" menu on win 2k.
Can anyone tell me what may be going wrong here?
Thanks and Regards,
Anil
|
|
|
|
|
This is how I implemented my QueryCOntextMenu
STDMETHODIMP MyShellFOlder::QueryContextMenu(HMENU hMenu, UINT uiIndexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
m_hMenu = hMenu;
m_idCmdFirst = uiIndexMenu;
m_id = idCmdFirst;
if (CMF_DEFAULTONLY & uFlags)
return MAKE_HRESULT(SEVERITY_SUCCESS,FACILITY_NULL,0);
int i = uiIndexMenu;
MxSNECmdMgr cmdMgr;
try
{
if(!cmdMgr.IsConnectedFromShell())
{
MENUITEMINFO mii = { 0 };
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = idCmdFirst + ID_CONNECT;
mii.fType = MFT_STRING;
mii.dwTypeData = _T("Connect");
mii.fState = MFS_ENABLED;
bool b = InsertMenuItem(hMenu, uiIndexMenu++, TRUE, &mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = idCmdFirst + ID_SEARCH;
mii.fType = MFT_STRING;
mii.dwTypeData = _T("Search");
mii.fState = MFS_DISABLED;
b = InsertMenuItem(hMenu, uiIndexMenu++, TRUE, &mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = idCmdFirst + ID_CREATEUSINGTEMPLATE;
mii.fType = MFT_STRING;
mii.dwTypeData = _T("Create Using Template");
mii.fState = MFS_DISABLED;
b = InsertMenuItem(hMenu, uiIndexMenu++, TRUE, &mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = idCmdFirst + ID_DISCONNECT;
mii.fType = MFT_STRING;
mii.dwTypeData = _T("Disconnect");
mii.fState = MFS_DISABLED;
b = InsertMenuItem(hMenu, uiIndexMenu++, TRUE, &mii);
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE;
mii.wID = idCmdFirst + ID_ABOUT;
mii.fType = MFT_STRING;
mii.dwTypeData = _T("About");
mii.fState = MFS_ENABLED;
b = InsertMenuItem(hMenu, uiIndexMenu++, TRUE, &mii);
}
catch(...)
{
}
return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(i-uiIndexMenu));
}
|
|
|
|
|
Hai to all of you
i am doing my project in VC++ as Front End and MySQL as an Back End,
i am feeling some problem whenever i insert data using Form (VC++ dialog based form) i am sending some line of code written below .Please help me
where i am wrong........
void CEmpDetail::OnSubmit()
{
int i, j;
MYSQL * Conn;
MYSQL_RES * res;
MYSQL_ROW row;
CString sDAt,sEmpid,sEmpf,sEmpl,sDes,iPh,iEx,dDt,sMm,iYy,sQf,sTs,iTx,iHcx,sVis,sLoc,iOdc,sPrj,sGp,iPk,sMid,iFs,iOs;
CString sStr;
if ( (Conn = mysql_init((MYSQL*) 0)) &&
mysql_real_connect( Conn, "localhost", "", NULL, NULL, MYSQL_PORT, NULL, CLIENT_MULTI_STATEMENTS ) )
{
if ( mysql_select_db( Conn, "project") < 0 )
{
SetDlgItemText(IDC_STATIC_LOGIN_MSG, "Can't select the database !\nTry later.") ;
goto exit_here;
}
}
else
{
SetDlgItemText(IDC_STATIC_LOGIN_MSG, "Can't connect to the mysql server !\nPlease try later.") ;
goto exit_here;
}
GetDlgItemText(IDC_EMPID,sEmpid) ; ///////// Getting emp id from user
GetDlgItemText(IDC_EMPNMF,sEmpf) ;/////////emp first name
GetDlgItemText(IDC_EMPNML,sEmpl) ;///////////emp last name
GetDlgItemText(IDC_DESIGNATION,sDes) ;/////////////emp designation
GetDlgItemText(IDC_PHONENO,iPh) ;///////////phone
GetDlgItemText(IDC_EXTEN,iEx) ;//////////ext
GetDlgItemText(IDC_COMBO_DD,dDt) ;////////date
GetDlgItemText(IDC_COMBO_MM,sMm) ;////////Month
GetDlgItemText(IDC_COMBO_YY,iYy) ;////////Year
GetDlgItemText(IDC_EDIT_QFLN,sQf) ;/////qualification
GetDlgItemText(IDC_EDIT_TKSKL,sTs) ;/////////////////technical skill
GetDlgItemText(IDC_EDIT_TOTAL,iTx) ;///////////total exp
GetDlgItemText(IDC_EDIT_HCL,iHcx) ;///////hcl exp
GetDlgItemText(IDC_EDIT_VISA,sVis) ;//////////visa
GetDlgItemText(IDC_LOC,sLoc) ;////////////////loc
GetDlgItemText(IDC_ODC,iOdc) ;//////////odc
GetDlgItemText(IDC_PROJID,sPrj) ;/////////proj
GetDlgItemText(IDC_GROUP,sGp) ;///////////////group
GetDlgItemText(IDC_PACKAGE,iPk) ;//////////////package
GetDlgItemText(IDC_EMPMAIL,sMid) ;///////mail id
GetDlgItemText(IDC_OFFSH,iFs) ;/////////////////offshore
GetDlgItemText(IDC_ONSH,iOs) ;/////////onsite"vas"
if (!mysql_query( Conn,"INSERT INTO emp VALUES (\'" + sEmpid + "\',\'" + sEmpf + "\',\'" + sEmpl + "\',\'" + sDes + "\',\'" + iPh + "\',\'" + iEx + "\',\'" + dDt + "\',\'" + sMm + "\',\" + iYy + "\',\'" + sQf + "\',\'" + sTs + "\',\'" + iTx + "\',\'" + iHcx + "\',\'" + sVis + "\',\'" + sLoc + "\',\'" + iOdc + "\',\'" + sPrj + "\',\'" + sGp + "\,\'" + iPk + "\',\'" + sMid + "\',0,1)")))
{
res = mysql_store_result(Conn);
if(res)
{
MessageBox("Your Data Submit Successfully","Yse...",MB_ICONASTERISK);
}
else
{
MessageBox("Data Not Submitted","Error...",MB_ICONQUESTION);
goto exit_here;
}
}
else
{
MessageBox(" Query Not Execute ","Error...",MB_ICONQUESTION);
goto exit_here;
}
exit_here:
mysql_close( Conn );
UpdateData(FALSE);
}
i think i am lack of using any API Please help me where i am wrong.
Thanking you
Yogendra kumar kaushik
mailing me
Yogi
|
|
|
|
|
I'm not sure what you're asking but all the GetDlgItemText calls could be replaced with the DDX (Dialog Data eXchange). Use ClassWizard to add member variables for the controls then call UpdateData(TRUE) to get all the values.
Steve
|
|
|
|
|