예제 #1
0
 public static extern int PropertySheet([In, MarshalAs(UnmanagedType.Struct)] ref PropSheetHeader psh);
예제 #2
0
 /// <summary>
 /// Display only the specified property pages.
 /// </summary>
 /// <remarks>
 /// See the <see cref="DisplayPropertySheet()"/>() overload.
 /// </remarks>
 /// <param name="pages">Controls which pages are presented</param>
 /// <returns><c>true</c> if dialog box was dismissed with OK, otherwise <c>false</c>.</returns>
 public bool DisplayPropertySheet(PropPages pages)
 {
     PropSheetHeader hdr = new PropSheetHeader();
     IProvideTaskPage iProvideTaskPage = (IProvideTaskPage)iTask;
     IntPtr[] hPages = new IntPtr[3];
     IntPtr hPage;
     int nPages = 0;
     if ((pages & PropPages.Task) != 0) {
         //get task page
         iProvideTaskPage.GetPage(0, false, out hPage);
         hPages[nPages++] = hPage;
     }
     if ((pages & PropPages.Schedule) != 0) {
         //get task page
         iProvideTaskPage.GetPage(1, false, out hPage);
         hPages[nPages++] = hPage;
     }
     if ((pages & PropPages.Settings) != 0) {
         //get task page
         iProvideTaskPage.GetPage(2, false, out hPage);
         hPages[nPages++] = hPage;
     }
     if (nPages == 0) throw (new ArgumentException("No Property Pages to display"));
     hdr.dwSize = (uint)Marshal.SizeOf(hdr);
     hdr.dwFlags = (uint) (PropSheetFlags.PSH_DEFAULT | PropSheetFlags.PSH_NOAPPLYNOW);
     hdr.pszCaption = this.Name;
     hdr.nPages = (uint)nPages;
     GCHandle gch = GCHandle.Alloc(hPages, GCHandleType.Pinned);
     hdr.phpage = gch.AddrOfPinnedObject();
     int res = PropertySheetDisplay.PropertySheet(ref hdr);
     gch.Free();
     if (res < 0) throw (new Exception("Property Sheet failed to display"));
     return res>0;
 }