Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Scrolling ActiveX control

Posted on 2004-11-02
2
Medium Priority
?
455 Views
Last Modified: 2013-11-20
Hi experts

I’m relatively new to C++ and I’m taking my first tentative steps in to ActiveX. Using the App Wizard in Visual Studio.net, I have created an MFC ActiveX Control called ‘TestAX’.

The only modification I have made to it, is in the ‘CTestAXCtrl’ class I have changed the default OnDraw function so that the background rectangle and ellipse are drawn twice as big as the control itself. Shown below.

void CTestAXCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
      if (!pdc)
            return;

      // TODO: Replace the following code with your own drawing code.
      pdc->FillRect(rcBounds * 2, rush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
      pdc->Ellipse(rcBounds * 2);
}

My question is: how difficult is it to add scroll bars to the control so that the whole ellipse can be viewed. The direct base class ‘COleControl’ has a ‘ScrollWindow()’ function but if I call this in the constructor of CTestAXCtrl I get a runtime error. Same gose for the ‘ShowScrollBar()’ in the indirect base class ‘CWnd’.

Am I barking up completely the wrong tree? Its just I can’t seem to find any simple examples of this anywhere!

Thanks

Matt
0
Comment
Question by:MattWM
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
KurtVon earned 500 total points
ID: 12473337
These functions will work fine, but the confusion is in thinking the class constructor has a window.  The window is not created until long after the object is constructed, so you cannot call any window functions from the constructor.

What you need to do is watch the Create function, which should be overriddden. When the Create function completes successfully, then the window manipulations functions will work because a window handle will have been created.

Hope this helps.
0
 

Author Comment

by:MattWM
ID: 12473715
Thanks Kurt

Just as a quick test I used the two scroll functions in the OnDraw function and they appeared just as they should. Perhaps not an ideal place but it got me moving again.

I’ll probable have plenty more questions as I move on. So keep a look out.

Thanks again

Matt
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question