Creating measurement studio control dynamically in VC++7.0

We downloaded an example from the
following site:
<http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3EFE056A4E034080020E74861&p_...>
We converted the project to VC++7.0
solution.
When we tried to create a single
control it worked fine.
But when we create the second control
it crashes.
void CDynamicControlDlg:nButton1()
        CNiReal64Vector rt;                
        CNiMath:ineWave(rt, 60, 1.0);
        BSTR bstrLic = :ysAllocStringLen(pwchUILic, sizeof (pwchUILic) /
sizeof(WCHAR));
        m_graph1.Create("", WS_VISIBLE, CRect(110,20,370,200),this, 0,NULL,
FALSE, bstrLic);
        m_graph1.PlotY(rt);                
        :ysFreeString(bstrLic);              
        ::AfxMessageBox("WAIT for the crash.....");
        BSTR bstrLic1 = :ysAllocStringLen(pwchUILic, sizeof (pwchUILic) /
sizeof(WCHAR));
        m_graph2.Create("", WS_VISIBLE, CRect(200,120,350,300),this, 0,NULL,
FALSE, bstrLic1);
        m_graph2.PlotY(rt);                
        :ysFreeString(bstrLic1);    

Each control needs to have a unique ID, which is what the 5th parameter
in the Create method is. Try changing the code to the following
BSTR bstrLic = :ysAllocStringLen(pwchUILic, sizeof (pwchUILic) /
sizeof(WCHAR));
        m_graph1.Create("", WS_VISIBLE, CRect(110,20,370,200),this, 0,NULL,
FALSE, bstrLic);
        m_graph1.PlotY(rt);                
        :ysFreeString(bstrLic);              
        ::AfxMessageBox("WAIT for the crash.....");
        BSTR bstrLic1 = :ysAllocStringLen(pwchUILic, sizeof (pwchUILic) /
sizeof(WCHAR));
        m_graph2.Create("", WS_VISIBLE, CRect(200,120,350,300),this, 1002,NULL,
FALSE, bstrLic1);
        m_graph2.PlotY(rt);                
        :ysFreeString(bstrLic1);    
What you were doing was giving two controls the same control ID (0 in
this case). MFC will assert in this case. I just chose 1002, but that
value will depend on how many controls you have on your dialog and what
IDs are available. So everytime you create a new control, make sure you give it an ID that is not being used by another control.
Hope this helps.
Message Edited by bilalD on 10-26-2005 09:17 AM
Bilal Durrani
NI

