Desktop Functions: Smart Device Functions:
|
Search Results for "RECT" in [All]gdi321: Arc
static extern bool ArcTo(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1,
ByVal nLeftRect As Integer, ByVal nTopRect As Integer, _
ByVal nRightRect As Integer, ByVal nBottomRect As Integer, _ 2: ArcTo
static extern bool ArcTo(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1,
ByVal nLeftRect As Integer, ByVal nTopRect As Integer, _
ByVal nRightRect As Integer, ByVal nBottomRect As Integer, _ 3: BitBlt The BitBlt function performs a bit-block transfer of the color data corresponding to a rectangle of pixels from the specified source device context into a destination device context.
/// rectangle of pixels from the specified source device context into
/// <param name="nXDest">The leftmost x-coordinate of the destination rectangle (in pixels).</param>
/// <param name="nYDest">The topmost y-coordinate of the destination rectangle (in pixels).</param>
/// <param name="nWidth">The width of the source and destination rectangles (in pixels).</param>
/// <param name="nHeight">The height of the source and the destination rectangles (in pixels).</param>
/// <param name="nXSrc">The leftmost x-coordinate of the source rectangle (in pixels).</param>
/// <param name="nYSrc">The topmost y-coordinate of the source rectangle (in pixels).</param>
''' rectangle of pixels from the specified source device context into
''' <param name="nXDest">The leftmost x-coordinate of the destination rectangle (in pixels).</param>
''' <param name="nYDest">The topmost y-coordinate of the destination rectangle (in pixels).</param>
''' <param name="nWidth">The width of the source and destination rectangles (in pixels).</param>
''' <param name="nHeight">The height of the source and the destination rectangles (in pixels).</param>
''' <param name="nXSrc">The leftmost x-coordinate of the source rectangle (in pixels).</param>
''' <param name="nYSrc">The topmost y-coordinate of the source rectangle (in pixels).</param> If a rotation or shear transformation is in effect in the source device context, BitBlt returns an error. If other transformations exist in the source device context (and a matching transformation is not in effect in the destination device context), the rectangle in the destination device context is stretched, compressed, or rotated, as necessary. 4: Chord
static extern bool Chord(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nXRadial1, int nYRadial1,
Public Function Chord(ByVal hDc As IntPtr, ByVal nLeftRect As Integer, ByVal nTopRect As Integer,
ByVal nRightRect As Integer, ByVal nBottomRect As Integer, ByVal nXRadial1 As Integer, 6: CombineRgn
public static extern IntPtr CreateEllipticRgn(int nLeftRect, int nTopRect,int nRightRect, int nBottomRect);
static extern IntPtr CreateBrushIndirect([In] ref LOGBRUSH lplb); Private Shared Function CreateBrushIndirect( _ Private Declare Function CreateBrushIndirect Lib "gdi32"( _
static extern IntPtr CreateEllipticRgn(int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect); 10: CreateFont
static extern IntPtr CreateFontIndirect([In] ref LOGFONT lplf);
public static extern IntPtr CreateFontIndirect(
static extern IntPtr CreateFontIndirect([In] ref LOGFONT lplf);
public static extern IntPtr CreateFontIndirect(
drawingArea.FillRectangle(lGB, drawingArea.VisibleClipBounds) 13: CreateRectRgn
static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
Private Shared Function CreateRectRgn(ByVal nLeftRect As Integer, ByVal nTopRect As Integer, ByVal nRightRect As Integer, ByVal nBottomRect As Integer) As IntPtr
static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
FillRgn(wDc, CreateRectRgn(0,0,mx,my), brush);
static extern IntPtr CreateRoundRectRgn(int x1, int y1, int x2, int y2,
IntPtr _RegionHandle = CreateRoundRectRgn( 10, 10, 60, 60, 10, 10 ); 15: CreateSolidBrush
static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
FillRgn(wDc, CreateRectRgn(0,0,mx,my), brush); 16: DPtoLP POINT [] points = { new POINT(rect.Left, rect.Top), new POINT(rect.Right, rect.Bottom) }; 17: Ellipse
static extern bool Ellipse(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect);
Private Shared Function Ellipse(hdc As IntPtr, nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer) As Boolean 18: Escape
19: ExtFloodFill
vGraphics.DrawRectangle(Pens.Blue, new Rectangle(0, 0, 300, 300));
vGraphics.DrawRectangle(Pens.Blue, new Rectangle(50, 70, 300, 300)); 20: ExtTextOut
[In] ref RECT lprc, [MarshalAs(UnmanagedType.LPWStr)] string lpString, See RECT. 21: FillRgn
static extern IntPtr CreateRectRgn(int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect);
FillRgn(wDc, CreateRectRgn(0,0,mx,my), brush); 22: GetClipBox
static extern int GetClipBox(IntPtr hdc, out RECT lprc); 23: GetFontData
/// Gets the full name directly out of specified True Type font file.
// Get the correct name record
NameRecord nameRecord = SeekCorrectNameRecord(br, records);
/// Seeks the correct <see cref="NameRecord"/>.
/// <returns>The <see cref="NameRecord"/> providing access to the correct full font name.</returns>
private static NameRecord SeekCorrectNameRecord(BinaryReader br, int recordCount) 24: GetKerningPairs The only way I've been able to get ALL the kerning data is to parse the files directly; not easy to say the least. 25: GetRegionData
const int RDH_RECTANGLES = 1;
unsafe RECT[] RectsFromRegion(IntPtr hRgn)
RECT [] rects = null;
if (header->iType == RDH_RECTANGLES)
rects = new RECT[header->nCount];
// The rectangle data follows the header, so we offset the specified
// header size and start reading rectangles.
int rectOffset = header->dwSize;
// simple assignment from the buffer to our array of rectangles
rects[i] = *((RECT *)((byte *)bytes+rectOffset+(Marshal.SizeOf(typeof(RECT)) *i)));
// Return the rectangles
return rects; 26: GradientFill
GRADIENT_RECT[] pMesh, // array of gradient rectangles, that each one keeps two indices in pVertex array, to determine its bounds
uint dwNumMesh, // number of gradient rectangles to draw
GRADIENT_FILL dwMode); // Use either GRADIENT_FILL.RECT_H or GRADIENT_FILL.RECT_V. Using the value GRADIENT_FILL.TRIANGLE is wrong in this overload!
GRADIENT_FILL dwMode); // Use only GRADIENT_FILL.TRIANGLE. Both values GRADIENT_FILL.RECT_H and GRADIENT_FILL.RECT_V are wrong in this overload! This method creates one entry each for rectangles and triangles. It's just a matter of convenience and error checking by the compiler. 27: Pie
static extern bool Pie(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect,
int nBottomRect, int nXRadial1, int nYRadial1, int nXRadial2, int nYRadial2);
Private Shared Function Pie(hdc As IntPtr, nLeftRect%, nTopRect%, nRightRect%, nBottomRect%, nXRadial1%, nYRadial1%, nXRadial2%, nYRadial2%) As Boolean 28: PlayEnhMetaFile
static extern bool PlayEnhMetaFile(IntPtr hdc, IntPtr hemf, ref RECT lpRect); Changed lpRect from being an out parameter to a ref parameter. An out parameter will work in a debug build, but in a release build (with optimizations turned on) will not. Ref parameter works fine. 29: Rectangle
static extern bool Rectangle(IntPtr hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
Private Shared Function Rectangle(hdc As IntPtr, nLeftRect As Integer, nTopRect As Integer, nRightRect As Integer, nBottomRect As Integer) As Boolean 30: RectInRegion
31: RoundRect
static extern bool RoundRect(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nWidth, int nHeight);
public static extern bool RoundRect(RECT lpRect, Point point);
public static extern bool RoundRect(IntPtr hdc, int nLeftRect, int nTopRect,
int nRightRect, int nBottomRect, int nWidth, int nHeight);
DrawRoundRect(e.Graphics);
public void DrawRoundRect(Graphics gr)
RECT rect = new RECT(0, 0, this.Width, this.Height);
GDI32.RoundRect(hDC, 0, 0, this.Width, this.Height, 20, 20); 32: SelectClipRgn
IntPtr hRegion = CreateRectRgn(left, top, right, bottom); 33: SelectObject
/// <para>SIMPLEREGION - Region consists of a single rectangle.</para>
/// <para>COMPLEXREGION - Region consists of more than one rectangle.</para> 34: SetArcDirection
static extern int SetArcDirection(IntPtr hdc, int ArcDirection); There are two constants defining the direction. 35: SetMapMode
public static extern int Rectangle(IntPtr hDC, int nLeft, int nTop, int nRight, int nBottom); double fAspectRatio = (double)(this.ClientRectangle.Bottom) / (double)(this.ClientRectangle.Right);
this.ClientRectangle.Bottom, // So that (0,0) is at the bottom left.
this.ClientRectangle.Right,
-this.ClientRectangle.Bottom, // Negative so that y gets positive as you go up. // Draw a rectangle. Rectangle(hDC, 10, 25, 990, (int)(990 * fAspectRatio)); 36: SetTextColor
static extern int DrawText(IntPtr hdc, string lpStr, int nCount,ref Rect lpRect, int wFormat);
private struct Rect
public Rect(Rectangle r)
e.Graphics.FillRectangle(backcolorBrush, e.Bounds);
Rect bounds = new Rect(e.Bounds);
e.DrawFocusRectangle(); 37: TextOut [CharSet = CharSet.Auto] According to my experience this parameter should be used when using a LOGFONT structure and the CreateFontIndirect fuction, otherwise the selected font will not be displayed. All flags will be done (lfItalic, lfUnderline ...) but not the lfFaceName string. winspoolI believe the issue(s) discussed re:x64 is actually an odd idiosyncracy under Windows Server 2008 R2 x64, but is not a x86/x64 problem per se. At least testing this under Win7 x64, I have no issues. However, under W2K8 x64, the OutBuffer and InBuffer must NOT be the same (in Win7 x64 this works OK). ALSO, the call to set doc properties with fMode = 14 (Prompt | In | Out) and OutBuffer = IntPtr.Zero CANNOT possibly correct, as in this case there is no place to put the resulting Devmode. Good code shouldn't use "magic numbers" anyway. The following values from WinSpool.h should be used instead of "14" or "0" for the last parameter in this call: 39: DRIVER_INFO_6
/// A pointer to a null-terminated string that specifies a language monitor (for example, "PJL monitor"). This member can be NULL and should be specified only for printers capable of bidirectional communication. 40: EnumPorts
Redirected = 0x4, 41: GetPrinter
static extern bool GetPrinterDriverDirectory(StringBuilder pName,
GetPrinterDriverDirectory(null, null, 1, str, 1024, ref i); 42: GetPrinterDriver
static extern bool GetPrinterDriverDirectory(StringBuilder pName,
GetPrintProcessorDirectory(null, null, 1, str, 1024, ref i);
static extern bool GetPrinterDriverDirectory(StringBuilder pName,
GetPrintProcessorDirectory(null, null, 1, str, 1024, ref i); Gets the directory of the current PrinterProcessor.
static extern bool GetPrintProcessorDirectory(StringBuilder pName, StringBuilder pEnv, int Level, [Out] StringBuilder outPath, int bufferSize,
Declare Function GetPrintProcessorDirectory Lib "winspool.dll" (TODO) As TODO
static extern bool GetPrintProcessorDirectory(StringBuilder pName,
GetPrintProcessorDirectory(null, null, 1, str, 1024, ref length ); advapi3245: BackupEventLog
void SaveLog(string eventLogName, string destinationDirectory)
string exportedEventLogFileName = Path.Combine(destinationDirectory, eventLogName + ".evt"); As explained [here], memory for the returned unmanaged string must be freed by calling LocalFree. Therefore, you must define the string as an IntPtr in managed code and call LocalFree yourself. Otherwise, the marshaler would call CoTaskMemFree which is not correct in this case.
// Another C# Sample that converts a sid from a DirectoryEntry object
private string GetTextualSID(DirectoryEntry objGroup){
ManagementObject Share = new ManagementObject("Win32_Directory='" + ToPath + "'");
public static uint FILE_LIST_DIRECTORY = 0x1;
public static uint FILE_ADD_SUBDIRECTORY = 0x4;
string lpCurrentDirectory,
ByVal lpCurrentDirectory As String, _
String currentDirectory,
Public Function CreateProcessWithLogonW(ByVal userName As String, ByVal domain As String, ByVal password As String, ByVal logonFlags As UInt32, ByVal applicationName As String, ByVal commandLine As String, ByVal creationFlags As UInt32, ByVal environment As UInt32, ByVal currentDirectory As String, ByRef startupInfo As StartupInfo, ByRef processInformation As ProcessInformation) As Boolean
Public Function CreateProcessWithLogonW(ByVal userName As String, ByVal domain As String, ByVal password As String, ByVal logonFlags As UInt32, ByVal applicationName As String, ByVal commandLine As String, ByVal creationFlags As UInt32, ByVal environment As UInt32, ByVal currentDirectory As String, ByRef startupInfo As StartupInfo, ByRef processInformation As ProcessInformation) As Boolean
Dim currentDirectory As String = System.IO.Directory.GetCurrentDirectory()
currentDirectory, startupInfo, processInfo)
String currentDirectory,
String currentDirectory = System.IO.Directory.GetCurrentDirectory();
currentDirectory, 50: CreateService I changed the C# version from using "out uint lpdwTagId" to "string lpdwTagId". Without that change, the C# call to CreateService always returned an incorrect parameter error. 51: CryptSignHash
For Directories
System.Security.AccessControl.DirectorySecurity 53: GetSecurityInfo
Local or remote files or directories on an NTFS file system
Directory service objects
internal IntPtr RootDirectory;
lsaAttr.RootDirectory = IntPtr.Zero; 55: LsaLookupSids
internal IntPtr RootDirectory;
lsaAttr.RootDirectory = IntPtr.Zero; 56: LsaOpenPolicy I used a custom marshaler to live a happier life with the "own super special" string type that LSA uses. It marshals LSA_UNICODE_STRINGS to and from normal .NET strings. See "Alternate Sample Code" way below. However I'm quite new to p/invoke and this is my first custom marshaler ever, so please keep your eyes open for problems and bugs with my code. (A problem I had was CleanUpNativeData for data converted from managed to unmanaged aswell as for data converted from unmanaged to managed. Since I didn't allocate the data myself in the latter case my marshaler uses a hash table to keep track of the native data it allocated itself. Don't know if that's the correct way, however. Feel free to mail me at pi AT removethispart frohwalt removethisaswell DOT de for suggestions/corrections.
aObjectAttributes.RootDirectory = IntPtr.Zero;
ObjectAttributes.RootDirectory = IntPtr.Zero;
public IntPtr RootDirectory;
public IntPtr RootDirectory;
objectAttributes.RootDirectory = IntPtr.Zero; 58: RegEnumKeyEx
59: RegOpenKey - Changed IntPtr to UIntPtr: When invoking with IntPtr for the handles, you will run into an Overflow. UIntPtr is the right choice if you wish this to work correctly on 32 and 64 bit platforms.
' Create a new Registry key using the private constructor using the safeHandle - this should then behave like a .NET natively opened handle and disposed of correctly
Dim result = DirectCast(registryKeyConstructor.Invoke(New Object() {safeHandle, writable}), RegistryKey)
' Create a new Registry key using the private constructor using the safeHandle - this should then behave like a .NET natively opened handle and disposed of correctly
Dim result As Microsoft.Win32.RegistryKey = DirectCast(registryKeyConstructor.Invoke(New Object() {safeHandle, writable}), Microsoft.Win32.RegistryKey) To correct this, I changed the call to pointerToRegistryKey in openSubKey to pass true (ownsHandle). All code above is for versions of .NET Framework prior to 4.0. In version 4.0, Microsoft.Win32.SafeHandles.SafeRegistryHandle is now public instead of private causing the examples above to error. This was to added support for Microsoft.Win32.RegistryView which negates the need to directly call advapi32.dll and the RegOpenKeyEx function by making the process managed. Here are examples of how to access 32-bit registry keys from a 64-bit application using .NET Framework 4.0: 60: RegOpenKeyEx - Changed IntPtr to UIntPtr: When invoking with IntPtr for the handles, you will run into an Overflow. UIntPtr is the right choice if you wish this to work correctly on 32 and 64 bit platforms.
' Create a new Registry key using the private constructor using the safeHandle - this should then behave like a .NET natively opened handle and disposed of correctly
Dim result = DirectCast(registryKeyConstructor.Invoke(New Object() {safeHandle, writable}), RegistryKey)
' Create a new Registry key using the private constructor using the safeHandle - this should then behave like a .NET natively opened handle and disposed of correctly
Dim result As Microsoft.Win32.RegistryKey = DirectCast(registryKeyConstructor.Invoke(New Object() {safeHandle, writable}), Microsoft.Win32.RegistryKey) All code above is for versions of .NET Framework prior to 4.0. In version 4.0, Microsoft.Win32.SafeHandles.SafeRegistryHandle is now public instead of private causing the examples above to error. This was to added support for Microsoft.Win32.RegistryView which negates the need to directly call advapi32.dll and the RegOpenKeyEx function by making the process managed. Here are examples of how to access 32-bit registry keys from a 64-bit application using .NET Framework 4.0: Cut off search results after 60. Please refine your search. |