|
I am not sure, but I think it is a good idea to do such a thing.
Actually I avoid making circular includes in this way.
|
|
|
|
|
reza matinnejad wrote: I avoid making circular includes in this way
this CANNOT happen, as long as you designed your headers correctly.
there is a multiple includes exclusion system which tells for the header which it's defined in not to include it more than once...
If you're using Visual Studio only, the following is good and prefered for performances. This is MS specific:
<font color="green">
<font color="blue">#pragma once</font>
<font color="green">
if your sources are portable on pultiple plateforms, then use the standard construction which works on any compiler (Visual C++ included):
<font color="green">
<font color="blue">#ifndef</font> __YOUR_HEADER_FILE_H_INCLUDED__
<font color="blue">#define</font> __YOUR_HEADER_FILE_H_INCLUDED__
<font color="green">
<font color="blue">#endif</font> <font color="green">//At the very end of the file</font>
|
|
|
|
|
Thank you
|
|
|
|
|
ps, i didn't say it, because it was obvious to me, but you have to be careful that the macros such as "__YOUR_HEADER_FILE_H_INCLUDED__" is unique for each file (if 2 headers define the same macro, redefining identifiers errors may happen)...
|
|
|
|
|
how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..
|
|
|
|
|
Better idea that I would suggest is to disable the edit box. Use the following function to disable the Edit box.
EnableWindow(FALSE)
Regards,
Rane
|
|
|
|
|
Yes, derive your own class from CEdit and handle WM_CONTEXTMENU message . For information on
WM_CONTEXTMENU[^]
I hope it helps..
Regards,
Sandip.
|
|
|
|
|
can u plz give me a code that using WM_CONTEXTMENU to restrict right cliking in edit box
|
|
|
|
|
You can try something like this..
BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
ON_WM_CONTEXTMENU()
ON_MESSAGE(WM_COPY,OnCopy)
ON_MESSAGE(WM_PASTE,OnPaste)
END_MESSAGE_MAP()
void CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
{
}
void CMyEdit::OnCopy(WPARAM wParam,LPARAM lParam)
{
}
void CMyEdit::OnPaste(WPARAM wParam,LPARAM lParam)
{
}
And declarations..
protected:
afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
void OnCopy(WPARAM wParam,LPARAM lParam) ;
void OnPaste(WPARAM wParam,LPARAM lParam) ;
I hope it helps.
I assume you can derive the class from CEdit and add similar handlers to your class.
Also don't forget to add the control variable of type CMyEdit for the Edit Box.
Regards,
Sandip.
|
|
|
|
|
thanks for da reply
actually i m very beginner to visual c++ so feel problem while deriving plz can u help me further that how to derive myCEdit from CEdit and override its methods etc....
thanks in advance
|
|
|
|
|
I will advise you to read some book on MFC. Windows Programming with MFC by Jeff Prosise is good for beginners.
Now your problem.
1. Select Insert Menu -> New Class.
2. Type In your class name (CMyEdit)and select Base class as CEdit
3. Then add the handlers and their declarations from my previous posts to the class.
4. Add the member variable of type CMyEdit for Edit box.
I hope this makes sense.
But I suggest you to read from book as this is something very basic.
Regards,
Sandip.
|
|
|
|
|
thanks for da help
after deriving CMyedit class from Edit and adding handler of WM_CONTEXTMENU, WM_COPY,WM_PASTE
now plz tell the code to restrict menu and copy,paste using these methods
,means what would be coding to handle menu in these methods
void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point)
{ // TODO: Add your message handler code here
}
void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) {
// TODO: Add your message handler code here
}
void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) {
// TODO: Add your message handler code here
}
|
|
|
|
|
Blank implementation will prevent the Menu as well as copy and paste. You must have not added the member variable of type CMyEdit to your dialog in which you have your Edit Box.. You need to associate your class with the EditBox by adding a member variable and respective call to DDX_Control in the functio DoDataExchange()..
No need to edit this manually you can use wizard to add the variable. Only thing wizard will not do is to include header file MyEdit.h which you need to include manually.
I hope it is clear.
Regards,
Sandip.
|
|
|
|
|
Hi all,
I am getting an error here which usually does not happen.
I am getting
Unhandled exception at 0x77ddd83e in UpdateService.exe: 0xC0000005: Access violation reading location 0x00c7913e.
the values are:
hKey {unused=??? } HKEY__ *
lpValueName 0x004b9198 "Installer" const wchar_t *
Reserved 0 unsigned long
dwType 1 unsigned long
lpData "R" const unsigned char *
cbData 520 unsigned long
I wonder why it crashes as I use the same thing to my other inputs it does not happen. the code is this:
RMRegSetValueEx(hkey,UPDATELINK,0,REG_SZ,(BYTE*)((*Iter)->link.c_str()),_MAX_PATH);
RMRegSetValueEx(hkey,UPDATEFILE,0,REG_SZ,(BYTE*)(*Iter)->savePath.c_str(),_MAX_PATH);
RMRegSetValueEx(hkey,UPDATEINSTALL,0,REG_SZ,(BYTE*)(*Iter)->nameVer.c_str(),_MAX_PATH);
LONG RMRegSetValueEx(
HKEY hKey,
LPCTSTR lpValueName,
DWORD Reserved,
DWORD dwType,
CONST BYTE *lpData,
DWORD cbData
)
{
do
{
if (lRegOperLastErr == 1450)
{
Sleep(100);
}
lRegOperLastErr = RegSetValueEx(
hKey,
lpValueName,
Reserved,
dwType,
lpData,
cbData
);
} while (lRegOperLastErr == 1450);
return lRegOperLastErr;
}
At the bold part where the crashing happens at only one time at a specific value, that is being used with other values but does not crash.
Please advise
thanks,
Jayjay
|
|
|
|
|
monsieur_jj wrote: At the bold part where the crashing happens at only one time at a specific value,
What is that specific value that you are passing in?
Regards,
Rane
|
|
|
|
|
Hi Rane,
RMRegSetValueEx(hkey,UPDATEINSTALL,0,REG_SZ,(BYTE*)(*Iter)->nameVer.c_str(),_MAX_PATH);
the UPDATEINSTALL = _T("Installer")
nameVer = "Re-Rite Asian 6.0.0.125"
_MAX_PATH = 260
Is that all you need?
Thanks,
Jayjay
|
|
|
|
|
Why can't you use FormatMessage function to get a generic description of the error?
Regards,
Rane
|
|
|
|
|
Why are you passing _MAX_PATH instead of the actual size (in bytes) of the string?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If RegSetValueEx() is failing, why are you not calling GetLastError() ?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Can anybody suggest me a method for geting the Ip address of the computer.
Thanks in advance
With Regards
Deepu
|
|
|
|
|
void GetHostIP()
{
char *Ip;
WSADATA wsaData;
struct hostent *pHostEnt;
struct sockaddr_in tmpSockAddr;
WSAStartup(MAKEWORD(2,0),&wsaData);
char hostname[25];
strcpy(hostname,"Test Computer Name")
pHostEnt = gethostbyname(hostname);
if(pHostEnt == NULL)
{
printf("Error occured: %s\n",GetLastError());
return;
}
memcpy(&tmpSockAddr.sin_addr,pHostEnt->h_addr,pHostEnt->h_length);
Ip = NULL;
Ip = new char[17];
strcpy(Ip,inet_ntoa(tmpSockAddr.sin_addr));
printf("Ip Address of the machine %s is %s\n",Ip);
WSACleanup();
delete [] Ip;
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Please tell me the header files to be included.
|
|
|
|
|
Use gethostbyname function...
Regards,
Rane
|
|
|
|
|
Can u tell me the header files to be included.
It is showing as "undeclared identifier".
|
|
|
|
|
Documentation Check here [^]
Regards,
Sandip.
|
|
|
|