How do I copy the style from one control to another?

I need to programmatically copy the style from one graph to another. I'm currently using the importstyle and export style functions but I'd like to avoid that since: 1) I'm creating >100 of the same graphs in a scrolling window and execution time is a concern, and 2) it makes it harder to redistribute the application, and 3) you shouldn't have to import/export from disk just to copy a graph style.
I noticed the copy constructor was disabled so you can't just create a new one from the original. I suppose I could iterate through all the styles and transfer them from the master graph to all the copies but is there an easier way to do that? If not, is there some sample code for that?
I'm using MStudio 7.0 for C
++.
Thanks,
-Bob

One way that you could do this would be to create a helper method that configures your graph rather than configuring it at design-time, then use that helper method to apply the settings to the new graphs that you create. However, this would only work if you wanted all graphs to be configured exactly the same way - this would not work if the settings of your master graph are changing at run-time and you want the new graphs to be configured with the current settings of the master graph.
Another approach is to query each control for IPersistPropertyBag, create an IPropertyBag, pass the IPropertyBag to the master graph's IPersistPropertyBag:ave, then pass the IPropertyBag to the new graph's IPersistPropertyBag::Load implementation. I'm not aware of any implementations of IPropertyBag that are readily available for use in applications, so the tricky part is creating the IPropertyBag. Below is a very simple implementation of IPropertyBag that should be enough to get the job done for this example. First, add this to your stdafx.h:
#include <atlbase.h>
CComModule _Module;
#include <atlcom.h>
#include <atlcoll.h>
Here's the simple IPropertyBag implementation:
class ATL_NO_VTABLE CSimplePropertyBag :
public CComObjectRootEx<CComSingleThreadModel>,
public IPropertyBag
private:
CAtlMap<CComBSTR, CComVariant> m_propertyMap;
public:
BEGIN_COM_MAP(CSimplePropertyBag)
COM_INTERFACE_ENTRY(IPropertyBag)
END_COM_MAP()
STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT* pVar, IErrorLog* pErrorLog)
HRESULT hr = E_FAIL;
if ((pszPropName == NULL) || (pVar == NULL))
hr = E_POINTER;
else
if (SUCCEEDED(::VariantClear(pVar)))
CComBSTR key = pszPropName;
CComVariant value;
if (!m_propertyMap.Lookup(key, value))
hr = E_INVALIDARG;
else
if (SUCCEEDED(::VariantCopy(pVar, &value)))
hr = S_OK;
return hr;
STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT* pVar)
HRESULT hr = E_FAIL;
if ((pszPropName == NULL) || (pVar == NULL))
hr = E_POINTER;
else
m_propertyMap.SetAt(pszPropName, *pVar);
hr = S_OK;
return hr;
Once you have a way to create an implementation of IPropertyBag, you can use IPropertyBag and IPersistPropertyBag to copy the settings from one control to another like this:
void CopyGraphStyle(CNiGraph& source, CNiGraph& target)
LPUNKNOWN pSourceUnknown = source.GetControlUnknown();
LPUNKNOWN pTargetUnknown = target.GetControlUnknown();
if ((pSourceUnknown != NULL) && (pTargetUnknown != NULL))
CComQIPtr<IPersistPropertyBag> pSourcePersist(pSourceUnknown);
CComQIPtr<IPersistPropertyBag> pTargetPersist(pTargetUnknown);
if ((pSourcePersist != NULL) && (pTargetPersist != NULL))
CComObject<CSimplePropertyBag>* pPropertyBag = 0;
CComObject<CSimplePropertyBag>::CreateInstance(&pPropertyBag);
if (pPropertyBag != NULL)
CComQIPtr<IPropertyBag> spPropertyBag(pPropertyBag);
if (spPropertyBag != NULL)
if (SUCCEEDED(pSourcePersist->Save(spPropertyBag, FALSE, TRUE)))
pTargetPersist->Load(spPropertyBag, NULL);
(Note that "CreateInstan ce" above should be CreateInstance - a space gets added for some unknown reason after I click Submit.)
Then you can use this CopyGraphStyle method to copy the settings of the master graph to the new graph. Hope this helps.
- Elton

