Options

Question - Command Button to run ocx components.

jemmyjemmy Member Posts: 247
Easy question, I defined a command button to run ocx components.
for example: Windows Media Player
I have defined WindowsMediaPlayer as variables with datatype = OCX and subtype refers to Windows Media Player.
Then I put OnPush trigger with following codes:
WindowsMediaPlayer.Autostart := TRUE;
WindowsMediaPlayer.ShowDisplay := TRUE;
WindowsMediaPlayer.AnimationAtStart := TRUE;
WindowsMediaPlayer.Open ('C:\file.wmv');

But after I press the button, nothing happened. :x

I'm affraid I don't know which properties should be initialized for command button to make it works.
Anyone could figure/advise this out? :roll:

Thanks in advance.

Jemmy

ps. please don't suggest to put the code in the unit code, since it will works. :wink:

Comments

  • Options
    janpieterjanpieter Member Posts: 298
    Probably your code is executed but doesn't give the result you think it should.

    Can you see windows media player in the process list (ctrl+alt+del)?

    If so, there might be an additional property that still hides media player.

    Try something like:
    WindowsMediaPlayer.Visible := TRUE;

    Dont know if that excists but for most applications like word and excel this property has to be set first before the application becomes visible.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    jemmyjemmy Member Posts: 247
    Hi JanPieter,

    I can't find WindowsMediaPlayer application running in the Windows Task Manager. :x
    I also have tried to put WindowsMediaPlayer.Visible := True, but unfortunately it will generate error after I recompile the form.
    It will display:

    You have specified an unknown variable
    Visible


    So I think visible is not a property of WindowsMediaPlayer ocx.

    Am I wrong in defining PushAction property of the button? :?:

    Please help, Thanks again. :roll:

    HTH,

    Jemmy
  • Options
    janpieterjanpieter Member Posts: 298
    as far as i know you can just drag a button on a form from the toolbox and standard the C/AL code underneath it gets executed.

    There may be cases that the push trigger doesn't get fired when some properties of the button are set but don't exactly know which. The behavior you describe may be result of you using an existing button instead of making a new one. Is that right?

    If so, create a new one from the toolbox. This will get you the default properties which should work fine.
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    Mark_SMark_S Member Posts: 17
    I tested it with Navision 4.0 NL tho, but oke here's what i did:

    - Create New Form (empty)
    - Toolbox: Add Button
    - C/AL Code -> in de OnPush put: WMP.openPlayer('c:\bla.wmv');
    - Register a Global Var:
    Name: WMP
    Type: OCX
    SubType: Windows Media Player
    - CTRL-R
    - Press the button

    works fine here ..

    (after you added the global var you can see what properties and methods the WMP Variable has when you press F5 and select WMP in the outer left list)

    gl
    M Stunnenberg
    GAC Business Solutions B.V.
  • Options
    jemmyjemmy Member Posts: 247
    Folks,

    thanks for all your sharings.. :D

    here's my further test:

    It plays but does not show! :roll:
    when I assigned
    WindowsMediaPlayer.Open ('song.mp3');

    I heard the sound of 'song.mp3'! But The window of Windows Media Player didn't show.

    I have tried to set all similiar properties like
    ShowControl, Showtracker, Showgotobar, ShowStatusBar, etc to TRUE.
    But it still can't show anything.

    So nothing wrong with the command button.

    Is this the limitation of ocx in Navision 3.7? :?

    HTH,
  • Options
    janpieterjanpieter Member Posts: 298
    Think you are using the wrong library. I dont have all these properties you describe.

    When i do :

    WMP.openPlayer('c:\temp\taz.wav');

    This works fine.

    WMP = OCX var of type : "Windows Media Player"

    I have Win XP an WMP 9.0
    In a world without Borders or Fences, who needs Windows and Gates?
  • Options
    jemmyjemmy Member Posts: 247
    Hi JanPieter,

    Gozh, you are right! I think I used the different .dll.
    I used Windows Media Player 8, and Windows 2000 Server.

    After I install Windows Media Player 9 series, I got the method like
    OpenPlayer, newMedia, close, launchURL, newPlayList

    And it works well now. :D

    The window of media player is shown!


    So the conclusion is Windows Media Player 8 doesn't work for Navision 8)

    Case closed. :D

    Thanks.

    Jemmy
  • Options
    Mark_SMark_S Member Posts: 17
    Hmmz, strange that WMP 8 doesn't work.

    anyway, yw :wink:
    M Stunnenberg
    GAC Business Solutions B.V.
  • Options
    s_vahagns_vahagn Member Posts: 19
    I think it is suspended version of Media Player.
    DDE functions in Navision
Sign In or Register to comment.