Similar Messages

  • I create a CNiGraph control dynamically, But why havent I seen the Demo Mode Message Window?

    I am a licenced user of Mesurement Studio. I create a CNiGraph control dynamically. All work well.
    Then I copied my source code to another PC, I run "regsvr32 cwui.ocx", I found I can compile my source code on that computer, without any message box.
    But some people said that there will be a Demo Mode Message box.
    That's to say, any one can copy my source code to other computer and compile it well, then how can I protect my right?
    On what condition the Demo Mode Message Box will appear? I want it to show up when others use my code.

    It sounds like you were expecting the message box to come up at compile-time. Is that correct? If so, that is not expected and should not ever happen - the message box that you're referring to should not come up until you actually run the application. However, if you're dynamically creating the control and you are specifying the license string at creation time in your code, I expect it would still work when you take the code to another machine. Could you please reply with more information about what you're trying to do and how you expect this to work? Thanks.
    - Elton

  • Setting Z Order of measurement studio controls in Visual C++

    How can I set the Z Order of a measurement studio control (such as a button, numeric edit, etc.) from within a VC 6.0 application? I have several overlapping controls in which the first control is on top and the controls I apply later are below. I must go through all kinds of gyrations to control the Z Order.

    Tab order in Visual C++ dialogs controls Z-plane order. You can set the tab order under Layout->Tab Order. The lower the number in the tab order, the higher on the Z-plane.
    Best Regards,
    Chris Matthews
    National Instruments

  • Measurement Studio Controls and Dialogs

    I am running a dialog based project in VC6.0 and am trying to popup other modeless child dialogs to give me info on test ranges and setup information. I really want them to be modeless so that I can run the main test panel with the test ranges visable throughout if so desired.
    I thought I was done but realized that the static control that comes with VC6.0 Standard only takes 256 characters. I suppose I could use a bunch of static controls but that looks dumb.
    Edit boxes don't work well for me because they don't like tabs and newlines. I tried the rich text box control but when I put one on any dialog, even my main one, the whole dialog never displays. (Question for Microsoft I suppose.)
    So, I started looking through the ActiveX controls and found a great plug in called Microsoft Forms 2.0 TextBox. I dropped in that control and made a nice setup box and range box for my two dialogs.
    Well, here is the problem then. When I have a "Microsoft Forms 2.0 TextBox" control on my dialog I can't display my dialog as modeless. If I try to display it as modal with .DoModal everything works fine. I see that my problem is when I try to create the modeless dialog with the following command inside the Constructor for the dialog class:
    error = this->Create(IDD_DIALOG, NULL);
    All Microsoft tells me is that if the dialog is created and initialized without errors then error should be non zero. Well, it's zero if there is any NI control on the dialog. Consequently the dialog doesn't get displayed.
    I wish that there was a nice TextBox control like in CVI. Just something you can edit straight from the dialog and it'll load itself just fine when you run it. Microsoft's standard static control is lame and the edit boxes don't let you type in the edit box from the dialog editor screen. So much for visual control. Anyway, I need some suggestions. I don't want to have the overhead of doing any SDI or MDI if I don't have to. I only do small projects and seperate Dialog projects work great.
    Maybe I'm not doing something correctly with Visual C++ itself as far as creating modless dialogs are concerned, but the fact that all controls can be displayed as modal but only non-NI controls can be displayed modelessly seems strange. Maybe it's an ActiveX thing and since the NI-controls are the only ActiveX stuff I'm using I get into trouble. I'd appreciate some advice. Thanks,
    Grant Johnson
    Grant M. Johnson
    Project Engineer
    LECO Corporation

    I'm not really sure what could be causing the problem that you are seeing, but I have attached a small Meas. Studio for VC++ 6.0 example program to this post that creates an application similar to what you have described. The example has one dialog that creates another modeless dialog when a button is clicked using the CDialog::Create function. With this example the problem you are describing doesn't show up (the second dialog has CNi controls on it and it displays fine as a modeless dialog).
    I have also tried running a modified version of the attached example that creates the second dialog as modeless from within its constructor, and it worked fine again. I believe this is exactly what you were asking about.
    If you can discern anything from this
    example program, or modify it to be more similar with your scenario (create modeless dialog from constructor), then you can let us know what might be different.
    Jason F.
    Applications Engineer
    National Instruments
    www.ni.com/ask
    Attachments:
    dialogs.zip ‏191 KB

  • Using graphs in measurement studio

    I have written in multiple languages, and this �easy� �user friendly� software package has left me completely stumped. How on earth do you put data in to a graph and display it????? Can someone please show me code examples of firstly how to shove an entire array of numbers into a graph in VB.net using the new Measurement Studio and secondly how I could update a graph plot with a next acquired sample. Please help

    "Where would I find "Creating Measurement Studio Strip Charts, Scope Charts, and Graphs" document. if it is on the website it is extremeley well hidden even from its own search engine. Does this specifically talk about VB .NET and measurement studio"
    You can find this topic, as well as several other conceptual topics about the Measurement Studio .NET features with VB.NET/C#, in the Measurement Studio help that installs with Measurement Studio. You can find this help in two ways:
    Integrated into VS.ET 2003/MSDN Help - Go to the table of contents, then the "NI Measurement Studio Help" node.
    Measurement Studio standalone help - Go to the Start Menu, then Programs->National Instruments->Measurement Studio 7.1 for VS.NET 2003->Measurement Studio Documentation
    Once you're in the table of contents, you can find the topic above by navigating to:
    - NI Measurement Studio Help
    - NI Measurement Studio .NET Class Library
    - Using the Measurement Studio .NET Class Libraries
    - Using the Measurement Studio Windows Forms .NET Controls
    - Using the Measurement Studio Graph .NET Controls
    The topic above is the second link in the list. If you have Measurement Studio 7.1 installed, this link will take you directly there.
    "Using Measurement Studio ActiveX controls I wouldn't even know where to start, there is no AxCWGraph on any toolbar."
    AxCWGraph is the name of the interop wrapper that is automatically generated by VS.NET when you add CWGraph to your project, so you won't see it in the toolbox. WaveformGraph/ScatterGraph is what you should use in .NET applications if you have Measurement Studio 7.0 or higher. I only mentioned CWGraph because this was posted to the Measurement Studio for Visual Basic forum instead of the Measurement Studio for Visual Studio .NET forum, so it wasn't clear if you were using the Measurement Studio .NET controls or the Measurement Studio ActiveX controls.
    "If NI could just stick an example of exactly how to use VB.NET with measurement studio on displaying data and the various options available and stick it for all to see on the measurement studio home page it would be great."
    There are several examples that are installed with Measurement Studio 7.1. If you installed Measurement Studio to the default location, you can find this examples at:
    Program Files
    National Instruments
    MeasurementStudioVS2003
    DotNET
    Examples
    UI
    Graph
    "I write in over ten different languages and scripts and fluent in two of them. It worries me that I can't even find the front door let alone open it."
    I can understand how this could difficult if you were not aware of the Measurement Studio help and examples. Is it easier now that you know about this content that installed with Measurement Studio? If not, what else do you feel is missing?
    - Elton

  • Using Measurement studio with Tabs

    Whenever I place a measurement studio control on top of a tab control it goes underneth the tab control and can no longer be seen.  In the code I can tell it to come to the top using 'BringWindowToTop" and it is visable but while in the editor it is not, making it hard to place controls properly.  Is there a way to force the control to the top in the editor and if so how?

    Hi Born2Burn,
    The way controls on a form are displayed is determined by their z-order. The control's z-order is determined by its position in the form's Controls collection, with the first control in the collection being at the front (top layer) and the last at the back.  You will need to change control's z-order in order to make things look right.
    There are a few options to fix this at design time:
    Right-click on the Measurement Studio Control and select Bring to Front. This will change it's position in the form's Controls collection to 0, making it the top of z-order. Similarly, you could right-click on the Tab control and choose Send to Back.
    Select the Measurement Studio Control and click Format » Order » Bring to Front from Visual Studio's menu. There are also two icons on the Layout toolbar that will allow you to either "Send to Front" or "Send to Back".
    Additionally, Visual Studio 2005 also includes a very useful tool window called Document Outline.  You can access this from View » Other Windows » Document Outline, or by using the keyboard shortcut: Ctrl+Alt+T.  The Document Outline will allow you to rearrange controls by simply draging and droping them into their correct z-order
    Thanks,
    Jonathan C
    Staff Application Engineering Specialist | CTD | CLA
    National Instruments

  • How to save the value in Cedit control into a text file bu using measurement studio c++?

    Im using measurement studio c++ to create a application. How to save a randomly generated value which display in the CNumberEdit Control to a text file? how to do the coding part?

    You can use the CNiFile class to write the value out to a file. For example, create a new Measurement Studio C++ project and follow these steps:
    Add a CNiNumEdit to the dialog.
    Add a member variable for the CNiNumEdit called m_numEdit.
    Add a button to the dialog.
    Double-click the button to add a message handler for the button's BN_CLICKED message.
    Add the following code to the button's BN_CLICKED message handler:
    CNiFile file("C:\\Values.log", CFile::modeCreate | CFile::modeWrite | CFile::typeText);
    file << m_numEdit.Value << endl;
    file.Close();
    Run the application, edit the CNiNumEdit's value, and click the button. The value should be written to the Values.log
    file as specified in the code above.
    Hope this helps.
    - Elton

  • Does Measurement Studio offer much for someone writing a basic control system?

    I'm trying to weigh whether the added cost (and bulk) of Measurement Studio would be worth it for me vs simply using the free DAQmx libraries.
    My application wouldn't have any need for the custom controls offered by MS nor the advanced libraries. All the application is doing is monitoring a handful of digital and analog inputs, reacting to them, and setting a handful of digital inputs. No high speed measurements, waveforms, etc. Probably the highest priority I/O may get updated every 50-100 ms.
    I'm mainly wondering if MS offers anything over the DAQmx libraries when it comes to working with I/O asynchronously (which seems like the proper way to approach a responsive machine control application).

    This an interesting question and I don't have a great answer.  I hope someone comes along and explains the issue clearly.  
    I like having all of Measurement Studio because I depend on Visa for the instrument libraries (scopes, meters, power supplies etc.).  I don't want to write an entire communication library from scratch.
    For just basic IO though I'm not sure what Measurement Studio actually brings to the table.  Since I've always had the entire package (Measurement Studio Enterprise Edition I believe) I don't know which features are available outside of Measurement Studio.  
    Did you mention that you are working with NI hardware?  If not, then maybe Measurement Studio buys you even less.  When working with NI hardware NI MAX (Measurement and Automation eXplorer) makes it so simple.  Just plug in a USB device and give it an alias in MAX like TS_Light and you can talk to it with :
    using (var t = new Task())
             Thread.Sleep(10);
            // Create full device name based on fixture platform passed into constructor
             const string strDevice = "TS_Light/port0";
            // Setup Task
            t.DOChannels.CreateChannel(
                     strDevice, 
                      ChannelLineGrouping.OneChannelForAllLines);
             // Create a write stream and send out the desired Value
            var writer = new DigitalSingleChannelWriter(t.Stream);
            // Convert port value to bool array
             var boolArray = new bool[8];
            for (int i = 0; i < 8; i++)
                      boolArray[i] = Convert.ToBoolean((portValue >> i) & 0x01);
            t.Start();
             writer.WriteSingleSampleMultiLine(false, boolArray);
    It looks a little complicated but it is the same flow for all NiDaqMx Tasks.  
    Again, I realize that I'm not answering your direct question of what does MS really bring to you when you are doing such a simple IO project.  I wonder however if you will ever be doing a similar project again soon?  And then maybe you will want to add some support for instrument automation and data collection? When you look at doing multiple projects, even simple ones, the cost of Measurement Studio starts to look like a better investment in my opinion.
    Good luck with your project!
    Grant M. Johnson
    Project Engineer
    LECO Corporation

  • How to use NiGraph control component in the MFC not measurement studio MFC??

    I want to use the NiGraph control component in the normal MFC(exe) program, but after you add the component to the project ,it will generate a CCWGraph class, and it doesnt work. If I want to use NiGraph class to plot data, What should I do? Help
    Thanks a lot!!!

    I have attached an image of the toolbar items. If there items are not visible on your toolbar, right-click the toolbar, and select the item labeled "MStudio" (if using VC++ 6.0) or "NI-Measurement Studio" (if using VS 2003). These items will only be available if you have Measurement Studio support for C++ installed.
    I hope this helps
    Bilal Durrani
    NI
    Attachments:
    icon.JPG ‏13 KB

  • Measurement Studio NumericEdi​t Control is Not Working

    I installed Measurement Studio 2013 with Visual Studio 2012 Professional yesterday and imported my previously developed projects on (VS 2010 Express). Web controls and C# coding working fine.
    I started Measurement studio chapter 2 first exercise to add control WaveformGraph, Gauge and Legend on my page and working but when add NemericEdit control then it gives me JavaScript critical error …….. SCRIPT1014 Invalid character. I am using window 7 and IE11 cleared cache already.
    Please help.
    Best regards
    Bashir.
    Attachments:
    NumericEdit_ScreenShots.docx ‏298 KB

    Hi Bashir,
    I was able to reproduce this issue in IE11. Please note, Measurement Studio 2013 supports IE6 - IE10, so we have not tested the Measurement Studio 2013 ASP.NET controls with IE11. However, what you are seeing appears to be a result of IE11 dropping support for conditional compilation for javascript (https://msdn.microsoft.com/en-us/library/ie/121hztk3(v=vs.94).aspx). Because of this, when the Visual Studio debugger is attached to your ASP.NET website, you see an unexpected character exception.
    Please note that the documentation for Web Browser Compatibility with Measurement Studio Web Forms Controls says that IE9 and 10 are only fully supported in compatibility mode. I took the liberty of testing IE11 in compatibility mode, and the Visual Studio debugger message stopped appearing. 
    Let me know if you have any questions.
    Daniel D.
    National Instruments
    Automated Test Software R&D

  • I have programmed a visual basic application using activex controls. WHen I run this application through internet, it appears a message box indicating that the measurement studio is a demo, but I have the correct license. What can I do?

    I run the application in a computer without measurement studio because my application is stored in a web server and I access to the application downloading it from a web page of that server.

    Have you included the lpk file with your control? I've attached the tool you'll need and here is a nice link that goes thru it step by step.
    Hope this helps
    Bilal Durrani
    Bilal Durrani
    NI
    Attachments:
    lpk.zip ‏74 KB

  • Does Measurment Studio Standerd edition contains graph and chart ActiveX controls for VB6

    A Very Simple quistion:
    Does Measurment Studio Standerd edition contains graph and chart ActiveX controls for VB6?

    Shady -
    Measurement Studio 7.0 Standard Edition provides support for Visual C++ 2003, Visual Basic .NET 2003, and Visual C# 2003. It just so happens that the Visual C++ support includes ActiveX controls, which are usable in VB6. The CWGraph ActiveX control provides both graphing and charting functionality.
    However, full Visual Basic 6 support, including examples and documentation is not in the Standard edition. It is in the Professional and Enterprise Editions.
    The best thing to do would be for us to get in direct contact with each other to make sure that we get you exactly the (minimum) package you need. If your profile includes your email address, we can contact you. Otherwise, you'll need to go through ni.com/support and refer to t
    his discussion thread to open a direct dialogue.

  • Create controls dynamically in schematic

    Hi folks,
    I'm a newbie to these forums!
    Here's my problem: I'd like to create a schematic by giving the user a box of items (say circuit elements) that the user can drag and drop into place. The user could then set a property of the element, such as a COM port, and then a polling machine (separate) would say retrieve a value and display it in an indicator associated with the element.
    I understand how to poll, say in modbus, and I understand event structures although I've only ever used them to detect a front panel click per the producer/consumer with events pattern. Any help in how to create a new control on the fly, as well as how to refer to it in order to update it regularly say, as well as how to drag and drop it, would be really appreciated!
    Thanks,
    Rik

    Yeah you don't want to do that.  The question as it is right now cannot be done on a VI that is running.  Using Scripting you can programatically make controls but only on VIs not running, and only from the development environment, not in a built EXE.  There are several other techniques that make it appear as if you are making new controls, none of which are very easy to implement and have other limitations.
    Even so, the application you want sounds complicated and I think you need to get a good list of requirements before you start.  It does not sound like a simple application and would take plent of time for debug and support.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Measurement Studio Visual C++ 6.0 Multithreads

    I want to use the dialog editor to add NI controls to a dialog (or CFormView) and want to set CNiInterface to SingleThreaded. How do I do this. I do not want to create the controls dynamically because I do not want to deal with license strings. I get an error if I close the dialog box when a control is added with the dialog editor. Is this because the controls by default are created as multithreaded with caching? I get by this by calling destroy window on the control. Is this the proper way? Will I have to do this if I use singlethreaded?
    Next the documentation says I need to initialize COM. Is this true. Is it not enough to call
    AfxEnableControlContainer() in OnInitInstance of my application.
    By the way
    National Instruments, Your documentation leaves quit a bit to be desired!! Good grief.

    The default thread access for the Measurement Studio C++ controls is CNiInterface::MultipleThreadsWithCaching. You do not have to dynamically create the control if you want to create the control with CNiInterface:ingleThread - just specify it in the dialog class constructor's member initialization list. For example, if you had a dialog class called CTestDialog and you had a member variable for the graph in the dialog class called m_graph:
    CTestDialog::CTestDialog(CWnd* pParent /*=NULL*/)
    : CDialog(CTestDialog::IDD, pParent), m_graph(CNiInterface:ingleThread)
    Also, you should not need to initialize COM to use the controls in a dialog. The call to AfxEnableControlContainer in your InitInstance method should be sufficient.
    - Elton

  • Conflict between ActiveX from LabVIEW and Measurement Studio?

    Hello
    We're small software company from Poland. We're developing our product
    (SCADA/HMI and integration system heavily based upon Measurement Studio
    graphic controls) in C++ for Win32 environment (MSVC 2003 Edition C++
    Compiler). Today we ran into serious problem: our client, one of the
    biggest Polish companies that sell automation software and hardware, is
    evaluating our product. Company staff members are using LabVIEW, too
    and have various version of LabVIEW installed on their PCs. It turned
    out that our program displays message that license is needed for
    Measurement Studio ActiveX controls, and crashes, when ran on PC with
    LabVIEW installed! (This one has LabVIEW 6.1, 7.0, 7.1 simultaneously
    installed).
    While I gues that crash is not Measurement Studio's fault (I guess that
    control fails to create and throws exception which is not catched by
    our code...we'll fix that) I'm pretty sure that this "license" stuff
    is. Of course we have legal version of Measurement Studio 7.1, and all
    controls used in our software have their respective licenses generated
    and compiled into application (we create all controls dynamically). We
    have never run into such problem before, and we're using Measurement
    Studio for years...please help.
    Some additional details: control that failed is CWBoolean in "3D Diode"
    configuration. Other controls, including CWBoolean in another
    configurations seem to work OK, at least I was told so (it's pity that
    I don't have faulty configuratio here...will try to reproduce it using
    some kind of LabVIEW evaluation version).
    Best regards from Poland, and thanks for any help.
    Michal
    Michal Adamczak
    Lead programmer, ANT ISS (http://www.ant-iss.com)

    Hi Michal,
    This is actually an error message that is usually fixed pretty simply by using our License Fixer.  Sometimes the licenses for the ActiveX controls can become broken in Measurement Studio.  This usually happens if you install drivers after installing Measurement Studio or a program created using Measurement Studio.  You can find the License Fixer here.  Try this out and let us know if you still have any trouble.
    Thanks,
    Caroline Tipton
    Data Management Product Manager
    National Instruments

Maybe you are looking for

  • Error in reciever file content conversion

    Hi I have the following error in the file content conversion Could not process due to error: java.lang.Exception: Exception in XML Parser (format problem?):'java.lang.Exception: Message processing failed in XML parser: 'Conversion configuration error

  • Converting pdf to excel

    I am using acrobat pro 9.0 with windows vista home premium and am trying to convert a twenty three page pdf file to excel xml. I am using excel 2010.  I have converted two pages separately at a test, then the entire file via "export".  The exported f

  • Quantity Falls Below Minimum Inventory Level

    Hi!, I have an item that we manage  by warehouse, we've set the minimum inventory level to 5000 pieces. So the MRP has procured me 5000 pieces through a purchase order. I received my item through Goods Receipt PO and now that I want to transfer it to

  • Logical foreign key

    Hi All, I apologize to bring similar question. . I am able to create the logical foreign key for logical table A with new joining condition (A.2=B.2) (2 is calculated logical column). However there still exist Physical foreign key join with old condi

  • How can i put below  table into internalt table

    how can i put below  table into internalt table and want to add both internal table into 3rd internal table. SELECT  * FROM J_1IEXCHDR  WHERE STATUS = 'P'. WRITE: / J_1IEXCHDR-LIFNR,           J_1IEXCHDR-DOCNO,           J_1IEXCHDR-EXYEAR,