Docking Window problem

F

Falk

hello,



This is a function in the free magic library from Crownwood.

My problem is that I can not move windows to the second monitor. Here is the
function where I think with the problem ( 'IntPtr hDC = User32.GetDC
(IntPtr.Zero);'). The function uses the User32.dll. How con I coding for
multiple monitor?



public static void DrawDragRectangles(Rectangle[] newRects, int indent)

{

if (newRects.Length > 0)

{

// Create the first region

IntPtr newRegion = CreateRectangleRegion(newRects[0],
indent);



for(int index=1; index<newRects.Length; index++)

{

// Create the extra region

IntPtr extraRegion =
CreateRectangleRegion(newRects[index], indent);



// Remove the intersection of the existing and extra
regions

Gdi32.CombineRgn(newRegion, newRegion, extraRegion,
(int)Win32.CombineFlags.RGN_XOR);



// Remove unwanted intermediate objects

Gdi32.DeleteObject(extraRegion);

}



// Get hold of the DC for the desktop

IntPtr hDC = User32.GetDC(IntPtr.Zero);



// Define the area we are allowed to draw into

Gdi32.SelectClipRgn(hDC, newRegion);



Win32.RECT rectBox = new Win32.RECT();



// Get the smallest rectangle that encloses region

Gdi32.GetClipBox(hDC, ref rectBox);



IntPtr brushHandler = GetHalfToneBrush();



// Select brush into the device context

IntPtr oldHandle = Gdi32.SelectObject(hDC, brushHandler);



// Blit to screen using provided pattern brush and invert
with existing screen contents

Gdi32.PatBlt(hDC,

rectBox.left,

rectBox.top,

rectBox.right - rectBox.left,

rectBox.bottom - rectBox.top,

(uint)RasterOperations.PATINVERT);



// Put old handle back again

Gdi32.SelectObject(hDC, oldHandle);



// Reset the clipping region

Gdi32.SelectClipRgn(hDC, IntPtr.Zero);



// Remove unwanted region object

Gdi32.DeleteObject(newRegion);



// Must remember to release the HDC resource!

User32.ReleaseDC(IntPtr.Zero, hDC);

}

}
 
N

Niki Estner

Quote from MSDN, documentation of CreateDC:
"Windows 2000 and later: If there are multiple monitors on the system,
calling CreateDC(TEXT("DISPLAY"),NULL,NULL,NULL) will create a DC covering
all the monitors. "

If I got you right, this could be what you need.

Niki
 

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