Similar Messages

  • How to Move or Copy the Tables from One Database to Another Database ?

    HI,
          Can any one help me on this, How i can move or copy the tables from one database to another database in SQL server 2005 by using SQL query. Hope can anyone provide me the useful and valuable response.
    Thanks
    Gopi

    Hello,
    Maybe these links help you out
    http://www.microsoft.com/downloads/en/details.aspx?familyid=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en
    http://www.suite101.com/content/how-to-copy-a-sql-database-a193532
    Also, you can just detach the database make a copy and move it to the new server.

  • How to copy the data from one database to another database without DB link

    Good Day,
    I want to copy the data from one database to another database with out DB link but the structure is same in both.
    Thanks
    Nihar

    You could use SQL*Plus' COPY command
    http://technology.amis.nl/blog/432/little-gold-nugget-sqlplus-copy-command
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14357/apb.htm#sthref3702
    Edited by: Alex Nuijten on Sep 16, 2009 8:13 AM

  • How to Copy the PLD from one database to another

    Dear Members,
       i have designed the  PLD for Purchase Order, i want to copy the particular PLD into another Database.
    i tried to copy the PLD from one database to another through copy express.. i copied the PLD sucessfully. But the problem is,it copies all PLD's from one database to another. i want only the Purchaseorder PLD has to be copied in to another database.any body can help me in this regard.
    With Regards,
    G.shankar Ganesh

    Hi,
    select * into A1 from RDOC where Author !='System'
    select *  into A2  from  RITM   where Doccode  in (select Doccode from A1 )
    select * from A1
    select * from A2
    sp_generate_inserts 'A1'
    sp_generate_inserts 'A2'
    you will get Insert scripts of A1 and A2 tables .After that You 'll  Replace A1 to RDOC and A2 to RITM.
    So that you can RUN this SQL srcipts any where (In any Database)
    but First u have to run sp_generate_inserts  Storeprocedure(from websites) .
    drop table A1,A2

  • I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?

    I have no problems copying iMovie Events from one Mac to another, however, how can I copy iMovie Projects from one Mac to another?  Any help will be appreciated.  Thank you.

    This should give you some good insight, I'd probably store them on an External HD on the old machine and then just drag and drop to the new machine.
    https://discussions.apple.com/docs/DOC-4141

  • How can I copy cell formatting from one range to another?

    How can I copy cell formatting from one range to another, including text fonts, colours, borders, etc., so that, for example, I can reuse a formatted reconciliation table again in different parts of a sheet?

    Hi George,
    Wayne found the Spinning Beachball of Death, and you will find it too.
    Numbers is not good at handling large datasets. Might I suggest that you group your data into smaller sets (each month, perhaps?) and save each group in a separate Numbers document. Numbers will not link between documents, but you could have a summary Table within each document. Then comes the "clunky" bit of copying all those summary tables into a master document where you do the final processing of the data.
    Regards,
    Ian.

  • How can I copy GPS information from one image to another?

    I bought a Canon S100 specifically for its GPs and movie capability.  On a recent vacation, I used the S100 and a Nikon D300.  In cases where images were taken with both cameras in approximately the same place, I would like to copy the GPS information from the S100 CR2 files to the D300 NEF files.  Does anyone know how to do this or if there is any plugins that will do it?

    The added benefit of using GeoSetter to copy the information from one photo to another, is that you can see where every already-tagged photo is on a Google map to make sure the location is actually correct.  Sometimes the camera clock is off a few seconds or minutes and you can easily figure how what offset to use by watching where the existing photos show on the map.
    Using the MS Pro Photo Tools to generate a track from the existing S100 photos and then using that track in GeoSetter to assign the rest, with interpolation enabled, seems like the best course of action if the S100 track information is no longer available.
    When using an external program to Geotag images that are already in LR, to be safe you should first save all the metadata to XMP files in the folder you’re going to tag, then exit LR, then geotag the photos, then restart LR and read information from all the XMP files.
    Another benefit of GeoSetter is that you can assign the locality information to the photos that already have just coordinates in them.

  • HT1349 How do I copy my playlists from one computer to another?

    How do I copy my playlists from one computer to another? Both Acer.

    The playlists are contained in the iTunesLIbrary.itl file.
    If you are moving your library from one computer to another, simply copy the ENTIRE iTunes folder from the old computer to the new computer.

  • How do I copy Secure Notes from one computer to another in Lion?

    How do I copy Secure Notes from one computer to another?
    Keychain sync is no longer available

    Move the entire keychain to any location on the new computer and double-click it. You can then drag the notes from one keychain to the other.
    (64538)

  • How we can get the values  from one screen to another screen?

    hi guru's.
         how we can get the values  from one screen to another screen?
              we get values where cusor is placed but in my requirement i want to get to field values from one screen to another screen.
    regards.
      satheesh.

    Just think of dynpros as windows into the global memory of your program... so if you want the value of a field on dynpro 1234 to appear on dynpro 2345, then just pop the value into a global variable (i.e. one defined in your top include), and you will be able to see it in your second dynpro (assuming you make the field formats etc the same on both screens!).

  • How can you move the objects from one server to another?

    how can you move the objects from one server to another?

    Hi,
    Collecting objects for Transporting
    1. rsa1->transport connection
    2. left panel choose 'object type', middle panel choose 'infocube' and 'select objects'
    3. then choose your infocube and 'transfer'
    4. will go to right panel, choose collection mode 'manual' and grouping only 'necessary objects'
    5. after objects collection finished, create request
    6. If they are $TMP, then change the package.
    7. When you click the Save on the change package, it will prompt for transport. Here you can provide an existing open transport request number, or if you like here itself you can create a new one.
    8. You can check the request in SE09 to confirm.
    Releasing Transport Request  
    Lets say you are transporting from BWD to BWQ
    Step 1: In BWD go to TCode SE10
    Step 2: Find the request and release it (Truck Icon or option can be found by right click on request #)
    Note: First release the child request and then the parent request
    Steps below are to import transport (generally done by basis )
    Step 1: In BWQ go to Tcode STMS
    Step 2: Click on Import queue button
    Step 3: Double Click on the line which says BWQ (or the system into which transport has to be imported)
    Step 4: Click on refresh button
    Step 5: High light the trasnport request and import it (using the truck icon)
    Transport
    http://help.sap.com/saphelp_nw2004s/helpdata/en/b5/1d733b73a8f706e10000000a11402f/frameset.htm
    http://help.sap.com/saphelp_nw70/helpdata/en/0b/5ee7377a98c17fe10000009b38f842/frameset.htm
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/media/uuid/224381ad-0701-0010-dcb5-d74236082bff
    Hope this helps.
    thanks,
    JituK

  • How can I pass the photos from one iphone to another?

    how can I pass the photos from one iphone to another?

    Use the Beaming feature. See the info at the ? In iPhoto for iOS.

  • How do I transfer the data from one iPad to another

    How do I transfer all of the data from one ipad to another one?

    The best way IMO is to sync each iPad with your computer. Having all your stuff backed up on a computer is a good idea anyway. Just read how many folks here are trying to recover lost stuff that could easily be copied back from either backup or iTunes on the computer.
    Sync both iPads to the computer. Transfer all photos to the same computer. Then sync again selecting which items you want on each iPad.

  • How do I copy a photo from one folder to another one in Aperture

    I'm old and feeble      I cannot figure out how to copy a photo from one folder to another folder   and my 13 year old grandson can't figure it out either, so I feel better about it
    thanks
    canonmick

    Um ... that doesn't seem ... like a useful workflow.  When you say "folder" do you mean a Folder in Aperture (shown on the Library tab of the Inspector) or a folder in Finder?  They are not at all the same thing.
    Aperture is an image manager, with the requisite file management built-in.  Finder is a file manager.
    If you provide a full description of what are doing, and what you are trying to do, someone here can set your straight.
    Fwiw, IME, the learning curve if very long and uphill, but gentle.  What's unusual (esp. for Apple products) is that the landmass of Aperture is separated from the rest of your computer knowledge by a moat.  What I mean is, the first leap is the hardest.  After that, you'll be on firm ground, ready to explore.

  • How do i copy a layer from one psd to another

    how do i copy a layer from one psd to another

    Select...Select All, Ctrl+C to copy the contents to the Clipboard, then in the other PSD image use Ctrl+V to paste the contents in on its own layer.
    Ken

Maybe you are looking for

  • Problem in opening query in excel 2007

    Hi All, I am using MS office 2007. But I am not able to use BEx with excel 2007. I have SAP GUI 7.10 Installed also i have installed Excel As a viewer. then also i am getting same problem. So i request you to please guide me with this issue. And as I

  • Using email to send photos

    In using Apple mail as the application for iphoto, every time I send to pc users (which is a lot) I get responses back asking me to resend as an attachment in jpeg form. I am doing that, but they say they can't save them or even right click and save

  • LSMW- Recording : Multiple Line Items

    I am trying to create an LSMW recording that simulates transaction O3I7. The thing is that we have different line items. This is similar to a sales order where we have header details and items details. I created a recording. Then I created two struct

  • SAP job SAP_COLLECTOR_FOR_PERFMONITOR getting failed  with abap dump LOAD_PROGRAM_NOT_FOUND

    Dear Experts, Background job SAP_COLLECTOR_FOR_PERFMONITOR getting failed  with abap dump LOAD_PROGRAM_NOT_FOUND. As it is hourly scheduled job and it gets finished 22 times in a day but other 2 times fails with abap dump. Finished Job log Job starte

  • InDesign CS4 will not install

    THE PROBLEM: buy clicking on the .exe file the DVD starts-up but doesn't get any further! swapped the DVD drive still no joy! Have tried everything from the Adobe TechNote: installing in "simple mode" from the desktop, virus scanner de-installed all