Author |
Topic  |
|
liujibao
China
Posts |
Posted - 12/18/2003 : 01:01:38 AM
|
I learn these from GettingStarted7.0, I am sure of my operation according to it, but the toolbar cann't work, who can tell me how to create a relation between the origin-c code and the toolbar.
I am just a newer and have many questions ,so I hope my questions won't bother you. Thanks! |
|
Iris_Bai
China
Posts |
Posted - 12/18/2003 : 02:41:36 AM
|
Hi liujibao,
The following are the process used for together Menu with OriginC code. 1. Create a new c file named "TestMenu" in code builder window (use File-> New...) and copy the following code into it.
void test(string str) { MessageBox(GetWindow(), str, "Test Menu with OriginC"); }
2. Save as the c file under OriginC\Originlab folder in Origin installation path (use File -> Save as...). 3. Close code builder window. Select View -> Script window to open Script window. Copy and paste the following LabTalk command into this window.
menu -w; //sets the worksheet window menu bar active menu ?Ed; //makes the Edit menu active menu (try) //New a submenu named "try" in Edit menu { err = run.LoadOC(originlab\TestMenu); // If click the new menu and then load TestMenu.c file from Originlab folder if(0==err) test "Hello"; //If LoadOC method return 0, and then Run "test" function definde in TestMenu.c file }
4. Select all commands in Script window and click Enter key on your keyboard to run all commands. --> You will find a new menu named "try" shows in Edit menu. Click it, one message box will show "Hello".
5. You can update Filename and Fucntion name in the command above by your owner Filename and function name and then to try the feature.
Iris
Edited by - Iris_Bai on 12/18/2003 03:01:29 AM |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 12/18/2003 : 08:54:48 AM
|
There is a good article on OriginLab's web page that describes how to call an OriginC function from a toolbar button...
Automation of Tasks Using Origin C
See the last section in particular: OGS Files and Toolbar Buttons
Mike Buess Origin WebRing Member |
 |
|
liujibao
China
Posts |
Posted - 12/18/2003 : 8:11:19 PM
|
Hi,Mike Buess Thanks for your help, but I cann't implement the sample "Creating a Custom Toolbar", will you give me a detailed sample? Thanks |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 12/19/2003 : 12:37:57 AM
|
Yes, the article neglects to mention that you have to provide your own bitmaps for the button images. The User Defined toolbar that comes with Origin has no actions attached to its buttons so you can start by defining their functions. If you need more button images you can download a small collection from labtalk.nmrtools.com.
You'll find more details about toolbars (and their bitmap files) in this article. OriginLab's "Creating New Toolbars" Multimedia Tutorial might also be useful.
Mike Buess Origin WebRing Member |
 |
|
liujibao
China
Posts |
Posted - 12/19/2003 : 08:02:11 AM
|
sorry,I cann't run my code through toolbar yet.Maybe the causation lies in the directory of the files. Thank you for your reply. I just don't want to give up, can you tell me more detailed operation to realize this function? |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 12/19/2003 : 08:38:29 AM
|
1> Open CodeBuilder. 2> File->New->LabTalk script file. 3> Give it a name (MyFile.ogs) and path (Origin program folder). 4> Add the following text...
[Test] type -b "Hello World";
5> Save and close CodeBuilder. 6> View->Toolbars->Button Groups. 7> Find the User Defined group. 8> Select the 'Test' toolbar button. 9> Click the Settings button and enter these settings...
File Name: (browse to find MyFile.ogs) Section: Test Context: Always
10> Click OK. 11> Drag the 'Test' button onto Origin's program window. 12> Close the Customize Toolbar dialog.
Clicking the new 'Test' button will bring up a box with the message "Hello World". You can change the button's action by altering the script under the [Test] section heading in MyFile.ogs. The OGS file and script section can have any names you want as long as they are correctly identified in the Toolbar button settings.
Hope that helps.
...Perhaps the problem is with your code. Does it work when ran from the script window? If not, it won't work from a toolbar button.
...Another thought just occurred to me since this is the Origin C forum. You are not trying to write and compile your OC function in the OGS file are you, because that will not work. You need to write the function in a C file and compile it there. Then you can use the function in an OGS file just like any LabTalk command.
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 12/19/2003 09:04:36 AM
Edited by - Mike Buess on 12/19/2003 3:32:58 PM |
 |
|
liujibao
China
Posts |
Posted - 12/21/2003 : 9:33:17 PM
|
Sorry,It cann't work yet!!! It can work well in any way, but ToolBar excepted! I try to run it in all ways, including re-setup, only a answer--fail. what is wrong with my origin software?
|
 |
|
liujibao
China
Posts |
Posted - 12/21/2003 : 9:35:23 PM
|
note: I just try it by your code above. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 12/21/2003 : 10:56:57 PM
|
The button should work as long as the OGS file and script section are identified correctly in the button settings and the section contains a valid script. User Defined toolbar settings are in the file OUbtn.ini and if you set up the Test button as I suggested yours should contain this section...
[CustomButton6] Id=47654 Image=5 FileName=test.ogs SectionName=Test ArgumentList= ContextWindow=2 TemplateName= Worksheet=1 Graph=1 Matrix=1 Excel=1 Layout=1 ToolTip= StatusBarMsg= Variable=
Your key order and Id value might be different, but as long as FileName and SectionName are correct you should be OK.
Have you tried running an OGS script section from the script window yet? This is essentially what the button does...
run.section(Test.ogs,Test);
Mike Buess Origin WebRing Member |
 |
|
liujibao
China
Posts |
Posted - 12/22/2003 : 02:10:52 AM
|
Yes,I have tried running an OGS script section from the script window , it work well,but The ToolBar not |
 |
|
liujibao
China
Posts |
Posted - 12/22/2003 : 02:36:48 AM
|
Now I show you the process: 1、 2、 3、 4、 5、 Have the process a problem? so,when I Hold down the CTRL+SHIFT keys and click the "MyFile" button, anything won't happen ,just like the operation that I click this button. but the others work well: 6、 |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 12/22/2003 : 08:44:40 AM
|
Your images need valid URLs to show up in a forum message.
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|