Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - WPF COM Interop - How to manipulate the control

 
 
Old 03-20-2007   #1 (permalink)
Stefan Nuxoll


 
 

WPF COM Interop - How to manipulate the control

OK, so I finally figured out how to add a ActiveX control to a WPF form
through C# code, as the XAML method does not work for some odd reason (could
it be that I'm using VS Express?). Anyways, I can put the control as a
child of my DockPanel, but I cannot manipulate the control outside of the
function that I created it with. I'm sure that this is a newb mistake, but
I'm used to being able to manipulate a control globally. Thanks in advance.


My System SpecsSystem Spec
Old 03-20-2007   #2 (permalink)
Bryan Phillips


 
 

Re: WPF COM Interop - How to manipulate the control

If you created the control as design time, it is probably exposed as a
protected member instead of an internal(friend in vb).

If you created the control as run time, you will have to keep a
reference to the control globally like through a static field.

--
Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com



"Stefan Nuxoll" <netkid91@gmail.com> wrote in message
news:C22A1B72-EADA-43CB-8E17-55E6D8B80A50@microsoft.com:

> OK, so I finally figured out how to add a ActiveX control to a WPF form
> through C# code, as the XAML method does not work for some odd reason (could
> it be that I'm using VS Express?). Anyways, I can put the control as a
> child of my DockPanel, but I cannot manipulate the control outside of the
> function that I created it with. I'm sure that this is a newb mistake, but
> I'm used to being able to manipulate a control globally. Thanks in advance.


My System SpecsSystem Spec
Old 03-23-2007   #3 (permalink)
WPCoder


 
 

Re: WPF COM Interop - How to manipulate the control

To be clear: not through a static field -- add a member variable to the
code-behind class instead of declaring it local in the function:

(I've made up a class that represents your ActiveX control, called
ActiveXControlClass here).

public partial class Window1
{
private ActiveXControlClass axMyControl;

private void CreateAxControl()
{
axMyControl = new ActiveXControlClass();
// add control to parent, etc...
}

private void SomeOtherFunction()
{
axMyControl.SomeProperty = "123";
}


Normally VS (and Expresion) hide all of the declarations of the elements on
your UI in a file called something like window1.g.cs (in the obj/Debug
folder). This file contains the actual fields/members that represent the
elements on your user interface (and since it is generated as a part of the
compile process, that's why you need to compile the project after adding UI
elements to any current visual designer, so that the Intellisense engine can
work its magic).

Hope that helps.

--Aaron

http://www.wiredprairie.us




"Bryan Phillips" <bphillips@nospam.spamcop.net.spammenot> wrote in message
news:ujxEPU2aHHA.2316@TK2MSFTNGP04.phx.gbl...
> If you created the control as design time, it is probably exposed as a
> protected member instead of an internal(friend in vb).
>
> If you created the control as run time, you will have to keep a reference
> to the control globally like through a static field.
>
> --
> Bryan Phillips
> MCSD, MCDBA, MCSE
> Blog: http://bphillips76.spaces.live.com
>
>
>
> "Stefan Nuxoll" <netkid91@gmail.com> wrote in message
> news:C22A1B72-EADA-43CB-8E17-55E6D8B80A50@microsoft.com:
>
>> OK, so I finally figured out how to add a ActiveX control to a WPF form
>> through C# code, as the XAML method does not work for some odd reason
>> (could
>> it be that I'm using VS Express?). Anyways, I can put the control as a
>> child of my DockPanel, but I cannot manipulate the control outside of
>> the
>> function that I created it with. I'm sure that this is a newb mistake,
>> but
>> I'm used to being able to manipulate a control globally. Thanks in
>> advance.

>


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
manipulate string output PowerShell
Microsoft.VirtualServer.Interop.dll and the Microsoft.VMRCClientControl.Interop.dll Virtual Server
Using an interop assembly with interop dependencies PowerShell
Using Powershell to manipulate COM+? PowerShell
manipulate csv file and cut equivalent PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46