Board index » cppbuilder » How to make an OCX visible

How to make an OCX visible


2004-09-23 06:23:30 PM
cppbuilder24
Using C++ Builder 6 on XP pro.
How do you make an OCX visible?
I want the form to appear so that I can use the buttons etc on it.
The OCX was created as an ActiveForm.
I'm calling it manually rather than as a VCL drop in object.
I have CoCreateInstance running, got the Interface and can set and get properties e.g. a custom 'SimLevel' property that shows its the right object.
I tried setting the set_Visible property to 1 but that didn't work. Is there another value it should be set to?
So anybody know how to make the thing appear?
The folowing is the code to get the interface:
//**********************************
// CLSID and GUID are all setup
if(SUCCEEDED(CoInitialize(0)))
{
if(SUCCEEDED(hr)) // Got the CLSID ok
{
// Create the instance
hr = CoCreateInstance(CLSID_COMtest, NULL,
CLSCTX_INPROC_SERVER,
IID_IUnknown, (void**)&pInstance);
if(SUCCEEDED(hr))
{
// get the interface
hr = pInstance->QueryInterface(IID_ICOMtest, (void**)
&pCOMtestInterface) ;
(hr == S_OK)
{
// test message with custom property
MessageDlg("SimLevel = " +
AnsiString(pCOMtestInterface->get_SimLevel()),
mtInformation, TMsgDlgButtons() << mbOK, 0);
pCOMtestInterface->set_Visible(1); // Does nothing... }
}
}
//**************************
Thanks in advance
Ian.
 
 

Re:How to make an OCX visible

Try passing VARIANT_TRUE (i.e. -1) to set_Visible.
Mark
"ian" < XXXX@XXXXX.COM >wrote in message
Quote

Using C++ Builder 6 on XP pro.

How do you make an OCX visible?
I want the form to appear so that I can use the buttons etc on it.

The OCX was created as an ActiveForm.
I'm calling it manually rather than as a VCL drop in object.

I have CoCreateInstance running, got the Interface and can set and get
properties e.g. a custom 'SimLevel' property that shows its the right
object.

I tried setting the set_Visible property to 1 but that didn't work. Is
there another value it should be set to?

So anybody know how to make the thing appear?

The folowing is the code to get the interface:

//**********************************
// CLSID and GUID are all setup

if(SUCCEEDED(CoInitialize(0)))
{
if(SUCCEEDED(hr)) // Got the CLSID ok
{
// Create the instance
hr = CoCreateInstance(CLSID_COMtest, NULL,
CLSCTX_INPROC_SERVER,
IID_IUnknown, (void**)&pInstance);
if(SUCCEEDED(hr))
{
// get the interface
hr = pInstance->QueryInterface(IID_ICOMtest, (void**)
&pCOMtestInterface) ;
(hr == S_OK)
{
// test message with custom property
MessageDlg("SimLevel = " +
AnsiString(pCOMtestInterface->get_SimLevel()),
mtInformation, TMsgDlgButtons() << mbOK, 0);

pCOMtestInterface->set_Visible(1); // Does nothing... }
}
}
//**************************

Thanks in advance
Ian.

 

Re:How to make an OCX visible

Thanks.
I tried that but no effect either.
Cheers
Ian.
"Mark Guerrieri" < XXXX@XXXXX.COM >wrote:
Quote
Try passing VARIANT_TRUE (i.e. -1) to set_Visible.

Mark

"ian" < XXXX@XXXXX.COM >wrote in message
news:4152a422$ XXXX@XXXXX.COM ...
>
>Using C++ Builder 6 on XP pro.
>
>How do you make an OCX visible?
>I want the form to appear so that I can use the buttons etc on it.
>
>The OCX was created as an ActiveForm.
>I'm calling it manually rather than as a VCL drop in object.
>
>I have CoCreateInstance running, got the Interface and can set and get
>properties e.g. a custom 'SimLevel' property that shows its the right
>object.
>
>I tried setting the set_Visible property to 1 but that didn't work. Is
>there another value it should be set to?
>
>So anybody know how to make the thing appear?
>
>The folowing is the code to get the interface:
>
>//**********************************
>// CLSID and GUID are all setup
>
>if(SUCCEEDED(CoInitialize(0)))
>{
>if(SUCCEEDED(hr)) // Got the CLSID ok
>{
>// Create the instance
>hr = CoCreateInstance(CLSID_COMtest, NULL,
>CLSCTX_INPROC_SERVER,
>IID_IUnknown, (void**)&pInstance);
>if(SUCCEEDED(hr))
>{
>// get the interface
>hr = pInstance->QueryInterface(IID_ICOMtest, (void**)
>&pCOMtestInterface) ;
>(hr == S_OK)
>{
>// test message with custom property
>MessageDlg("SimLevel = " +
>AnsiString(pCOMtestInterface->get_SimLevel()),
>mtInformation, TMsgDlgButtons() << mbOK, 0);
>
>pCOMtestInterface->set_Visible(1); // Does nothing... }
>}
>}
>//**************************
>
>Thanks in advance
>Ian.
>


 

{smallsort}