How to show controls without form?

K

Kuba Florczyk

Hi

Once I saw the example application in VC where the controls was show without
form. Maybe somebody know how to do this in DotNet?

If my memory is good :) VC application use Win32 functions to do this.

regards
kuba florczyk
 
H

Herfried K. Wagner

Hello,

Kuba Florczyk said:
Once I saw the example application in VC where the controls
was show without form. Maybe somebody know how to do
this in DotNet?

If my memory is good :) VC application use Win32 functions
to do this.

Where should the control be shown? On the desktop?

Regards,
Herfried K. Wagner
 
K

Kuba Florczyk

I dont mean transparency.
When transparent is on the form is activ and you can not click in the
element under your form.
That same thing with Opaque, when you erased a bgd, its only a simulation.
When you rn SPY++ in VS.NET u will see what i mean (select Find Window).

That VC application was a animated ball which was stroke in the screen
corners. But what was interesting SPY++ finds a window with size 1024x768,
but only ball was activ, everything under "form" u can click.

kuba florczyk
Do you mean that the underlying form was transparent, so while the
controls were visible their container was not and it was possible to click
on underlying applications?
In that case you need to set the Form.TransparencyKey property to be the
same color as the Form.BackColor property i.e.
 
K

Kuba Florczyk

Where should the control be shown? On the desktop?

Yes, on desktop.

kuba florczyk
 
C

Carl Mercier

Hrm... why not use a borderless form that is exactly the size of your
control? I think it is an easy way to accomplish this, isn't?
 
H

Herfried K. Wagner

Hello,

Kuba Florczyk said:
Yes, on desktop.

Untested:

\\\
Private Declare Auto Function SetWindowPos Lib "user32.dll" ( _
ByVal hwnd As IntPtr, _
ByVal hWndInsertAfter As IntPtr, _
ByVal x As Int32, _
ByVal y As Int32, _
ByVal cx As Int32, _
ByVal cy As Int32, _
ByVal wFlags As Int32 _
) As Int32

Private Declare Auto Function SetParent Lib "user32.dll" ( _
ByVal hWndChild As IntPtr, _
ByVal hWndNewParent As IntPtr _
) As Int32

Private Declare Auto Function GetDesktopWindow Lib "user32.dll" ( _
) As IntPtr
///

Regards,
Herfried K. Wagner
 
K

Kuba Florczyk

I have right and you have right :)
Try something like this: Make a form with picturebox, where image is a
patchwork (black and white squares). Backcolor white and transparency white.
And now u can click outside picturebox and click will be trasnferred to the
window below, bu when u click in the "white" square that doesn't wok - u
click in picturebox.

But that not solved my problem.

I must make flash player something like http://www.screenweaver.com/ with
options trasparent.

When i put flash ActiveX on a form and enable TransparencyKey or enable
Opaque I always got background under activex and i don't know how to erased
him. So... i was think that good solution will be show ActiveX without
form - i see somthing like this in VC.

When u want see what i try to doo look at: http://www.comtica.pl/flash/
imagin that a text in IE is ma desktop :)

kuba florczyk
Yes you can.
From the docs:
"When the TransparencyKey property is assigned a Color, the areas of the
form that have the same BackColor will be displayed transparently. Any mouse
actions, such as the click of the mouse, that are performed on the
transparent areas of the form will be transferred to the windows below the
transparent area. For example, if the client region of a form is made
transparent, clicking the mouse on that area would send the event
notification of the click to any window that is below it."
The following form demos this. The form is transparent and topmost,
clicking on on a transparent error passes the input to the underlying
window, but the form and its non-transparent button remain visible (the
topmost property means that your opaque control does not vanish behind the
active window).
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
this.TransparencyKey = this.BackColor ;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.BackColor = System.Drawing.Color.Red;
this.button1.Location = new System.Drawing.Point(104, 96);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.button1});
this.Name = "Form1";
this.Text = "Form1";
this.TopMost = true;
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close() ;
}
}
This may not be what you want, but it is provided in case it helps you get there.
Ian Cooper
wwww.dnug.org.uk
 
K

Kuba Florczyk

Thx men it's work!!!!

Win32.User.SetParent([Your control].Handle, IntPtr.Zero);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top