Simple OCX Control

Could someone please supply code for a simple OCX control. Basically I would like an OCX with a single Label on it, have Navision send a string value to change the Label Caption. Then have the OCX return a string value saying “Hello World” Thanks, John

The info you have provided is quite limited. 1.Do you want to write an OCX with Navision? 2.Or you want to write OCX control using VB/C/C++/Java/Delphi/Perl/VBScript etc. The first one I am afraid is not possible. You cant write an OCX control using C/SIDE. As a matter of fact you can use Navision only as an Automation Controller. For the second one use Google or - there are plenty of examples. Writing of an OCX control could be as simple as just placing a new form and a label, writing few lines of event’s handling code and thats it /if you use Visual Studio -VB,C,or whatever programming language of choice, Delphi or any other RAD IDE/. And can be fairly complicated if you are using just plain,good,old C++ and Microsoft Platform SDK for example.

Okay I want to create the OCX with Microsoft. C, VB is doesn’t matter at this point. I have created my simple OCX, registered it in Navision great!!! How do I put that OCX on the Navision Form??? Thanks, John

Simply put - You can’t! Navision is only an Automation controller, which means that it can communicate with OCX controls, or any other automation provider, but can’t host an OCX control (e.g. be a Container). brgds, N

Okay if I had an OCX called ‘myOCX’ created in VB with a public function called myFunction. So here is the code for my OCX Public Sub myFunction() msgbox “Hello World” End Sub How can I make navision call “myFunction” from myOCX? Thanks, John

It’s annoying when people don’t answer your problem [}:)] ----------------------------------------------------------------- VB CODE AS FOLLOW - HAVEN’T TESTED! ***************************** ----------------------------------------------------------------- Public Function SetLabel(theCaption As String) Label1.Caption = theCaption End Function Public Function GetLabel() As String GetLabel = Label1.Caption End Function Public Function SetAndGetLabel(theCaption As String) As String Label1.Caption = theCaption SetAndGetLabel = Label1.Caption End Function ------------------------------------------------------------------- Then make your OCX in VB. Register it in Navision. Mae a variable of type OCX in Navision and select your control. Imagine your OCX is called MyTestOCX all you need to do is… MyTestOCX.SetLabel(Rec1.Caption); Rec1.Caption := MyTestOCX.GetLabel; Hope this at least helps you out a bit… I won’t ask why you need to do this… guess it’s just for an example of using OCX? Cheers Ade

As far as I know, you can’t use an OCX that has graphics in it in Navision. You can’t use controls similar to DataGrid, ListBox, TextBox, Label, etc… Your control should not have user interface elements. An example of a control that you can use is the Timer control. Also, I don’t think that Navision has a mechanism that supports OCX events. You OCX events will simply not fire.

If your OCX contains a form then it certainly can use DataGrid, Label, TextBox etc… It is true that Navision can not be a container… But you can create a normal form in a VB6 OCX and it will be visible when called from Navision… You can choose to make the OCX to either show the form or not… [}:)]

In which case you might just the same make an automation control which can also provide the abillity to fire events in Navision if needed.

Very Cool!! That is exactly what I wanted thank you very much! John