Solved

ATL Composite Control Sample

Posted on 2000-02-25
16
698 Views
Last Modified: 2013-11-25
I am new to atl-I have created an atl composit control that contains 1 activex control.  I need to do the following.

1-Have the contained control always move/size to completely fill the atl control (IE I want the atl control to basically not exist from the users perspective).

2-I need the atl control to have an OLE verb called "Edit".  The Edit action needs to call a method on the control.  How to create the Edit Verb and How to call a method on the contained control?

3-I am inserting this control into Visio (a drawing program) When ever the Edit verb is executed I need the atl control to set the dirty flag so visio will see it as needing to be saved.  When visio saves the document I need the contained active x control to be persisted in the visio document. When visio loads the document I need the contained controls info put pack in the contained control.  Basically how to get the atl control to persist the activex control.

I know this is pretty broad but I need to get something like this working fast.  Code samples/snipets appreciated.
0
Comment
Question by:PeterMorrone
  • 9
  • 7
16 Comments
 
LVL 11

Accepted Solution

by:
mikeblas earned 500 total points
ID: 2566454
Please see the COMPER.ZIP and XCTRL.ZIP samples at http://www.nwlink.com/~mikeblas/samples/ . (Note that my webpage will someday move to http://www.mooseboy.com/ )

..B ekiM
0
 

Author Comment

by:PeterMorrone
ID: 2566504
I went to the web site but the zip files were not there....
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2566523
OK, the files are up. As usual for my samples, please use "Find in Files" to search for "//SAMPLE" to see the code I added above what the Wizard gave.

1) To do this, just handle OnSize() in the composite control. Turn around and size the contained OLE control after measuring the client area of the composite control.

2) I just added an Edit verb to both the XCTRL and the COMPER control. COMPER finds the dispid on the contained control and calls it with Invoke(). You add methods using the context menu in the ClassView.

3) Edit in the COMPER control sets m_bRequiresSave to let the persistance interfaces (eg, IPersistStream and IPersistStorage) know that the content is dirty.

If you have questions about the code, just ask 'em here.

..B ekiM
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2566524
Sorry; I botched one of the ZIPs, so it took too long. They're up now.

..B ekiM
0
 

Author Comment

by:PeterMorrone
ID: 2566684
Mike,

I got the files and built them both, I went to Visio and inserted the Comper control and I got a Grey square that says "ATL Composite Control".  No X  or anything like that.  Any Ideas?
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2566715
Which version of which Visio product are you using?

I did my testing with Test Container, since I don't have any Visio products.  Does it work in Test Container on your machine?

..B ekiM
0
 

Author Comment

by:PeterMorrone
ID: 2567049
I am using visio 2000 professional.  I tried it in the test container and it worked ok.  I have built controls with mfc and they work fine with visio as well.  I wonder if visio requires some other interface(s).  I will check out the other items and see if visio can shed some light on the subject.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2567089
I found a testing machine that has Visio 5.0 Standard.

If I insert a Comper, it draws correctly. If I click on something else in Visio, it deactivates the control and the control shows only a grey background and "ATL Composite Control", as you describe.

If I doulbe-click on the control, it activates and then draws correctly again.

That's what the ATL Composite Control does by default if it's not in-place active.

If you want to change that behaviour, you can add an override to your composite control class:

   virtual HRESULT OnDraw(ATL_DRAWINFO& di)
   {
      // your special drawing code here!
      return S_OK;
   }

Note that ATL destroys the contained dialog box when the control goes inactive--you can't show it when the control isn't active.  (Maybe with some crazy gyrations you can, but...)

..B ekiM
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:PeterMorrone
ID: 2570971
1-I dont see the Ole verb "edit" on the control.  What I need is how to get the control to handle the Ole verb (in mfc you would do a ON_OLEVERB(AFX_IDS_VERB_EDIT, propwindow)).


2-The issue of not drawing the control when not in-place active really sucks.  This is real important for display as well as printing from visio.  If you can figure out a good solution I would gladly increase the points to 750.  Otherwise I suppose I will need to go back to trying the same thing with the MFC Active X control.
0
 

