storage problem about an inserted mp3 player activex control

General TRichView support forum. Please post your questions here
Post Reply
ironside
Posts: 4
Joined: Fri Aug 11, 2006 9:41 am

storage problem about an inserted mp3 player activex control

Post by ironside »

Dear Sergey,
I have create an activex control component using visual c++ which can play mp3 files, it's form like media player. I have inserted this activex ocx in trichviewedit sucessfully, after setting a mp3 file's path to this ocx, it will begin to play and so on.
But there is a problem about save and load. That is, i want to save all content in the trichviewedit as rvf format, including each mp3 file's data corresponding to each inserted activex control. The same requirement to loading, that is, after loading the rvf file, the inserted control can still get the audio data part from the rvf file. Now i can not realize this.
I have studied your demo WavButton, and i think maybe i can solve the problem by either the following approaches:
Approach1: rewrite the activex control with c++ builder, implement some additional properties and approach that listed in WavButton.pas, such as FStream LoadFromFile SaveToFile(here not existed, but i think need) WriteMusic ReadMusic DefineProperties and so on. If this apporach feasible? If ther any attentions i must pay?
Approach2: keep the activex ocx writing with visual c++, add some additional codes in c++ builder. I prefer to this approach, but do not know how to implement!
Thank you very much!
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I think you can add new properties ether in OCX control or in VCL wrapper for this control, it does not matter.
In that forum, you can find an example of Flash ActiveX modification.
The ActiveX itself is not modified (of course), but new property (allowing to store movie) is added in VCL wrapper.
You can find links both to Delphi and C++Builder wrappers, you can take the C++'s one as a sample. Unfortunately, it does not work properly with Flash (for unknown reason), but I hope this techinque will work for your OCX.
ironside
Posts: 4
Joined: Fri Aug 11, 2006 9:41 am

get some progress, still exist some problems

Post by ironside »

Sergey Tkachenko wrote:I think you can add new properties ether in OCX control or in VCL wrapper for this control, it does not matter.
In that forum, you can find an example of Flash ActiveX modification.
The ActiveX itself is not modified (of course), but new property (allowing to store movie) is added in VCL wrapper.
You can find links both to Delphi and C++Builder wrappers, you can take the C++'s one as a sample. Unfortunately, it does not work properly with Flash (for unknown reason), but I hope this techinque will work for your OCX.
Dear Sergey,
Thanks for your reply!
My activex control's name is AudioControl which wirtten in visual c++. I have written a VCL wrapper AudioControlVCL for the activex control through modifying your files MyShockwaveFlashCPP.cpp and MyShockwaveFlashCPP.h. There is no problem on saving mp3 files in rvf format.
But when loading the saved rvf file, i find the control's some resource can not be initialized automatically! Problems and phenomenon are following:
1. my activex's part code as this
CAudioControlCtrl::CAudioControlCtrl()
{
InitializeIIDs(&IID_DAudioControl, IID_DAudioControlEvents);

}
BOOL CAudioControlCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
cs.dwExStyle |= WS_EX_CONTROLPARENT;
return COleControl::PreCreateWindow(cs);
}
int CAudioControlCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;
}

my VCL wrapper's code almost same to the MyShockwaveFlashCPP.cpp and MyShockwaveFlashCPP.h, for example its construction is
__fastcall TAudioControlVCL::TAudioControlVCL(TComponent* AOwner)
: TAudioControl(AOwner)
{
FStream = new TMemoryStream;
}

2. when inserting a AudioControlVCL to richviewedit, after executing
TAudioControlVCL* audioControl = new TAudioControlVCL((TComponent*)NULL);
then the activex's three methods listed above will be called orderly and automatically, and the activex's some resource's such as m_hWnd can be intiallized in the latter two method.
But, when loading the conmponet's mp3 data from rvf file, only the control's first method CAudioControlCtrl::CAudioControlCtrl() will be called, and the latter two will never! So my control's some resource's can not be initiallized.

Please tell me how to resolve the above rvf load problem. Thank you very much!
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

I am afraid I do not know the answer :(

I can explain how controls are read from RVF:
1) Control class name is read
2) Control class is obtained (ControlClass := GetClass(ClassName))
3) Control is created (Control := ControlClass.Create(nil))
4) Control.Visible := False; Control.Parent := RichView;
5) Control is loaded using Stream.ReadComponent()
6) Control.Visible := True is assigned on formatting
ironside
Posts: 4
Joined: Fri Aug 11, 2006 9:41 am

Post by ironside »

Dear Sergey,
Thanks for your reply, i think your explaination above will be great helpful to my work.
Post Reply