Click here to Skip to main content
15,888,527 members
Home / Discussions / C#
   

C#

 
GeneralRe: need help with adding a worker thread to my singleton Pin
PIEBALDconsult4-Nov-09 14:22
mvePIEBALDconsult4-Nov-09 14:22 
QuestionTrouble understanding IDisposable Pin
daviiie4-Nov-09 5:35
daviiie4-Nov-09 5:35 
AnswerRe: Trouble understanding IDisposable Pin
Giorgi Dalakishvili4-Nov-09 5:44
mentorGiorgi Dalakishvili4-Nov-09 5:44 
AnswerRe: Trouble understanding IDisposable Pin
Bassam Saoud4-Nov-09 6:29
Bassam Saoud4-Nov-09 6:29 
AnswerRe: Trouble understanding IDisposable Pin
PIEBALDconsult4-Nov-09 7:46
mvePIEBALDconsult4-Nov-09 7:46 
QuestionXml Pin
md_refay4-Nov-09 4:17
md_refay4-Nov-09 4:17 
AnswerRe: Xml Pin
Not Active4-Nov-09 7:15
mentorNot Active4-Nov-09 7:15 
GeneralRe: Xml Pin
Abhishek Sur4-Nov-09 8:39
professionalAbhishek Sur4-Nov-09 8:39 
AnswerRe: Xml Pin
Abhishek Sur4-Nov-09 8:40
professionalAbhishek Sur4-Nov-09 8:40 
QuestionModel-View-Presenter (MVP): events in IView vs Methods in Presenter Pin
art_haali4-Nov-09 3:18
art_haali4-Nov-09 3:18 
AnswerRe: Model-View-Presenter (MVP): events in IView vs Methods in Presenter Pin
Giorgi Dalakishvili4-Nov-09 3:29
mentorGiorgi Dalakishvili4-Nov-09 3:29 
Questionload image Pin
Arefeh Haghpnah4-Nov-09 3:13
Arefeh Haghpnah4-Nov-09 3:13 
AnswerCross post Pin
Not Active4-Nov-09 3:38
mentorNot Active4-Nov-09 3:38 
AnswerRe: load image Pin
Shameel4-Nov-09 4:06
professionalShameel4-Nov-09 4:06 
GeneralRe: load image Pin
Arefeh Haghpnah5-Nov-09 7:32
Arefeh Haghpnah5-Nov-09 7:32 
QuestionSendKeys in WebService Pin
Juergen Loewner4-Nov-09 2:16
Juergen Loewner4-Nov-09 2:16 
AnswerRe: SendKeys in WebService Pin
Dave Kreskowiak4-Nov-09 5:35
mveDave Kreskowiak4-Nov-09 5:35 
QuestionDealing with Lists as objects Pin
MatthysDT4-Nov-09 2:09
MatthysDT4-Nov-09 2:09 
AnswerRe: Dealing with Lists as objects Pin
Luc Pattyn4-Nov-09 2:34
sitebuilderLuc Pattyn4-Nov-09 2:34 
GeneralRe: Dealing with Lists as objects Pin
MatthysDT4-Nov-09 2:49
MatthysDT4-Nov-09 2:49 
GeneralRe: Dealing with Lists as objects Pin
Luc Pattyn4-Nov-09 4:05
sitebuilderLuc Pattyn4-Nov-09 4:05 
AnswerRe: Dealing with Lists as objects Pin
Shameel4-Nov-09 3:42
professionalShameel4-Nov-09 3:42 
QuestionRe: Dealing with Lists as objects Pin
MatthysDT4-Nov-09 18:51
MatthysDT4-Nov-09 18:51 
AnswerRe: Dealing with Lists as objects Pin
PIEBALDconsult4-Nov-09 3:56
mvePIEBALDconsult4-Nov-09 3:56 
QuestionGlass Effect using dwmapi.dll in windows xp on C# Pin
Viswa Teja4-Nov-09 2:01
Viswa Teja4-Nov-09 2:01 
Hii i am writing a code to make the glass effect on windows form. Well the code works fine on vista but my target is on windows xp. I have copyed all the dll's that are reqired and when i debug i am getting an error "DLL NOT FOUND EXCEPTION UNHANDILED".
Here is the code that i am using:-
-----------------------------------------------------------------------------------------------------------------------------
This is the class where i import dwmapi dll.
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

