|
Here's the translated C# code if anyones interested...
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
<br />
namespace WindowsApplication3<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label1;<br />
<br />
private bool LeftMouseDown = false;<br />
private Point MouseDownPos;<br />
private Rectangle DragRect;<br />
private ArrayList FinalRects;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.MouseDownPos = new Point( 0,0 );<br />
this.FinalRects = new ArrayList();<br />
<br />
this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.label3.SuspendLayout();<br />
this.SuspendLayout();<br />
this.label3.BackColor = System.Drawing.Color.Transparent;<br />
this.label3.Controls.Add(this.label1);<br />
this.label3.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label3.Location = new System.Drawing.Point(0, 0);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(292, 266);<br />
this.label3.TabIndex = 0;<br />
this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint);<br />
this.label1.BackColor = System.Drawing.Color.Transparent;<br />
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label1.Location = new System.Drawing.Point(0, 0);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(292, 266);<br />
this.label1.TabIndex = 1;<br />
this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.Control;<br />
this.ClientSize = new System.Drawing.Size(292, 266);<br />
this.Controls.Add(this.label3);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);<br />
this.label3.ResumeLayout(false);<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
}<br />
<br />
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseDown");<br />
MouseDownPos = new Point(e.X, e.Y); <br />
LeftMouseDown = true;<br />
DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseMove");<br />
DragRect = CalcDragRect(e.X, e.Y);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Console.WriteLine("Panel2_MouseUp");<br />
LeftMouseDown = false;<br />
DragRect = CalcDragRect(e.X, e.Y); <br />
this.label1.Invalidate();<br />
FinalRects.Add(DragRect);<br />
}<br />
}<br />
<br />
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Pen pen = new Pen(Color.Blue);<br />
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
DrawRect(e.Graphics, DragRect, pen);<br />
pen.Dispose();<br />
} <br />
}<br />
<br />
private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
foreach( Rectangle rect in FinalRects )<br />
{<br />
DrawRect(e.Graphics, rect, Pens.Red);<br />
}<br />
}<br />
<br />
public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
{<br />
if (rect.Width == 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
}<br />
else if (rect.Width > 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
}<br />
else if (rect.Width == 0 && rect.Height > 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
}<br />
else
{<br />
g.DrawRectangle(pen, rect);<br />
}<br />
}<br />
<br />
private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
{<br />
return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
System.Math.Min(mouseY, MouseDownPos.Y),<br />
System.Math.Max(mouseX, MouseDownPos.X),<br />
System.Math.Max(mouseY, MouseDownPos.Y) <br />
);<br />
}<br />
<br />
private void Form1_SizeChanged(object sender, System.EventArgs e)<br />
{ <br />
base.OnSizeChanged(e);<br />
this.Invalidate(); <br />
}<br />
}<br />
}<br />
*sigh* still working on this one.
|
|
|
|
|
This works (for me), i copied it from Reflector:
namespace TransparentPanels
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
public class TransPanelForm : Form
{
public TransPanelForm()
{
this.FinalRects = new ArrayList();
this.InitializeComponent();
this.SetStyle(ControlStyles.DoubleBuffer |
(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint), true);
}
private Rectangle CalcDragRect(int mouseX, int mouseY)
{
return Rectangle.FromLTRB(Math.Min(mouseX, this.MouseDownPos.X),
Math.Min(mouseY, this.MouseDownPos.Y),
Math.Max(mouseX, this.MouseDownPos.X),
Math.Max(mouseY, this.MouseDownPos.Y));
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
public static void DrawRect(Graphics g, Rectangle rect, Pen pen)
{
if ((rect.Width == 0) && (rect.Height == 0))
{
g.DrawLine(pen, (float)rect.X, (float)rect.Y,
(float)rect.X, (float)(rect.Y + 0.01f));
}
else if ((rect.Width > 0) && (rect.Height == 0))
{
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
}
else if ((rect.Width == 0) && (rect.Height > 0))
{
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);
}
else
{
g.DrawRectangle(pen, rect);
}
}
[DebuggerStepThrough]
private void InitializeComponent()
{
this.Panel1 = new Label();
this.Panel2 = new Label();
this.SuspendLayout();
this.Panel1.BackColor = Color.Transparent;
this.Panel1.BorderStyle = BorderStyle.FixedSingle;
this.Panel1.Dock = DockStyle.Left;
Point point1 = new Point(10, 10);
this.Panel1.Location = point1;
this.Panel1.Name = "Panel1";
Size size1 = new Size(270, 0x10a);
this.Panel1.Size = size1;
this.Panel1.TabIndex = 0;
this.Panel2.BackColor = Color.Transparent;
this.Panel2.BorderStyle = BorderStyle.FixedSingle;
this.Panel2.Dock = DockStyle.Right;
point1 = new Point(290, 10);
this.Panel2.Location = point1;
this.Panel2.Name = "Panel2";
size1 = new Size(0x110, 0x10a);
this.Panel2.Size = size1;
this.Panel2.TabIndex = 0;
size1 = new Size(5, 13);
this.AutoScaleBaseSize = size1;
size1 = new Size(0x23c, 0x11e);
this.ClientSize = size1;
this.Controls.Add(this.Panel2);
this.Controls.Add(this.Panel1);
this.DockPadding.All = 10;
this.Name = "TransPanelForm";
this.Text = "TransPanelForm";
this.ResumeLayout(false);
}
[STAThread]
public static void Main()
{
Application.Run(new TransPanelForm());
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
Rectangle rectangle1 = this.ClientRectangle;
LinearGradientBrush brush1 = new LinearGradientBrush(rectangle1,
Color.White, Color.LightSteelBlue,
LinearGradientMode.ForwardDiagonal);
e.Graphics.FillRectangle(brush1, rectangle1);
brush1.Dispose();
}
protected override void OnSizeChanged(EventArgs e)
{
base.OnSizeChanged(e);
this.Invalidate();
}
private void Panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point point1 = new Point(e.X, e.Y);
this.MouseDownPos = point1;
this.LeftMouseDown = true;
Rectangle rectangle1 = new Rectangle(e.X, e.Y, 0, 0);
this.DragRect = rectangle1;
this.Panel2.Invalidate();
}
}
private void Panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.DragRect = this.CalcDragRect(e.X, e.Y);
this.Panel1.Invalidate();
}
}
private void Panel1_MouseUp(object sender, MouseEventArgs e)
{
if (this.LeftMouseDown)
{
this.LeftMouseDown = false;
this.DragRect = this.CalcDragRect(e.X, e.Y);
this.Panel2.Invalidate();
this.FinalRects.Add(this.DragRect);
}
}
private void Panel1_Paint(object sender, PaintEventArgs e)
{
if (this.LeftMouseDown)
{
Pen pen1 = new Pen(Color.Blue);
pen1.DashStyle = DashStyle.Dash;
TransPanelForm.DrawRect(e.Graphics, this.DragRect, pen1);
pen1.Dispose();
}
}
private void Panel2_Paint(object sender, PaintEventArgs e)
{
IEnumerator enum1;
try
{
enum1 = this.FinalRects.GetEnumerator();
while (enum1.MoveNext())
{
Rectangle rectangle1 = (Rectangle) enum1.Current;
TransPanelForm.DrawRect(e.Graphics, rectangle1, Pens.Red);
}
}
finally
{
}
}
internal virtual Label Panel1
{
get
{
return this._Panel1;
}
[MethodImpl(MethodImplOptions.Synchronized)]
set
{
if (this._Panel1 != null)
{
this._Panel1.Paint -= new PaintEventHandler(this.Panel1_Paint);
this._Panel1.MouseMove -= new MouseEventHandler(this.Panel1_MouseMove);
this._Panel1.MouseUp -= new MouseEventHandler(this.Panel1_MouseUp);
this._Panel1.MouseDown -= new MouseEventHandler(this.Panel1_MouseDown);
}
this._Panel1 = value;
if (this._Panel1 != null)
{
this._Panel1.Paint += new PaintEventHandler(this.Panel1_Paint);
this._Panel1.MouseMove += new MouseEventHandler(this.Panel1_MouseMove);
this._Panel1.MouseUp += new MouseEventHandler(this.Panel1_MouseUp);
this._Panel1.MouseDown += new MouseEventHandler(this.Panel1_MouseDown);
}
}
}
internal virtual Label Panel2
{
get
{
return this._Panel2;
}
[MethodImpl(MethodImplOptions.Synchronized)]
set
{
if (this._Panel2 != null)
{
this._Panel2.Paint -= new PaintEventHandler(this.Panel2_Paint);
}
this._Panel2 = value;
if (this._Panel2 != null)
{
this._Panel2.Paint += new PaintEventHandler(this.Panel2_Paint);
}
}
}
[AccessedThroughProperty("Panel1")]
private Label _Panel1;
[AccessedThroughProperty("Panel2")]
private Label _Panel2;
private IContainer components;
private Rectangle DragRect;
private ArrayList FinalRects;
private bool LeftMouseDown;
private Point MouseDownPos;
}
}
|
|
|
|
|
Alright, here's one last shot at the dilema I've been facing with this little project. I'm just so close, yet so far. Here's the setup as it currently stands.
I have a basic Win-Form with a Browser component Control, I've then added to that this.WB.Controls.Add(this.render_label);. This is just a label exactly as in your example, so the render label has a drag label control added to itself this.render_label.Controls.Add(this.drag_label);. So basically what I would like to accomplish is to view web pages in the browser, and then be able to draw rectangles and such around objects on the web page. But currently when I make the render & drag labels visible (their backcolor is set to .Transparent) the browser disappears and you then see the original forms background.
I tried utilizing the browser Invalidated() event handler, but to no avail. Am I just missing the point here? Any other suggesitons you might have would be greatly appreciated again.
~Rcurrie
|
|
|
|
|
rcurrie wrote:
Am I just missing the point here?
Yes i think you are, because the point is that a transparant control just paints it's parent. So when the browser and the render label are both on the form (have form as parent), and the label is over the browser, the label will just paint the form.
I don't know about the browser (like it's an ActiveX or something). Does the browser control has a Controls property, just like the label? If so, try adding the render label to the browser (browser.Controls.Add(render_label) ). But again i don't know if that is even possible.
Waiting for your reply!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Thanks [Marc],
That does indeed make sense. The ActiveX browser component that I am using does indeed have a controls property, however it doesn't function the way I would hope. So basically I have 2 labels and the browser. I have added the inner most label to the controls of the second label. I have then added this second label to the controls of the browser, and then added the browser itself to the controls of the form. That seems to be just what we're looking for here.
However, it still does not appear transparent. I think it has to do with the OnPaint event of the browser...namely that it doesnt have one. The Invalidated() event is probably quite similar, but I'm confussed on what to put in this event_handler in order to repaint the browser onto the labels?
Here is some code that demonstrates what I'm trying to do...just like above but I've added the browser to it. You'll probably have to add the AxSHDocVx resource as well as the Microsoft.mshtml resource to the project should you using it in VS.NET
using System;<br />
using System.Drawing;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Windows.Forms;<br />
using System.Data;<br />
using mshtml;<br />
<br />
namespace WindowsApplication3<br />
{<br />
public class Form1 : System.Windows.Forms.Form<br />
{<br />
private System.Windows.Forms.Label label3;<br />
private System.Windows.Forms.Label label1;<br />
<br />
private bool LeftMouseDown = false;<br />
private Point MouseDownPos;<br />
private Rectangle DragRect;<br />
private ArrayList FinalRects;<br />
private AxSHDocVw.AxWebBrowser axWebBrowser1;<br />
<br />
private System.ComponentModel.Container components = null;<br />
<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
<br />
this.axWebBrowser1.Navigate("http://www.msnbc.com");<br />
<br />
this.MouseDownPos = new Point( 0,0 );<br />
this.FinalRects = new ArrayList();<br />
<br />
this.SetStyle(System.Windows.Forms.ControlStyles.SupportsTransparentBackColor, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
this.SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
}<br />
<br />
protected override void Dispose( bool disposing )<br />
{<br />
if( disposing )<br />
{<br />
if (components != null) <br />
{<br />
components.Dispose();<br />
}<br />
}<br />
base.Dispose( disposing );<br />
}<br />
<br />
#region Windows Form Designer generated code<br />
private void InitializeComponent()<br />
{<br />
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));<br />
this.label3 = new System.Windows.Forms.Label();<br />
this.label1 = new System.Windows.Forms.Label();<br />
this.axWebBrowser1 = new AxSHDocVw.AxWebBrowser();<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).BeginInit();<br />
this.SuspendLayout();<br />
this.label1.BackColor = System.Drawing.Color.Transparent;<br />
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.label1.Location = new System.Drawing.Point(0, 0);<br />
this.label1.Name = "label1";<br />
this.label1.Size = new System.Drawing.Size(400, 400);<br />
this.label1.TabIndex = 1;<br />
this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint);<br />
this.label1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.label1_MouseUp);<br />
this.label1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.label1_MouseMove);<br />
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.label1_MouseDown);<br />
this.label3.BackColor = System.Drawing.Color.Transparent;<br />
this.label3.Controls.Add(this.label1);<br />
this.label3.Location = new System.Drawing.Point(188, 32);<br />
this.label3.Name = "label3";<br />
this.label3.Size = new System.Drawing.Size(400, 400);<br />
this.label3.TabIndex = 0;<br />
this.label3.Paint += new System.Windows.Forms.PaintEventHandler(this.label3_Paint); <br />
this.axWebBrowser1.Controls.Add(label3);<br />
this.axWebBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;<br />
this.axWebBrowser1.Enabled = true;<br />
this.axWebBrowser1.Location = new System.Drawing.Point(0, 0);<br />
this.axWebBrowser1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axWebBrowser1.OcxState")));<br />
this.axWebBrowser1.Size = new System.Drawing.Size(819, 476);<br />
this.axWebBrowser1.TabIndex = 1;<br />
this.axWebBrowser1.Invalidated += new InvalidateEventHandler(axWebBrowser1_Invalidated);<br />
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);<br />
this.BackColor = System.Drawing.SystemColors.Control;<br />
this.ClientSize = new System.Drawing.Size(819, 476);<br />
this.Controls.Add(this.axWebBrowser1);<br />
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;<br />
this.MaximumSize = new System.Drawing.Size(825, 500);<br />
this.MinimumSize = new System.Drawing.Size(825, 500);<br />
this.Name = "Form1";<br />
this.Text = "Form1";<br />
((System.ComponentModel.ISupportInitialize)(this.axWebBrowser1)).EndInit();<br />
this.ResumeLayout(false);<br />
<br />
}<br />
#endregion<br />
<br />
[STAThread]<br />
static void Main() <br />
{<br />
Application.Run(new Form1());<br />
}<br />
<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
base.OnPaintBackground (pevent);<br />
}<br />
<br />
private void label1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseDown");<br />
MouseDownPos = new Point(e.X, e.Y); <br />
LeftMouseDown = true;<br />
DragRect = new Rectangle(e.X, e.Y, 0, 0);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( e.Button == MouseButtons.Left )<br />
{<br />
Console.WriteLine("Panel2_MouseMove");<br />
DragRect = CalcDragRect(e.X, e.Y);<br />
this.label1.Invalidate();<br />
} <br />
}<br />
<br />
private void label1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Console.WriteLine("Panel2_MouseUp");<br />
LeftMouseDown = false;<br />
DragRect = CalcDragRect(e.X, e.Y); <br />
this.label1.Invalidate();<br />
FinalRects.Add(DragRect);<br />
}<br />
}<br />
<br />
private void label1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
if( LeftMouseDown )<br />
{<br />
Pen pen = new Pen(Color.Blue);<br />
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;<br />
DrawRect(e.Graphics, DragRect, pen);<br />
pen.Dispose();<br />
} <br />
}<br />
<br />
private void label3_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
foreach( Rectangle rect in FinalRects )<br />
{<br />
DrawRect(e.Graphics, rect, Pens.Red);<br />
}<br />
}<br />
<br />
public void DrawRect(Graphics g, Rectangle rect, Pen pen)<br />
{<br />
if (rect.Width == 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Y + (float)0.01);<br />
}<br />
else if (rect.Width > 0 && rect.Height == 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);<br />
}<br />
else if (rect.Width == 0 && rect.Height > 0) <br />
{<br />
g.DrawLine(pen, rect.X, rect.Y, rect.X, rect.Bottom);<br />
}<br />
else<br />
{<br />
g.DrawRectangle(pen, rect);<br />
}<br />
}<br />
<br />
private System.Drawing.Rectangle CalcDragRect(int mouseX, int mouseY)<br />
{<br />
return Rectangle.FromLTRB( System.Math.Min(mouseX, MouseDownPos.X),<br />
System.Math.Min(mouseY, MouseDownPos.Y),<br />
System.Math.Max(mouseX, MouseDownPos.X),<br />
System.Math.Max(mouseY, MouseDownPos.Y) <br />
);<br />
}<br />
<br />
private void axWebBrowser1_Invalidated(object sender, InvalidateEventArgs e)<br />
{<br />
<br />
}<br />
}<br />
}<br />
|
|
|
|
|
When a control has a transparent background, it does InvokePaintBackground[^] and InvokePaint[^] on its parent. So if the browser doesn't paint anything in OnPaint and/or OnPaintBackground (wich is probably the case), i think you're screwed...
Maybe you should repost your question, explain that it's in an ActiveX browser control so that normal Let-My-Parent-Paint-My-Background transparency doesn't work, you can give a link to the top of this topic if you want.
Toedeloe!
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Does anyone have a clever idea on how to bind RadioButtons?
|
|
|
|
|
How do I exactly do it?
I am just learning C#, I have a C++ background and in C++ it was something like this:
class someclass {
public:
int somemember;
someclass(int i)
}
someclass::someclass (int i) :
somemember(i)
{
}
Is there something similar in C# or is this enough?
class someclass
public int somemember;
public someclass(int i)
{
somemember = i;
}
}
Tnx
Dragan
|
|
|
|
|
You are doing the right thing.
Alomgir Miah
Live Life King Size
|
|
|
|
|
While looking at all this XML stuff I keep seeing this stream thing. What exactly is stream when doing xml syncronization?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
A stream is an abstraction of the idea of data flow. In other words, a stream is most typically a file on your hard drive, but can be something else.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
When I populate my datagrid in my dialog app can I limit it as to what columns I want to show?
Also I found an example on how to do ADO.NET programming in C# using name space system.data.ADO. However I do not have this on my machine. Did this change and if so what tutorial would be a good one to read to show the changes?
Last question If I'm opening an Access 2000 database using the dataset (hopefully this is right) would this be okay if i'm populating a list control or would a datagrid work better?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You can use your DataSet's ColumnMapping property to hide a column.
// Creating connection and command sting
string conStr = @"Provider=Microsoft.JET.OLEDB.4.0;data source=C:\northwind.mdb";
string sqlStr = "SELECT * FROM Employees";
// Create connection object
OleDbConnection conn = new OleDbConnection(conStr);
// Create data adapter object
OleDbDataAdapter da = new OleDbDataAdapter(sqlStr,conn);
// Create a dataset object and fill with data using data adapter's Fill method
DataSet ds = new DataSet();
da.Fill(ds, "Employees");
// Hide the column and attach dataset's DefaultView to the datagrid control
ds.Tables["Employees"].Columns["LastName"].ColumnMapping = MappingType.Hidden;
dataGrid1.DataSource = ds.Tables["Employees"];
Alomgir Miah
Live Life King Size
|
|
|
|
|
Does anyone know a way to get the type names of custom attributes applied to a class when the assembly is loaded in ReflectionOnly mode?
The only method to get custom attributes that I know is Type.GetCustomAttributes; but since that returns attribute instances and not just the type name, it can't be used in ReflectionOnly mode.
I just want to make sure I'm not overlooking something before sending a suggestion to Microsoft.
|
|
|
|
|
|
ReflectionOnly mode means the type is loaded in "inspection context".
That is a .NET 2.0 feature to load assembly if you just want to reflect on them without creating types.
It's faster, doesn't lock the assembly file etc...
But you can't get instances from ReflectionOnly assemblies, so GetCustomAttributes() always results in an exception.
But I just found the solution myself: CustomAttributeData.GetCustomAttributes(type)[^] gets information about the attributes in a ReflectionOnly compatible way.
|
|
|
|
|
Hello,
If I have 5 tabcontrol windows on my Form1. Is there a way of
hiding some of those tabs?
Thank you
|
|
|
|
|
this.tabControl1.TabPages.Remove(this.tabPageToRemove);
Add it again when you need it
this.tabControl1.TabPages.Add(this.tabPageToRemove);
Alomgir Miah
Live Life King Size
|
|
|
|
|
hello
i am new in programming and also in C#. i have a problem regarding for loop in three dimentional array .
i am pasting piece of code in which i want to check that a value exists in array or not
rook_moves = new int[ 64 ][][];
rook_moves[ 0 ] = new int[ 2 ][];
rook_moves[ 0 ][ 0 ] = new int[ 7 ];
rook_moves[ 0 ][ 1 ] = new int[ 7 ];
rook_moves[ 0 ][ 0 ][ 0 ] = 1;
rook_moves[ 0 ][ 0 ][ 1 ] = 2;
rook_moves[ 0 ][ 0 ][ 2 ] = 3;
rook_moves[ 0 ][ 0 ][ 3 ] = 4;
rook_moves[ 0 ][ 0 ][ 4 ] = 5;
rook_moves[ 0 ][ 0 ][ 5 ] = 6;
rook_moves[ 0 ][ 0 ][ 6 ] = 7;
rook_moves[ 0 ][ 1 ][ 0 ] = 8;
rook_moves[ 0 ][ 1 ][ 1 ] = 16;
rook_moves[ 0 ][ 1 ][ 2 ] = 24;
rook_moves[ 0 ][ 1 ][ 3 ] = 32;
rook_moves[ 0 ][ 1 ][ 4 ] = 40;
rook_moves[ 0 ][ 1 ][ 5 ] = 48;
rook_moves[ 0 ][ 1 ][ 6 ] = 56;
if i want to search that '48' exists or not please tell me how i will implement it in C#
thanks
|
|
|
|
|
Ok i'm not 100% sure but i think something like this is what your asking for.
<br />
for (int i=0; i<64; i++)<br />
{<br />
for (int x=0; x<64; x++)<br />
{<br />
for (int z=0; z<64; z++)<br />
{<br />
if (rook_moves[i][x][z] == 48)<br />
return true;<br />
}<br />
}<br />
}<br />
This code, i'm pretty sure, would check every single slot in the Array for 48.
|
|
|
|
|
Hello,
I'd like to read in a few enviroment variables for an application that will automate a few tasks. VB has a function 'Environ' that can look up env variables with the key as the parameter. Is there anything simular in C#? It it's not possible through C# then I assume to use some api calls.
Thanks,
Bic2k
|
|
|
|
|
Yup, figured it out myself of course.
string path = System.Environment.GetEnvironmentVariable("PATH");
James
|
|
|
|
|
Please note that the environment variables created within the application will not be
available after the application exits.
|
|
|
|
|
|
hi ...i want to know tht how can we discover whole network in such a way that just enter the IP address, then discover and scan all devices and network attached to system and keep on scanning until reach at some dead end.
plz gime the hint how can we do ht in c#.net ...thank u
ingenious
|
|
|
|
|