Author Comment

by:PeterMorrone
ID: 2571086
1-I dont see the Ole verb "edit" on the control.  What I need is how to get the control to handle the Ole verb (in mfc you would do a ON_OLEVERB(AFX_IDS_VERB_EDIT, propwindow)).


2-The issue of not drawing the control when not in-place active really sucks.  This is real important for display as well as printing from visio.  If you can figure out a good solution I would gladly increase the points to 750.  Otherwise I suppose I will need to go back to trying the same thing with the MFC Active X control.
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2572743
1) Oh!  You really did want a verb!  I added a method. Most people don't use OLE verbs anymore. I'll see if I can fix that around for you today.

2) I'll look into it.

..B ekiM
0
 

Author Comment

by:PeterMorrone
ID: 2572849
All this revolves around using the control in visio.  Visio, when you right click on it presents a list of the OLE verbs the control implements and alows you to specify which verb gets executed when you double click on the Control.
0
 

Author Comment

by:PeterMorrone
ID: 2596255
Any progress on this???
0
 
LVL 11

Expert Comment

by:mikeblas
ID: 2617545
I've never heard of an OLE verb named EDIT. OLEverbs include:

  OLEIVERB_PRIMARY
  OLEIVERB_SHOW
  OLEIVERB_OPEN
  OLEIVERB_HIDE
  OLEIVERB_UIACTIVATE
  OLEIVERB_INPLACEACTIVATE
  OLEIVERB_DISCARDUNDOSTATE
  OLEIVERB_PROPERTIES

When I right-click on the control, I don't see the verb list you're talking about, or a way to set which verb happens when I double-click. Can you be more explicit about the locaiton of that command?  (Again, I'm using Visio Standard, and not Professional...)

..B ekiM
0
 

Author Comment

by:PeterMorrone
ID: 2637825
From the MFC Help,
*****************
COleControl::OnEdit
virtual BOOL OnEdit( LPMSG lpMsg, HWND hWndParent, LPCRECT lpRect );
......
Remarks

Call this function to cause the control to be UI activated. This has the same effect as invoking the control's OLEIVERB_UIACTIVATE verb.

This function is typically used as the handler function for an ON_OLEVERB message map entry. This makes an “Edit” verb available on the control's “Object” menu. For example:


***********************


SO I guess the edit verb is the UIACTIVATE verb.  I could just as easily use the OLEIVERB_PROPERTIES

verb.  That would be better in fact.  These verbs appear in visio when you right click on the control, the last item in the context menu is the "Control Name Object" submenu which lists the available verbs.  IN an mfc control, doing...
ON_OLEVERB(AFX_IDS_VERB_EDIT, OnEdit)
would cause 'Edit' to appear in the menu.  Basically I want to hook a verb and bring up my own properties window.  I dont want to use the standard property dialog that MFC or ATL provide you with so that is why with MFC I used the Edit verb.  If we can trap the Properties verb and NOT bring up a normal propery sheet but call one of my methods that would be just as good.

All visio versions work the same regarding active x handling.  The double click behavior is specified in that same context menu, under the format submenu, under the behavior option.  This will bring up a dialog box with a tab called "Double Click" one of the options is "Ole Verb" and a pull down of all available verb will be seem.


Sorry I took so long getting back to you, I was away on business.  Any  ideas on getting the control to display when not active?  This is critical.  At this point, an MFC solution would also be acceptable.  If you can get the desired behavior in either MFC or ATL, I would increase the point value to 1000.  The goal ultimately is to have a contained activex control appear in visio, have a verb to bring up a custom dialog (not the normal properties dialog, however the property verb would be ok to use if we could trap it) and have the contained control allways show and print in visio.
0
 

Author Comment

by:PeterMorrone
ID: 2687495
Well, I guess the issue here is that there is probibly no easy way to render the contained control when the container control in not inplaceactive.  This would prevent proper printing and other issues.

If you cant help me on this issue then replay as such and I will award you the points for your time and answers to date.

Thanks
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now