namespace welcome_page
{
class VistaGlassEffect
{
internal class VistaApi
{
[DllImport("dwmapi.dll")]
internal static extern void DwmExtendFrameIntoClientArea(System.IntPtr hWnd, ref Margins pMargins);

[DllImport("dwmapi.dll")]
internal static extern void DwmIsCompositionEnabled(ref bool isEnabled);

internal struct Margins
{
public int Left, Right, Top, Bottom;
}

// consts for wndproc
internal const int WM_NCHITTEST = 0x84;
internal const int HTCLIENT = 1;
internal const int HTCAPTION = 2;
}
}
}
-----------------------------------------------------------------------------------------------------------------------------
This the form where i call this class "VistaGlassEffect"


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.AudioVideoPlayback;
using System.Diagnostics;
using System.Drawing.Drawing2D;


namespace welcome_page
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
this.FitGlass();
}
Video video;
private welcome_page.VistaGlassEffect.VistaApi.Margins marg;
private Rectangle topRect = Rectangle.Empty;
private Rectangle botRect = Rectangle.Empty;
private Rectangle lefRect = Rectangle.Empty;
private Rectangle rigRect = Rectangle.Empty;

private void FitGlass()
{
// If DWM is not enabled then get out
if (!this.IsGlassEnabled())
{
return;

}

// Set the Margins to their default values
marg.Top = 600; // extend from the top
marg.Left = 400; // not used in this sample but could be
marg.Right = 200; // not used in this sample but could be
marg.Bottom = 860;// not used in this sample but could be

this.Paint += new PaintEventHandler(this.Form1_Paint);

// call the function that gives us glass,
// passing a reference to our inset Margins
welcome_page.VistaGlassEffect.VistaApi.DwmExtendFrameIntoClientArea(this.Handle, ref marg);
}


private void apply()
{
this.Paint -= new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.RecreateHandle(); //needed if changing on the fly
this.FitGlass();

}


private bool IsGlassEnabled()
{
//if (Environment.OSVersion.Version.Major < 6)
//{
// Debug.WriteLine("How about trying this on Vista?");
// return false;
//}

//Check if DWM is enabled
bool isGlassSupported = false;
------welcome_page.VistaGlassEffect.VistaApi.DwmIsCompositionEnabled(ref isGlassSupported);---Here Error OCCURS.
return isGlassSupported;
}

// Alpha-blending Paint after the glass extension
// this seems better than the winforms transparency approach because here we can click on the glass!
private void Form1_Paint(object sender, PaintEventArgs e)
{
// black brush for Alpha transparency
SolidBrush blackBrush = new SolidBrush(Color.Black);

Graphics g = e.Graphics;

if (this.IsGlassEnabled())
{
// setup the rectangles
topRect = new Rectangle(0, 0, this.ClientSize.Width, marg.Top);
lefRect = new Rectangle(0, 0, marg.Left, this.ClientSize.Height);
rigRect = new Rectangle(this.ClientSize.Width - marg.Right, 0, marg.Right, this.ClientSize.Height);
botRect = new Rectangle(0, this.ClientSize.Height - marg.Bottom, this.ClientSize.Width, marg.Bottom);
// Fill Rectangles
g.FillRectangle(blackBrush, topRect);
g.FillRectangle(blackBrush, lefRect);
g.FillRectangle(blackBrush, rigRect);
g.FillRectangle(blackBrush, botRect);
}

blackBrush.Dispose();
}





protected override void WndProc(ref Message m)
{
base.WndProc(ref m);

if (m.Msg == welcome_page.VistaGlassEffect.VistaApi.WM_NCHITTEST // if this is a click
&& m.Result.ToInt32() == welcome_page.VistaGlassEffect.VistaApi.HTCLIENT // ...and it is on the client
&& this.IsOnGlass(m.LParam.ToInt32())) // ...and specifically in the glass area
{
m.Result = new IntPtr(welcome_page.VistaGlassEffect.VistaApi.HTCAPTION); // lie and say they clicked on the title bar
}
}

private bool IsOnGlass(int lParam)
{
// sanity check
if (!this.IsGlassEnabled())
{
return false;
}

// get screen coordinates
int x = (lParam << 16) >> 16; // lo order word
int y = lParam >> 16; // hi order word

// translate screen coordinates to client area
Point p = this.PointToClient(new Point(x, y));

// work out if point clicked is on glass
if (topRect.Contains(p) || lefRect.Contains(p) || rigRect.Contains(p) || botRect.Contains(p))
{
return true;
}

return false;
}
void buttn()
{

}
private void Form2_Load(object sender, EventArgs e)
{

int width = panel1.Width;
int height = panel1.Height;
System.Uri u = new Uri(@"F:\Documents\Viswa Teja\Documents\C2\teja.avi");
video = Video.FromUrl(u);
video.Owner = panel1;
video.Play();
panel1.Size = new Size(width, height);
//this.apply();



}

private void button1_Click(object sender, EventArgs e)
{
this.Close();
}



}
}
-----------------------------------------------------------------------------------------------------------------------------


Please kindly help me.

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.