private unsafe bool GetCalendarGridInfoText(MCGIP dwPart, int calendarIndex, int row, int column, out string text) { const int nameLength = 128; Span <char> name = stackalloc char[nameLength + 2]; bool result; fixed(char *pName = name) { var gridInfo = new MCGRIDINFO { cbSize = (uint)sizeof(MCGRIDINFO), dwFlags = MCGIF.NAME, dwPart = dwPart, iCalendar = calendarIndex, iCol = column, iRow = row, pszName = pName, cchName = (uint)name.Length - 1 }; result = User32.SendMessageW(_owner, (User32.WM)MCM.GETCALENDARGRIDINFO, IntPtr.Zero, ref gridInfo) != IntPtr.Zero; } text = name.SliceAtFirstNull().ToString(); return(result); }
private unsafe bool GetCalendarGridInfo( MCGIF dwFlags, MCGIP dwPart, int calendarIndex, int row, int column, out RECT rectangle, out Kernel32.SYSTEMTIME endDate, out Kernel32.SYSTEMTIME startDate) { Debug.Assert( (dwFlags & ~(MCGIF.DATE | MCGIF.RECT)) == 0, "GetCalendarGridInfo() should be used only to obtain Date and Rect," + "dwFlags has flag bits other that MCGIF_DATE and MCGIF_RECT"); var gridInfo = new MCGRIDINFO { cbSize = (uint)sizeof(MCGRIDINFO), dwFlags = dwFlags, dwPart = dwPart, iCalendar = calendarIndex, iCol = column, iRow = row }; try { bool result = GetCalendarGridInfo(ref gridInfo); rectangle = gridInfo.rc; endDate = gridInfo.stEnd; startDate = gridInfo.stStart; return(result); } catch { rectangle = new RECT(); endDate = new Kernel32.SYSTEMTIME(); startDate = new Kernel32.SYSTEMTIME(); return(false); } }
public bool GetCalendarPartRectangle(int calendarIndex, MCGIP dwPart, int row, int column, out RECT calendarPartRectangle) { bool success = GetCalendarGridInfo( MCGIF.RECT, dwPart, calendarIndex, row, column, out calendarPartRectangle, out Kernel32.SYSTEMTIME endDate, out Kernel32.SYSTEMTIME startDate); if (success) { success = User32.MapWindowPoints(new HandleRef(this, Owner.Handle), new HandleRef(null, IntPtr.Zero), ref calendarPartRectangle, 2) != 0; } if (!success) { calendarPartRectangle = new RECT(); } return(success); }