MFC & ActiveX Control

chepuri_uk
chepuri_uk used Ask the Experts™
on
How can we draw on a ActiveX control in design-mode using VC++ (MFC)?

For example, if we created a ActiveX Control and placed on a DialogBox ( i.e Dialog based application), now we want to draw something on a ActiveX Control in design-mode. Remember,
we haven't yet compiled the DialogBox application. Is this possible ?

Any help/Suggestions...

Thank you.
-Umakanth
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Check AmbientUserMode. If it is TRUE, it is in run mode, otherwise in desig. Please look at this sample....

void CPictureCtrlXCtrl::OnDraw(
               CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
     // TODO: Replace the following code with your own drawing code.
     if ( TRUE == AmbientUserMode() )
     {
          // Run Time
          m_oPictureEx.OnDraw(pdc);
     }
     else
     {
          // Design Time
          CRect rcWnd(rcBounds);
          rcWnd.right--;
          rcWnd.bottom--;

          pdc->FillSolidRect(&rcWnd, GetSysColor(COLOR_3DFACE));
          pdc->Draw3dRect(&rcWnd, GetSysColor(COLOR_3DDKSHADOW), GetSysColor(COLOR_3DLIGHT));

          rcWnd.left          += 4;
          rcWnd.right          -= 4;
          rcWnd.top          += 4;
          rcWnd.bottom     -= 4;
          pdc->DrawText("Picture Control", &rcWnd, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
     }
}


Good Luck

Author

Commented:
Thank you.

Does it Possible to draw on a ActiveX Control in Design-mode using Mouse (i.e Free hand drawing )?

I have to check that. I think that is not possible.....Are you getting Mouse Move in Design Time....? I don't think so...

Roshmon

C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Author

Commented:
Thank you.
No.Even if i change Mouse cursor also it's not reflecting in design-time or sometimes application is hanging.
I think only the draw is possible in design time. One tricky way is that, creating a timer and getting the cursor position using GetCursorPos and can draw along with the mouse. But that is overhead.

Roshmon

Author

Commented:
If we do like this, does it safe in the long run ?
Better is draw just in OnDraw, do not handle mouse or timer.
I think my comment almost reached to answer.. If Yes, please rate it.

Roshmon

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial