|
1) I would derivate a new class CMyRichEditCtrl from CRichEditCtrl, adding these functionnalities
void CMyRichEditCtrl::OnRButtonDown(UINT nFlags, CPoint point) <br />
{<br />
CPoint local = point;<br />
ClientToScreen(&point);<br />
GetParent()->SendMessage(WM_CONTEXTMENU, (WPARAM) GetParent()->GetSafeHwnd(), <br />
MAKELPARAM(point.x, point.y));<br />
CRichEditCtrl::OnRButtonDown(nFlags, local);<br />
}<br />
<br />
LRESULT CMyRichEditCtrl::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) <br />
{<br />
<br />
if(message == WM_CONTEXTMENU){<br />
GetParent()->SendMessage(WM_CONTEXTMENU, wParam, lParam);<br />
return(0);<br />
}<br />
else<br />
return CRichEditCtrl::DefWindowProc(message, wParam, lParam);<br />
}
The dialog class then implements the answer to the "Context Menu" message (m_RichEdit is an instance of CMyRichEditCtrl):
void CMyDialog::OnContextMenu(CWnd* pWnd, CPoint point) <br />
{<br />
if (point.x == -1 && point.y == -1){<br />
CRect rect;<br />
m_RichEdit.GetClientRect(rect);<br />
m_RichEdit.ClientToScreen(rect);<br />
point = rect.TopLeft();<br />
point.Offset(5, 5);<br />
}else{<br />
CRect codeWindowRect;<br />
<br />
m_RichEdit.GetWindowRect(&codeWindowRect);<br />
if(!codeWindowRect.PtInRect(point))<br />
return;<br />
}<br />
<br />
<br />
CMenu menu;<br />
VERIFY(menu.LoadMenu(IDR_CONTEXT_MENU));<br />
<br />
CMenu *pPopup = menu.GetSubMenu(SUB_CCODE);<br />
ASSERT(pPopup);<br />
<br />
long lStart, lEnd;<br />
m_RichEdit.GetSel(lStart, lEnd);<br />
pPopup->EnableMenuItem(IDC_COPY, <br />
MF_BYCOMMAND | ((lStart != lEnd) ? MF_ENABLED : MF_DISABLED | MF_GRAYED));<br />
pPopup->EnableMenuItem(IDC_CUT, <br />
MF_BYCOMMAND | ((lStart != lEnd) ? MF_ENABLED : MF_DISABLED | MF_GRAYED));<br />
pPopup->EnableMenuItem(IDC_PASTE, <br />
MF_BYCOMMAND | ((m_RichEdit.CanPaste()) ? MF_ENABLED : MF_DISABLED | MF_GRAYED));<br />
pPopup->EnableMenuItem(IDC_CLEAR, <br />
MF_BYCOMMAND | ((lStart != lEnd) ? MF_ENABLED : MF_DISABLED | MF_GRAYED));<br />
pPopup->EnableMenuItem(IDC_UNDO, <br />
MF_BYCOMMAND | ((m_RichEdit.CanUndo()) ? MF_ENABLED : MF_DISABLED | MF_GRAYED));<br />
<br />
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);<br />
}
The dialog class implements also the code for the different menu items.
2) A variation could be to do the "SetWindowText" in the CPropertyPage::OnInitDialog, where the Property Page has a valid HWND.
HTH,
K.
Angels banished from heaven have no choice but to become demons
Cowboy Bebop
|
|
|
|
|
1) Merci beaucoup . I've also found an article on CP about that inbetween, however your solution seems more precise.
2) That's what I thought. I've also tried it (forgot to mention it), like this :
In Dialog
CPropertypage shdlg;
shdlg.m_NewTitle="Hello World"; In CPropertypage::OnInitDialog
SetWindowText(m_NewTitle);
This does not throw an exception, but does not change the title neither.
~RaGE();
|
|
|
|
|
we are developing an e-mail client in school, and I wonder how to authentificate to the mail-server, if sending an mail from home. My teacher said, I have to do a pop3 before I send the mail, but that didn't work (I didn't exactly understood what he means...)
..and now I'm here and asking some real IT-gurus...
thanks
andy
|
|
|
|
|
I assume you're recieving email from the server using pop3, and sending it using smtp?
Basically, some smtp servers will only allow you to send an email if they recognise that you're a valid user. However, smtp doesn't have any kind of login system, so instead you must first connect and login to their pop3 server, then the smtp server will allow you to send mails
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Thanks, but I made it this way and it didn't work.
There must be something wrong in my code.
|
|
|
|
|
It works now. I didn't send the correct e-mail address with the rcpt to command.
|
|
|
|
|
Probably anyone, who has ever try to obtain mac address has found page at Winsock Programmer's FAQ and saw all three samples. The most "complicated" method there was SNMP method and it actually works everywhere i tryed. But (there is allways some but)...
After enumerating all mac addresses for my devices, i found myself tiny little confused. I have 2 network cards, one for internal network and one for inet, but i have 4 mac addresses. After some clicking i found two more device drivers. Every one of those two has its own mac address!!
Now the question... how to figure out which mac address is owned by actually hardware (2 ethernet cards)?
I have found one way, to get ip address from winsock and snmp, then match them and get mac address for match, but it is kind a annoying...
Thank you for reading this,
Rok
|
|
|
|
|
I'm using Visual C++ version 6.0.
I don't manually add text to the rich edit control. My application is responsible for displaying text in the MFC rich edit control.
Everytime, a new line of text is added, I want to scroll to the end of the rich edit control. For doing this I use the member RichEditCtrl::ScrollLine.
I know that if I use the ScrollLine function with a number of lines > than the total amount of lines in the rich edit control, the rich edit control is scrolled so that only the last line is shown.
This is certainly not what I want. The result I want to reach is that the last line is displayed at the bottom of the rich edit control, so that as much lines as possible are always visible. This can be compared with setting the focus to the rich edit control and entering CTRL-END.
The problem is that it doesn't work.
The text that is added to the rich edit control is using the Arial font (sometimes size 12, sometimes size 32 or 46). After the RichEditCtrl::ScrollLine the last line(s) is still not visible in the rich edit control, or the last line is only partially shown.
How can I solve this.
One more thing, the apllication is running on a Windows '98 PC.
|
|
|
|
|
I'm doing this with
CRichEditCtrl someCtrl;
someCtrl.LineScroll(someCtrl.GetLineCount());
this scrolls to the end, and displays the last line at the bottom.
-
|
|
|
|
|
On which OS ? I tested my application first on Windows 2000 and there it works fine (I apllied it the same way you did). On Windows '98 however I get a complete other result???
|
|
|
|
|
Sorry, my fault.
I've done this on Windows 2000 and XP, only.
-
|
|
|
|
|
Friends, I developed an application in MFC and link is "statically" with MFC. The application also uses an ActiveX control that i developed.
Now i want to distribute my application's exe with ActiveX control. As i said before that my application is linked statically with MFC. In such case, do i also need to link my ActiveX control statically with MFC or not ?????
|
|
|
|
|
no. you can link your control either way.
-c
Zzzzz...
|
|
|
|
|
In the watch window, when the value of a variable is displayed
as
"Error. error in OMF type information"
What is the interpretation of that?
|
|
|
|
|
the debugger probably can't see the symbol you're asking it to display (out of scope, most likely)
-c
Zzzzz...
|
|
|
|
|
That was my guess. However, the variable I am after is passed as a parameter to a function. For example:
bool MyFunc(CPoint SomePoint)
{
CPoint TestAPoint;
TestAPoint(SomePoint);
// Do stuff....
return true;
}
Now, in the watch window, for both variables, (SomePoint and TestAPoint) I get the OMF error. Even if I try and read out say, TestAPoint.x and TestAPoint.y. However, if I dump TestAPoint.x, TestAPoint.y, SomePoint.x and SomePoint.y to an ASCII file, I can see that indeed the points are there and are correct - they simply will not display in the watch window
|
|
|
|
|
rebuild-all .... sounds like the complier and debugger are confused.
-c
Zzzzz...
|
|
|
|
|
dear all,
how do i construct a DWORD value from a CString,
eg the code;
CString s("0x600");
SomeFunction(s); //SomeFunction(DWORD);
gives an error
|
|
|
|
|
strtoul()
a DWORD is a typedefed unsigned long.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
thanx for a precise reply!
|
|
|
|
|
hello,
How to get mousemove msg to a CButton ctrl placed in a dialog.
Mahesh
|
|
|
|
|
Derive your class CMyButton from the CButton one and handle CMyButton::OnMouseMove()
~RaGE();
|
|
|
|
|
hi all,
could you please help me code a file mask matching function?
i mean, i should see if a given name matches a particular mask. the mask should have wildcards *,? , etc.
thanks
Hari Krishnan
|
|
|
|
|
Why reinvent the wheel? Use PathMatchSpec() in shlwapi.dll
--Mike--
Looks like I picked the wrong week to stop sniffing glue.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Or, if you don't want to use shlwapi.dll to get PathMatchSpec, a useful function can be found here:
http://www.codeproject.com/string/wildcmp.asp[^]
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|