thank you very much Carsten!
I will try it.
but, I guess i was missing something by far.
I notice that there is a InitVCL call, in the file you mentioned. but it
seems that it need something like a static or dynamic lib to get it work.
where can I get such a lib, should I compile the vcl project on my computer
or I can just download it somewhere.
thank you, and hope your reply.

best wishes, Rainman.

On Thu, Jun 19, 2008 at 11:14 PM, Carsten Driesner <[EMAIL PROTECTED]>
wrote:

> Rainman Lee wrote:
>
>> hello everyone,
>> I'm trying to use uno controls independently without OO runing.
>> but when I try to create the com.sun.star.awt.Toolkit service in my
>> program,
>> it crashes.
>> I have tried to create other services (e.g. UnoButtonModel), and it seeems
>> ok.
>> I use OOo 2.4 on windows platform with Visual C++ for this testing, and
>> here
>> is how I do:
>>
>> first, I implement a uno component with XMain interface.
>> in its run method, I just try to get the service manager through the
>> component context that I have restored during the component instantiation.
>>
>> virtual ::sal_Int32 SAL_CALL run(const Sequence< ::rtl::OUString >&
>> aArguments) SAL_THROW((RuntimeException))
>> {
>>        if (m_xContext.is())
>>            MessageBox(NULL, TEXT("1 OK!"), TEXT("Msg"), MB_OK);
>>
>>        Reference<lang::XMultiComponentFactory> xMultiFactory =
>> m_xContext.get()->getServiceManager();
>>        if (xMultiFactory.is())
>>            MessageBox(NULL, TEXT("2 OK!"), TEXT("Msg"), MB_OK);
>>
>>        Reference<XInterface> xInterface =
>>
>> xMultiFactory.get()->createInstanceWithContext(L"com.sun.star.awt.Toolkit",
>> m_xContext);
>>        if (xInterface.is())
>>            MessageBox(NULL, TEXT("3 OK!"), TEXT("Msg"), MB_OK);
>>        return 0;
>> }
>>
>> then I register all uno dll components in [OFFICE_PROGRAM_PATH] with my
>> component into a new rdb file.(myservices.rdb)
>> finally I run uno -s MY_SERVICENAME -ro myservices.rdb to startup my uno
>> component.
>>
>> when the component is runing, it shows the first two message boxes as
>> expected, and crashes without showing the last one.
>> but if I replace "com.sun.star.awt.Toolkit" with
>> "com.sun.star.awt.UnoButtonModel" or
>> "com.sun.star.awt.ContainerWindowProvider" instead, it runs correctly with
>> all message boxes displayed.
>> so why cant I create the Toolkit service in my component? does this
>> serivce
>> depend on other services or things which I haven't prepared ready?
>> hope for your reply, and thanks very much!
>>
> Hi Rainman,
>
> You have to make sure that VCL is properly initialized before you can use
> UNO awt! UNO awt is a wrapper around VCL and cannot work correctly if VCL
> has not been initialized. To initialize VCL you have to call InitVCL(...).
> You can find how to call InitVCL in the desktop project, e.g. look within
> desktop/source/pkgchk/unopkg/unopkg_misc.cxx at the function getUNO(...).
> There is also a function called DeInitVCL().
>
> Regards,
> Carsten
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to