Thursday, September 25, 2008

Adding accelerator keys in VC

A microsoft support link shows in a pretty straightforward way how to implement an accelrator key. Have a go

Getting the hyper link to work in CRichEditCtrl

Trying to get a mouse click to work in RichEdit and not succeeding? I faced a similar issue and ended up with this flow

Set the SetEventMask for your m_MyRichEdit (this is my control variable for the CRichEditCtrl class) to understand links
m_MyRichEdit.SetEventMask( \
m_MyRichEdit.GetEventMask() | ENM_MOUSEEVENTS)
Now, add a override function for OnNotify in your class. In the .h file, add
afx_msg BOOL OnNotify (WPARAM wParam, \
LPARAM lParam, LRESULT *pResult);
Add the corresponding function similar to the one below
BOOL CParentDlg:: OnNotify (WPARAM wParam, LPARAM lParam, LRESULT * pResult) 
{

if (LOWORD (wParam) == IDC_RICHEDIT)
{
MSGFILTER * mf = (MSGFILTER *) lParam;
switch (mf-> msg)
{
case WM_LBUTTONUP:
ENLINK *p_EnLink;
p_EnLink = (ENLINK *)lParam;
m_MyRichEdit.SetSel (p_EnLink->chrg);
CString szLinkString = m_RichEdit.GetSelText ();
break;
)
)

return CDialog:: OnNotify (wParam, lParam, pResult);
)
Now, your szLinkString will have the data you need to manipulate. You can use this with the ShellExecute function to popup whatever you want.

On, by the way, you need to add RTF content if you intend to make that identifiable. It goes something like
CString szT = "{\\rtf1 \\par http " + szAppendString + " \\par}";
My above code will popup a http link using which I Open it in ShellExecute

Tuesday, September 02, 2008

Auto Complete in VC++ 6

When the "Auto Complete" (Complete Word) feature of VC (6 in my case) stops working, all you need to do is
1. close the project
2. Go to the project directory
3. Remove the .ncb file in the directory
4. Re-open the project

Voila, its working !!!
(atleast it started working for me).

Ensoy