Draw External Control

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2006-12-06 in Download section
Draw External Control
This download shows how you can draw an external control directly in a Navision form.

Don't forget to compile the project first to create and register the DLL. Then use the form 88000 to see the result. This is a raw and simple project. There's a lot of improvement a skilled c++ developer can accomplish.

Contains:

1- Project .Net C++ (open the project and compile to create and register the dll!!!)
2- Navision form with a reference to the dll

Sorry for the lack of documentation but didn't had the time to do it.
Hope someone can create some nice things and share with the mibuso community.

A great year to everyone.

http://www.mibuso.com/dlinfo.asp?FileID=548

Discuss this download here.

Comments

  • henrikohmhenrikohm Member Posts: 30
    e:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxv_w32.h(18): fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>

    What is the problem?
    Best regards
    Henrik Ohm
  • andreofandreof Member Posts: 133
    That error, and a lot more :wink: , apeared to me also and i had to deal with them. I dont have the answer right away, but when i have some time, maybe in the weekend, i will try to create a project from scratch and document all my steps and all error solutions. It was a hard fight for me the first time i did it.
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • guidorobbenguidorobben Member Posts: 157
    Haven't tried it yet, but cool that you post the code on the internet.

    Guido
  • andreofandreof Member Posts: 133
    it should work with all versions
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • andreofandreof Member Posts: 133
    Have not tryed it yet so i dont know
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • Bump.

    So, anyone got this built? Anyone knows what exactly is happening in the code, could it be done in other than .net?
  • andreofandreof Member Posts: 133
    I've tried in other languages but got no results.

    You have to understand and know c++ to compile or change this project, there are no miracles.
    Andre Fidalgo
    My world: Dynamics NAV,SQL and .NET

    CEO at Solving Dynamics
    http://www.solvingdynamics.com
  • I couldn't build the above example, but I managed to make it from scratch (with lots of googling and learning a bit C++ :). I started a new atl project (vs2005), added a simple object class and implemented a slightly modified version of your your code. It works quite nice and it can host all sorts of controls (even browser).

    Now, I would like to implement the code to respond to resize events. Normaly the external control wouldn't resize. I can call the function to update the window size from Navi, but that's not really it. Any ideas or suggestions in which direction to look?

    Thanks.
  • Care to explain that a bit more? By default control you mean my atl object or the hosted control? I can't find any WndProc methods in those. Then again, this is my first time c experience, so I apologize if i ask stupid questions.
  • I added an event to WM_SIZE. However, it doesn't seem to respond to resizing, so nothing really happens. Anyway, it's enough for today. Have a nice weekend.
  • bruno77bruno77 Member Posts: 62
    Very cool =D> , really appreciate you posting the source code for this!

    This solved my compile error btw.

    http://forums.microsoft.com/MSDN/ShowPo ... 1&SiteID=1

    Thanks a lot for sharing
    :D
  • janpieterjanpieter Member Posts: 298
    nono dont try catch resize events.

    You have to use the handle of the navision (sub)form to act as a container. The MSDN examples i remember creates its own window as a container. This is not necesary just use the hwnd or cwnd of the (sub)form.

    When the container is right, then it will size automatically according to the container.
    In a world without Borders or Fences, who needs Windows and Gates?
  • janpieterjanpieter Member Posts: 298
    Hmm if you dont believe me ... =;

    I never had to do that though i created this product :
    http://www.mibuso.com/dlinfo.asp?FileID=333
    In a world without Borders or Fences, who needs Windows and Gates?
  • wakestarwakestar Member Posts: 207
    Anybody got a working sample in c#?

    I'm going nuts with this! I'm able to find out the handle of the navision form / subform.. but I cannot set the MdiParent property of my custom form in VS 2005 ](*,)
  • janpieterjanpieter Member Posts: 298
    This topic is not about MDI forms but about OCX controls.
    In a world without Borders or Fences, who needs Windows and Gates?
  • wakestarwakestar Member Posts: 207
    I have a visual external control in c#.

    All I want is to embedd it in a subform of Navision.
  • janpieterjanpieter Member Posts: 298
    wakestar wrote:
    I have a visual external control in c#.

    All I want is to embedd it in a subform of Navision.

    MDI properties are not available for OCX controls as you are not working on Multiple Document Interface there.

    Listen, the thing we are doing here isn't something you can do with properties. It is verry unusual to host OCX controls in applications that you did not design (like Navision).

    I don't really think C# is cappable of doing the hosting bit. You will have to reside to some C++ magic with its ATL libraries. See the posted example.

    I'm not really into embedding C# controls, you might have to compile the OCX in a way that it supports COM. But i'm not sure about that.
    In a world without Borders or Fences, who needs Windows and Gates?
  • wakestarwakestar Member Posts: 207
    ok, thanks janpieter

    at the end I don't care about the way it is solved. When it works I'm happy :lol:
  • SaroSaro Member Posts: 58
    there is one problem though, if i draw an editable ocx using this dll, it's not letting me input text or change any other value on the ocx, it displays it correctly though, anyone can help me on that?
    Saro
  • janpieterjanpieter Member Posts: 298
    Saro wrote:
    there is one problem though, if i draw an editable ocx using this dll, it's not letting me input text or change any other value on the ocx, it displays it correctly though, anyone can help me on that?

    This also is my biggest problem. Navision is always taking back the focus. Somehow this is done with postmessage API calls i think. If you can catch those events then you can probably prevent these messages from getting back to standard navision fields.

    Though it is a bit dangerous to make these kind of changes to navision behavoir. You would not want to prevent those messages from being send when you click on a navision field otherwise Navision will never receive the focus again! And i think you will encounter many more other problems. That's why I stopped trying to deal with it quite soon.

    If you manage to implement this it would be a great achievement.

    (oh probably text input is possible if you don't use text fields on the form the control is drawn on).

    So far i only managed to have controls drawn that only supports visual and mouse user interaction. No keyboard. But even this has a lot of cool possibilities.
    In a world without Borders or Fences, who needs Windows and Gates?
  • SaroSaro Member Posts: 58
    janpieter
    thank you for the response that was very helpful, i suppose we can wait till 5.0 is out, maybe with the .net backend we will be able to use such things, probably even internally
    Saro
  • janpieterjanpieter Member Posts: 298
    Saro wrote:
    janpieter
    thank you for the response that was very helpful, i suppose we can wait till 5.0 is out, maybe with the .net backend we will be able to use such things, probably even internally

    glad to help.

    umg sure hope so but i have doubts ...
    In a world without Borders or Fences, who needs Windows and Gates?
Sign In or Register to comment.