Click here to Skip to main content
15,867,308 members
Home / Discussions / Windows Forms
   

Windows Forms

 
QuestionProblems adding dynamically a custon-control to a panel Pin
J. Holzer24-Jul-07 11:40
J. Holzer24-Jul-07 11:40 
QuestionHow to run a dll on system reboot Pin
rockyl24-Jul-07 4:46
rockyl24-Jul-07 4:46 
AnswerRe: How to run a dll on system reboot Pin
Christian Graus24-Jul-07 13:31
protectorChristian Graus24-Jul-07 13:31 
GeneralRe: How to run a dll on system reboot Pin
rockyl24-Jul-07 21:02
rockyl24-Jul-07 21:02 
GeneralRe: How to run a dll on system reboot Pin
Christian Graus24-Jul-07 22:05
protectorChristian Graus24-Jul-07 22:05 
GeneralRe: How to run a dll on system reboot Pin
rockyl24-Jul-07 22:39
rockyl24-Jul-07 22:39 
GeneralRe: How to run a dll on system reboot Pin
Jonathan [Darka]26-Jul-07 4:27
professionalJonathan [Darka]26-Jul-07 4:27 
QuestionDrag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
charles92223-Jul-07 18:57
charles92223-Jul-07 18: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 19:11
protectorChristian Graus23-Jul-07 19:11 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Paul Conrad23-Jul-07 19:48
professionalPaul Conrad23-Jul-07 19:48 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Christian Graus23-Jul-07 19:58
protectorChristian Graus23-Jul-07 19:58 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Paul Conrad23-Jul-07 20:00
professionalPaul Conrad23-Jul-07 20:00 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Luc Pattyn24-Jul-07 12:18
sitebuilderLuc Pattyn24-Jul-07 12:18 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
Christian Graus24-Jul-07 13:29
protectorChristian Graus24-Jul-07 13:29 
GeneralRe: Drag and drop pictureBox bitmap is overwritten by repaint (C#) Pin
charles92224-Jul-07 22:08
charles92224-Jul-07 22:08 
QuestionData Flow between a web server and a computer Pin
Tarik Guney23-Jul-07 12:12
Tarik Guney23-Jul-07 12:12 
AnswerRe: Data Flow between a web server and a computer Pin
Paul Conrad23-Jul-07 15:20
professionalPaul Conrad23-Jul-07 15:20 
GeneralRe: Data Flow between a web server and a computer Pin
Tarik Guney23-Jul-07 22:39
Tarik Guney23-Jul-07 22:39 
QuestionDisplaying a Form in a specific monitor Pin
Leslie Sanford23-Jul-07 10:21
Leslie Sanford23-Jul-07 10:21 
AnswerRe: Displaying a Form in a specific monitor Pin
Luc Pattyn23-Jul-07 11:18
sitebuilderLuc Pattyn23-Jul-07 11:18 
GeneralRe: Displaying a Form in a specific monitor Pin
Leslie Sanford23-Jul-07 12:56
Leslie Sanford23-Jul-07 12:56 
GeneralRe: Displaying a Form in a specific monitor Pin
Luc Pattyn23-Jul-07 13:28
sitebuilderLuc Pattyn23-Jul-07 13:28 
GeneralRe: Displaying a Form in a specific monitor Pin
Leslie Sanford25-Jul-07 17:28
Leslie Sanford25-Jul-07 17:28 
GeneralRe: Displaying a Form in a specific monitor Pin
Paul Conrad25-Jul-07 17:49
professionalPaul Conrad25-Jul-07 17:49 
QuestionC# Winforms DataGridView control in User Control Pin
ADSolArch22-Jul-07 23:08
ADSolArch22-Jul-07 23: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.