Memo Edit OCX Control for Navision v0.9 (VB6)

AdministratorAdministrator Member, Moderator, Administrator Posts: 2,500
edited 2009-05-21 in Download section
Memo Edit OCX Control for Navision v0.9 (VB6)
This is sample to demonstrate how to host external memo control inside Navision environment. Works with all version >=3.xx.

Source code in VB6 is included.

Code is quite messy, sorry (version 0.9 :) ). Have no time to finish. Don't kick me too strong.

FOB and TXT for navision objects are included.

To do:
1. LoadFromFile/SaveToFile methods to save/load long text for/from control.
2. Use navsion's streams (have no idea how to do this!)

Known issues:
1. Sometimes losing focus. Host form must to be resized (I have no idea why but trying to do something).

If somebody wish to donate couple of GBPs please contact me.

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

Discuss this download here.

Comments

  • janpieterjanpieter Member Posts: 298
    Hey nice done.

    Seems to be another way of embedding other then using ATL commands.

    The focus issue i can explain. This is navisions standard behavior, it tries to pull back the focus to one of its own controls. The only way it would work in my experience is to put this on a navision form where no other controls are located that can receive focus.

    Also a sollution may be to subclass the parent form and stop events (lucky gues:) like WM_SETFOCUS or something simular. These commands i think are send to the parent form by Navision, if you filter them out then this behavior may not occur. Though i think it is quite dangerous.

    I have tried to communicate with navision streams by automation and no luck. I think it is impossible in an easy way. Ofcourse you can always try sending pointers and do memory reads. But wouldn't reccomend that; rather use files in between ...
    In a world without Borders or Fences, who needs Windows and Gates?
  • janpieterjanpieter Member Posts: 298
    hmm maybe this helps:

    MQBus Automation 'Navision MS-Message Queue Bus Adapter'.MSMQBusAdapter
    CC2 Automation 'Navision Communication Component version 2'.CommunicationComponent Yes
    InMsg Automation 'Navision Communication Component version 2'.InMessage
    InS InStream
    XMLDom Automation 'Microsoft XML, v3.0'.DOMDocument
    XMLNode Automation 'Microsoft XML, v3.0'.IXMLDOMNode
    OutMsg Automation 'Navision Communication Component version 2'.OutMessage
    OutS OutStream

    (foud on:)
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnav/html/TkNavision.asp
    In a world without Borders or Fences, who needs Windows and Gates?
  • Matt_KeyesMatt_Keyes Member Posts: 23
    Have you fixed the focus thing? Also, are you able to type in the memo box? i tried tweaking your code to allow both things (to no avail), so i recreated it in C++ to see if that would help. No dice... any help is appreciated.

    It appears no keyboard input commands are sent to the control.
  • Matt_KeyesMatt_Keyes Member Posts: 23
    Upon further research, i tried trapping every windows message (besides WM_PAINT, for obvious reasons) and displaying it in a message box. My control (when in a form all by itself) will show mouse activate, set focus, etc., but when the cursor is in the control (rich edit control), nothing happens. The cursor sits there flashing, but no keystroke messages are sent to it. Anyone have any thoughts?
  • janpieterjanpieter Member Posts: 298
    hmm if you try to trap events from the parent window (main form), do the key events go there?

    Then try forward them to the memo box :mrgreen:
    In a world without Borders or Fences, who needs Windows and Gates?
  • janpieterjanpieter Member Posts: 298
    Thats what i said. Navision is stealing the focus back. The answer should be in stopping navision from doing that.

    But then again, this might be dangerous.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Matt_KeyesMatt_Keyes Member Posts: 23
    i don't think it is strictly an issue with focus - i think Navision doesn't forward the keystrokes on to the control. i imagine they have OnCmdMsg (or the equivalent) overriden somewhere, and they don't forward keystroke commands on to an OCX. Interestingly enough, the Application Designer's Guide mentions that graphical user controls aren't supported.

    What i think i'm going to do is just use a dialog box for editing the text. i can still display it fine.

    However, if someone does figure out a way to get around this, please let me know :)
  • Matt_KeyesMatt_Keyes Member Posts: 23
    There are a few custom messages that come through for me (some of which will crash if you don't handle correctly - at least in C++), and a few standard Windows messages, but you're right - WM_SIZE never makes it. What i did was just compare the parent window sizes every time a message was processed and adjust size if the parent did.

    Funny thing is, if i resize the window, i can get the focus to the control and type away. However, i am never able to figure out when to tell it to kill focus.

    As a result, i just use this control to display data (not editable). i have a popup dialog whenever a user needs to edit the text inside the control.

    The bottom line is that Navision never knows about this control (since we are drawing the window manually), so it really can't be expected to act like a control (esp. when such things are not technically supported in Navision).
  • daborgdaborg Member Posts: 54
    Does anybody know how to get the SetTextStream function to work properly? I would like to use this OCx for displaying a large text list so I think I need to stream it into the OCX but I'm getting the following error when trying to do it:

    The call to member SetTextStream failed. Project1 returned the following message: Object variable or With block variable not set



    Any help would be appreciated
  • Khalid_AkkawiKhalid_Akkawi Member Posts: 0
    Heey Guys,

    I am new to NAV but I am spending most of my time testing here and there, Actually I've succeeded to get the focus on the Memo Control .. I am sure you did that before 2 or 3 years maybe..
    Anyway, Its a great work chaps =D>
    can you please help me guys ..
    I have OCX with some shapes and controls .. and I need to embedded it within Nav ! can I add it as a control on this project instead of the Memo and mimic functions that I need inside the project ? then create the Dll File and use it ? is it possible or not ? and if its possible what specific code should I use to prevent falling within errors ?!

    Thanx in advanced,
    Khalid
Sign In or Register to comment.