|
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.
|
|
|
|
|
Hi all
How can make a application which run program as a system service? Plz help me
|
|
|
|
|
Check out this link.[^]
Regards,
Rane
|
|
|
|
|
Services[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
i m using CListCtrl wit LVS_SHOWSELALWAYS and LVS_EX_FULLROWSELECT property.
here multiple items are select with the help of mouse.
i want only one row select at any condition.
please tell me how can i do this.
if possible please explain with example.
i waiting for your valuable suggestion and replies.
thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
One way would be to handle the click event on the list. Save the index of the selected item in some member variable. Once the user clicks on an item other than the selected one use SetItemState and SetSelectionMark to get this done. You already have the previously selected item index stored and can get the current one easily
Hope this helps
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
"_$h@nky_" wrote: i want only one row select at any condition.
set the LVS_SINGLESEL style.
|
|
|
|