Click here to Skip to main content
16,004,227 members
Home / Discussions / C#
   

C#

 
GeneralRe: Please correct the error..... Pin
Colin Angus Mackay26-Jun-07 13:55
Colin Angus Mackay26-Jun-07 13:55 
QuestionBuilding a code Pin
vkg_dce26-Jun-07 2:04
vkg_dce26-Jun-07 2:04 
AnswerRe: Building a code Pin
Manas Bhardwaj26-Jun-07 2:22
professionalManas Bhardwaj26-Jun-07 2:22 
AnswerRe: Building a code Pin
Colin Angus Mackay26-Jun-07 2:22
Colin Angus Mackay26-Jun-07 2:22 
AnswerRe: Building a code Pin
Guffa26-Jun-07 2:46
Guffa26-Jun-07 2:46 
GeneralRe: Building a code Pin
vkg_dce26-Jun-07 20:08
vkg_dce26-Jun-07 20:08 
GeneralRe: Building a code Pin
vkg_dce26-Jun-07 20:10
vkg_dce26-Jun-07 20:10 
Question[C# + GDI]Panel transparent:Pb de rafraichissement Pin
jlbiah26-Jun-07 1:56
jlbiah26-Jun-07 1:56 
Salut,
J'ai crée un panel transparent qui marche plutôt bien en ce qui concerne la transparence; mais le problème est quand je fais bouger l'ascenseur, les parties du panel qui apparaissent sont floues et ont de sérieux problèmes d'encre et je ne sais plus quoi faire (faut dire que je débute en gdi).
voici ma classe de base:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;

namespace TransparentControlsLibrary
{
public class TransparentPanel : System.Windows.Forms.Panel
{
#region P/Invoke
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern int GetWindowLong(HandleRef hWnd, int nIndex);
[DllImport("user32.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);

private const int WS_EX_TRANSPARENT = 0x00000020;
private const int GWL_EXSTYLE = -20;
#endregion

private bool isPainting = false;
private bool isResizing = false;
private Brush backBrush;
private Bitmap tempBitmap;
private Graphics tempGraphics;

public TransparentPanel() : base()
{
this.SetStyle(ControlStyles.UserPaint, true);
}

protected override void OnPaintBackground(PaintEventArgs pevent)
{
}

protected override void OnMove(EventArgs e)
{
//this.Invalidate();
base.OnMove(e);
}

protected override void OnResize(EventArgs e)
{
isResizing = true;
base.OnResize(e);
}

protected override void OnSizeChanged(EventArgs e)
{
isResizing = true;
base.OnSizeChanged(e);
}

protected override void Dispose(bool disposing)
{
if (disposing)
{
backBrush.Dispose();
tempBitmap.Dispose();
tempGraphics.Dispose();
}
base.Dispose (disposing);
}

protected override void OnBackColorChanged(EventArgs e)
{
this.Invalidate();
}

protected override void OnInvalidated(InvalidateEventArgs e)
{
if (!isResizing && !DesignMode)
{
// HACK: Permet de supprimer d'initialiser le fond du panel à Transparent.
this.SuspendLayout();
this.Width--;
this.Width++;
this.ResumeLayout();
}
base.OnInvalidated (e);
}

protected override void OnPaint(PaintEventArgs e)
{
if (!isPainting)
{
isPainting = true;
backBrush = new SolidBrush(Color.FromArgb(this.OpacityAsByte, base.BackColor));
tempBitmap = new Bitmap(this.Width, this.Height);
tempGraphics = Graphics.FromImage(tempBitmap);

tempGraphics.FillRectangle(backBrush, 0,0,this.Width, this.Height);
e.Graphics.DrawImage(tempBitmap, e.ClipRectangle);
isPainting = false;
isResizing = false;
}
}

// Transforme la valeur d'opacité du masque en byte
private byte OpacityAsByte {
get {return (byte)(this.opacity * 255);}
}

private double opacity = 1;
public double Opacity {
get {return opacity;}
set {
if (value > 1)
value = 1;
else if (value < 0)
value = 0;

opacity = value;
this.Invalidate();
}
}

// Précise que le controle doit être transparent
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= WS_EX_TRANSPARENT;
return cp;
}
}
}
}
AnswerRe: [C# + GDI] Transparent Panel : refresh problem Pin
jlbiah26-Jun-07 2:05
jlbiah26-Jun-07 2:05 
QuestionHow to populate the gridview in c# windows application? Pin
monuSaini26-Jun-07 1:56
monuSaini26-Jun-07 1:56 
GeneralRe: How to populate the gridview in c# windows application? Pin
Stu Richardson26-Jun-07 2:39
Stu Richardson26-Jun-07 2:39 
GeneralRe: How to populate the gridview in c# windows application? Pin
monuSaini26-Jun-07 2:45
monuSaini26-Jun-07 2:45 
AnswerRe: How to populate the gridview in c# windows application? Pin
Stu Richardson26-Jun-07 3:02
Stu Richardson26-Jun-07 3:02 
GeneralRe: How to populate the gridview in c# windows application? Pin
monuSaini26-Jun-07 3:11
monuSaini26-Jun-07 3:11 
GeneralRe: How to populate the gridview in c# windows application? Pin
Stu Richardson26-Jun-07 3:24
Stu Richardson26-Jun-07 3:24 
QuestionHow to populate the gridview in c# windows application? Pin
monuSaini26-Jun-07 1:56
monuSaini26-Jun-07 1:56 
AnswerRe: How to populate the gridview in c# windows application? Pin
Gamzun26-Jun-07 4:16
Gamzun26-Jun-07 4:16 
Question[Message Deleted] Pin
help as an alias26-Jun-07 1:37
help as an alias26-Jun-07 1:37 
AnswerRe: Please correct the errror... Pin
Ed.Poore26-Jun-07 1:42
Ed.Poore26-Jun-07 1:42 
AnswerRe: Please correct the errror... Pin
Vasudevan Deepak Kumar26-Jun-07 1:42
Vasudevan Deepak Kumar26-Jun-07 1:42 
AnswerRe: Please correct the errror... Pin
Giorgi Dalakishvili26-Jun-07 1:42
mentorGiorgi Dalakishvili26-Jun-07 1:42 
AnswerRe: [Message Deleted] Pin
Colin Angus Mackay26-Jun-07 2:26
Colin Angus Mackay26-Jun-07 2:26 
QuestionCalling and controlling dynamic DataGrid [modified] Pin
JoppeG26-Jun-07 1:11
JoppeG26-Jun-07 1:11 
QuestionEnumerations Pin
Sebastian T Xavier26-Jun-07 0:56
Sebastian T Xavier26-Jun-07 0:56 
AnswerRe: Enumerations Pin
Christian Graus26-Jun-07 1:06
protectorChristian Graus26-Jun-07 1:06 

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.