Click here to Skip to main content
15,909,741 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 3:31
billb211224-Aug-04 3:31 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd24-Aug-04 4:16
neoksd24-Aug-04 4:16 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
billb211224-Aug-04 5:45
billb211224-Aug-04 5:45 
AnswerRe: How can I pass byte array from C++ to c# ? Pin
Heath Stewart24-Aug-04 8:03
protectorHeath Stewart24-Aug-04 8:03 
GeneralRe: How can I pass byte array from C++ to c# ? Pin
neoksd26-Aug-04 15:23
neoksd26-Aug-04 15:23 
GeneralRe: Declaration Default Argument Values Pin
S Sansanwal23-Aug-04 23:54
S Sansanwal23-Aug-04 23:54 
GeneralRe: Declaration Default Argument Values Pin
Heath Stewart24-Aug-04 8:09
protectorHeath Stewart24-Aug-04 8:09 
GeneralHosting Managed Controls in MFC Pin
Amir Harel23-Aug-04 23:13
Amir Harel23-Aug-04 23:13 
I created a simple user control in C# which has a button in it.
//DemoControl.cs

namespace DemoControl
{
public class UserControl1 : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public UserControl1()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();

// TODO: Add any initialization after the InitComponent call

}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}

#region Component Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 16);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(88, 32);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// UserControl1
//
this.Controls.Add(this.button1);
this.Name = "UserControl1";
this.Size = new System.Drawing.Size(608, 248);
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.UserControl1_MouseMove);
this.ResumeLayout(false);

}
#endregion


}
}

The i created an MFC ActiveX control to host the C# control

//HostCtrol.cpp
int CMfcHostCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (COleControl::OnCreate(lpCreateStruct) == -1)
return -1;

AfxEnableControlContainer();
DemoControl::UserControl1* pcal = new DemoControl::UserControl1();


CComPtr<iunknown> spunkControl;
spunkControl.Attach((IUnknown*)System::Runtime::InteropServices::Marshal::GetIUnknownForObject(pcal).ToPointer());

CRect rectPlaceHolder;
GetClientRect( &rectPlaceHolder );
m_ctrl.Create(spunkControl, WS_VISIBLE | WS_TABSTOP, rectPlaceHolder, this, 0);

return 0;
}

where m_ctrl is CWinFormsControlWnd class which i downloaded from the MSDN Magazine at http://msdn.microsoft.com/msdnmag/issues/03/03/WindowsForms/default.aspx

It works great, but the hosting application stuck when i press the button.

Does anyone knwos whats wrong?

Amir.

Amir Harel
Generaldatabound list with customisable filter Pin
..Hubert..23-Aug-04 23:03
..Hubert..23-Aug-04 23:03 
GeneralIP-Tunnel Pin
erina54823-Aug-04 22:55
erina54823-Aug-04 22:55 
GeneralRe: IP-Tunnel Pin
Dave Kreskowiak24-Aug-04 6:56
mveDave Kreskowiak24-Aug-04 6:56 
GeneralISOBARS Pin
beolijza23-Aug-04 22:39
beolijza23-Aug-04 22:39 
QuestionHow do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 20:21
Salil Khedkar23-Aug-04 20:21 
AnswerRe: How do I call a base class function from a derived class function? Pin
Colin Angus Mackay23-Aug-04 20:44
Colin Angus Mackay23-Aug-04 20:44 
GeneralRe: How do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 21:19
Salil Khedkar23-Aug-04 21:19 
GeneralRe: How do I call a base class function from a derived class function? Pin
leppie23-Aug-04 21:31
leppie23-Aug-04 21:31 
GeneralRe: How do I call a base class function from a derived class function? Pin
Colin Angus Mackay24-Aug-04 0:29
Colin Angus Mackay24-Aug-04 0:29 
AnswerRe: How do I call a base class function from a derived class function? Pin
Salil Khedkar23-Aug-04 22:11
Salil Khedkar23-Aug-04 22:11 
GeneralNew to C# Pin
Vicks23-Aug-04 20:00
Vicks23-Aug-04 20:00 
GeneralRe: New to C# Pin
Colin Angus Mackay23-Aug-04 20:29
Colin Angus Mackay23-Aug-04 20:29 
GeneralRe: New to C# Pin
Salil Khedkar23-Aug-04 20:30
Salil Khedkar23-Aug-04 20:30 
GeneralRe: New to C# Pin
sreejith ss nair23-Aug-04 22:43
sreejith ss nair23-Aug-04 22:43 
GeneralRe: New to C# Pin
S Sansanwal23-Aug-04 23:52
S Sansanwal23-Aug-04 23:52 
GeneralRe: New to C# Pin
billb211224-Aug-04 3:41
billb211224-Aug-04 3:41 
GeneralRe: New to C# Pin
Nick Parker24-Aug-04 4:48
protectorNick Parker24-Aug-04 4:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.