Click here to Skip to main content
15,126,105 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionProblems adding dynamically a custon-control to a panel Pin
J. Holzer24-Jul-07 12:40
MemberJ. Holzer24-Jul-07 12:40 
QuestionHow to run a dll on system reboot Pin
rockyl24-Jul-07 5:46
Memberrockyl24-Jul-07 5:46 
AnswerRe: How to run a dll on system reboot Pin
Christian Graus24-Jul-07 14:31
protectorChristian Graus24-Jul-07 14:31 
GeneralRe: How to run a dll on system reboot Pin
rockyl24-Jul-07 22:02
Memberrockyl24-Jul-07 22:02 
GeneralRe: How to run a dll on system reboot Pin
Christian Graus24-Jul-07 23:05
protectorChristian Graus24-Jul-07 23:05 
GeneralRe: How to run a dll on system reboot Pin
rockyl24-Jul-07 23:39
Memberrockyl24-Jul-07 23:39 
GeneralRe: How to run a dll on system reboot Pin
Jonathan [Darka]26-Jul-07 5:27
professionalJonathan [Darka]26-Jul-07 5:27 
QuestionDrag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
charles92223-Jul-07 19:57
Membercharles92223-Jul-07 19:57 
Greetings all,

I can drag and drop a bitmap from a small picture box (pictureBox1) to a larger picture box (pictureBox2) and it works fine until a repaint, at which point the large picture box reverts back to what it was before the drag and drop. Thank you in advance. Any ideas to fix this would be appreciated. (Thanks to Rehan Nadeem for the Win32Support code!)

private void pictureBox2_DragDrop(object sender, DragEventArgs e)
{
if ((e.Data.GetDataPresent(DataFormats.Bitmap)))
{
Point largeBitmapLocation = this.pictureBox2.PointToClient(new Point(e.X, e.Y));

// 1. Get a handle to the large bitmap device context
Graphics largeBitmapDC = this.pictureBox2.CreateGraphics();
IntPtr largeBitmapHdc = largeBitmapDC.GetHdc();

// 2. Get a handle to the small bitmap device context
Bitmap smallBitmap = (Bitmap)(e.Data.GetData(DataFormats.Bitmap));
int smallBitmapHeight = smallBitmap.Height;
int smallBitmapWidth = smallBitmap.Width;
IntPtr smallBitmapHdc = Win32Support.CreateCompatibleDC(largeBitmapHdc); // in-memory
Win32Support.SelectObject(smallBitmapHdc, smallBitmap.GetHbitmap());

// 3. draw the smallBitmap on the largeBitmap
Win32Support.BitBlt(
largeBitmapHdc, // largeBitmap is target
largeBitmapLocation.X, largeBitmapLocation.Y, // destination
smallBitmapWidth, smallBitmapHeight, // source width, height
smallBitmapHdc, // smallBitmap is source
0, 0, // source x,y
Win32Support.TernaryRasterOperations.SRCCOPY);

Graphics memDC = Graphics.FromHdc(smallBitmapHdc); // for ReleaseHdc
IntPtr hMemdc = memDC.GetHdc();

memDC.ReleaseHdc(hMemdc);
largeBitmapDC.ReleaseHdc(largeBitmapHdc);
}
}

charles922
cepeasley@earthlink.net
AnswerRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Christian Graus23-Jul-07 20:11
protectorChristian Graus23-Jul-07 20:11 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Paul Conrad23-Jul-07 20:48
professionalPaul Conrad23-Jul-07 20:48 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Christian Graus23-Jul-07 20:58
protectorChristian Graus23-Jul-07 20:58 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Paul Conrad23-Jul-07 21:00
professionalPaul Conrad23-Jul-07 21:00 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Luc Pattyn24-Jul-07 13:18
sitebuilderLuc Pattyn24-Jul-07 13:18 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Christian Graus24-Jul-07 14:29
protectorChristian Graus24-Jul-07 14:29 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
charles92224-Jul-07 23:08
Membercharles92224-Jul-07 23:08 
QuestionData Flow between a web server and a computer Pin
Tarik Guney23-Jul-07 13:12
MemberTarik Guney23-Jul-07 13:12 
AnswerRe: Data Flow between a web server and a computer Pin
Paul Conrad23-Jul-07 16:20
professionalPaul Conrad23-Jul-07 16:20 
GeneralRe: Data Flow between a web server and a computer Pin
Tarik Guney23-Jul-07 23:39
MemberTarik Guney23-Jul-07 23:39 
QuestionDisplaying a Form in a specific monitor Pin
Leslie Sanford23-Jul-07 11:21
MemberLeslie Sanford23-Jul-07 11:21 
AnswerRe: Displaying a Form in a specific monitor Pin
Luc Pattyn23-Jul-07 12:18
sitebuilderLuc Pattyn23-Jul-07 12:18 
GeneralRe: Displaying a Form in a specific monitor Pin
Leslie Sanford23-Jul-07 13:56
MemberLeslie Sanford23-Jul-07 13:56 
GeneralRe: Displaying a Form in a specific monitor Pin
Luc Pattyn23-Jul-07 14:28
sitebuilderLuc Pattyn23-Jul-07 14:28 
GeneralRe: Displaying a Form in a specific monitor Pin
Leslie Sanford25-Jul-07 18:28
MemberLeslie Sanford25-Jul-07 18:28 
GeneralRe: Displaying a Form in a specific monitor Pin
Paul Conrad25-Jul-07 18:49
professionalPaul Conrad25-Jul-07 18:49 
QuestionC# Winforms DataGridView control in User Control Pin
ADSolArch23-Jul-07 0:08
MemberADSolArch23-Jul-07 0:08 

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.