Ignore:
Timestamp:
Nov 2, 1999, 10:44:04 PM (26 years ago)
Author:
achimha
Message:

comctl32 merged with WINE 991031

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/comctl32/propsheet.c

    r1402 r1565  
    1 /* $Id: propsheet.c,v 1.10 1999-10-22 18:04:11 sandervl Exp $ */
     1/* $Id: propsheet.c,v 1.11 1999-11-02 21:44:02 achimha Exp $ */
    22/*
    33 * Property Sheets
     
    1313 */
    1414
    15 /* WINE 990923 level */
     15/* WINE 991031 level */
    1616
    1717/* CB: Odin problems:
     
    117117static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText);
    118118static void PROPSHEET_SetTitleA(HWND hwndDlg, DWORD dwStyle, LPCSTR lpszText);
     119static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg);
    119120static BOOL PROPSHEET_SetCurSel(HWND hwndDlg,
    120121                                int index,
     
    214215    HGLOBAL hTemplate = LoadResource(lppsp->hInstance,
    215216                                     hResource);
    216      pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
     217    pTemplate = (LPDLGTEMPLATEA)LockResource(hTemplate);
    217218  }
    218219
     
    265266      p += lstrlenW( (LPCWSTR)p ) + 1;
    266267      break;
    267   }
     268  } 
    268269
    269270  /* class */
     
    283284  /* Extract the caption */
    284285  psInfo->proppage[index].pszText = (LPCWSTR)p;
    285 //  TRACE(propsheet, "Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
     286//  TRACE("Tab %d %s\n",index,debugstr_w((LPCWSTR)p));
    286287  p += lstrlenW((LPCWSTR)p) + 1;
    287288
    288289  if (dwFlags & PSP_USETITLE)
    289290  {
    290 //AH: todo
    291 //    psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
    292 //                                                      0,
    293 //                                                      lppsp->pszTitle);
     291    if ( !HIWORD( lppsp->pszTitle ) )
     292    {
     293      char szTitle[256];
     294     
     295      if ( !LoadStringA( lppsp->hInstance, (UINT) lppsp->pszTitle, szTitle, 256 ) )
     296        return FALSE;
     297
     298//AH: TODO     
     299//      psInfo->proppage[index].pszText = HEAP_strdupAtoW( GetProcessHeap(),
     300//                                                       0, szTitle );
     301    }
     302//AH: TODO
     303//    else
     304//      psInfo->proppage[index].pszText = HEAP_strdupAtoW(GetProcessHeap(),
     305//                                                      0,
     306//                                                      lppsp->pszTitle);
    294307  }
    295308
     
    297310   * Build the image list for icons
    298311   */
    299   if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID))
     312  if ((dwFlags & PSP_USEHICON) || (dwFlags & PSP_USEICONID)) 
    300313  {
    301314    HICON hIcon;
     
    876889  PropPageInfo* ppInfo = psInfo->proppage;
    877890  PADDING_INFO padding;
    878   HWND hwndAfter;
    879 
    880 //  TRACE(propsheet, "index %d\n", index);
     891
     892  TRACE("index %d\n", index);
    881893
    882894  if (ppshpage->dwFlags & PSP_DLGINDIRECT)
     
    908920    pTemplate->style &= ~WS_POPUP;
    909921    pTemplate->style &= ~WS_DISABLED;
    910 
    911922  }
    912923
     
    917928
    918929  hwndPage = CreateDialogIndirectParamA(ppshpage->hInstance,
    919                                         pTemplate,
    920                                         hwndParent,
    921                                         ppshpage->pfnDlgProc,
    922                                         (LPARAM)ppshpage);
     930                                        pTemplate,
     931                                        hwndParent,
     932                                        ppshpage->pfnDlgProc,
     933                                        (LPARAM)ppshpage);
    923934
    924935  ppInfo[index].hwndPage = hwndPage;
     
    932943
    933944  if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
    934   {
    935     GetWindowRect(hwndParent, &rc);
    936945    padding = PROPSHEET_GetPaddingInfoWizard(hwndParent);
    937     hwndAfter = hwndParent;
    938   }
    939946  else
    940947  {
     
    946953    SendMessageA(hwndTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM)&rc);
    947954    padding = PROPSHEET_GetPaddingInfo(hwndParent);
    948     hwndAfter = HWND_TOP;
    949   }
    950 
    951   SetWindowPos(hwndPage, hwndAfter,
     955  }
     956
     957  SetWindowPos(hwndPage, HWND_TOP,
    952958               rc.left + padding.x,
    953959               rc.top + padding.y,
     
    10381044                                                    PropSheetInfoStr);
    10391045
     1046  hdr.hwndFrom = hwndDlg;
    10401047  hdr.code = PSN_WIZNEXT;
    10411048
     
    10441051  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    10451052
    1046 //  TRACE("msg result %ld\n", msgResult);
     1053  TRACE("msg result %ld\n", msgResult);
    10471054
    10481055  if (msgResult == -1)
    10491056    return FALSE;
    10501057
    1051   PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
     1058  if(PROPSHEET_CanSetCurSel(hwndDlg) != FALSE)
     1059  {
     1060    PROPSHEET_SetCurSel(hwndDlg, psInfo->active_page + 1, 0);
     1061  }
    10521062
    10531063  return TRUE;
     
    10651075                                                    PropSheetInfoStr);
    10661076
     1077  hdr.hwndFrom = hwndDlg;
    10671078  hdr.code = PSN_WIZFINISH;
    10681079
     
    10711082  msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    10721083
    1073 //  TRACE("msg result %ld\n", msgResult);
     1084  TRACE("msg result %ld\n", msgResult);
    10741085
    10751086  if (msgResult != 0)
     
    12061217  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
    12071218                                                    PropSheetInfoStr);
    1208 
     1219  if ( !psInfo ) return;
    12091220  for (i = 0; i < psInfo->nPages; i++)
    12101221  {
     
    12591270}
    12601271
     1272/*************************************************************************
     1273 * BOOL PROPSHEET_CanSetCurSel [Internal]
     1274 *
     1275 * Test weither the current page can be changed by sending a PSN_KILLACTIVE
     1276 *
     1277 * PARAMS
     1278 *     hwndDlg        [I] handle to a Dialog hWnd
     1279 *
     1280 * RETURNS
     1281 *     TRUE if Current Selection can change
     1282 *
     1283 * NOTES
     1284 */
     1285static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg)
     1286{
     1287  PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwndDlg,
     1288                                                    PropSheetInfoStr);
     1289  HWND hwndPage;
     1290  NMHDR hdr;
     1291
     1292  if (!psInfo)
     1293    return FALSE;
     1294
     1295  /*
     1296   * Notify the current page.
     1297   */
     1298  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
     1299
     1300  hdr.hwndFrom = hwndDlg;
     1301  hdr.code = PSN_KILLACTIVE;
     1302
     1303  return !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     1304}
     1305
    12611306/******************************************************************************
    12621307 *            PROPSHEET_SetCurSel
     
    12721317  NMHDR hdr;
    12731318
    1274   /*
    1275    * Notify the current page.
    1276    */
    12771319  hwndPage = psInfo->proppage[psInfo->active_page].hwndPage;
    12781320
    12791321  hdr.hwndFrom = hwndDlg;
    1280   hdr.code = PSN_KILLACTIVE;
    1281 
    1282   if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr))
    1283     return FALSE;
    1284 
    12851322  /*
    12861323   * hpage takes precedence over index.
     
    12921329    if (index == -1)
    12931330    {
    1294       //TRACE("Could not find page to remove!\n");
     1331      TRACE("Could not find page to remove!\n");
    12951332      return FALSE;
    12961333    }
     
    13101347    result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
    13111348    /*
    1312      * TODO: check return value.
     1349     * TODO: check return value. 
    13131350     */
    13141351  }
     
    14691506  psInfo->nPages++;
    14701507
    1471   return FALSE;
     1508  return TRUE;
    14721509}
    14731510
     
    14821519                                                     PropSheetInfoStr);
    14831520  HWND hwndTabControl = GetDlgItem(hwndDlg, IDC_TABCONTROL);
    1484   PropPageInfo* oldPages = psInfo->proppage;
    1485 
     1521  PropPageInfo* oldPages;
     1522
     1523  if (!psInfo) {
     1524    FIXME("No psInfo for propertysheet at windows 0x%04x, returning FALSE...\n", hwndDlg);
     1525    return FALSE;
     1526  }
     1527  oldPages = psInfo->proppage;
    14861528  /*
    14871529   * hpage takes precedence over index.
     
    14901532  {
    14911533    index = PROPSHEET_GetPageIndex(hpage, psInfo);
    1492 
    1493     if (index == -1)
     1534  }
     1535
     1536  /* Make shure that index is within range */
     1537  if (index < 0 || index >= psInfo->nPages)
    14941538    {
    1495 //      TRACE(propsheet, "Could not find page to remove!\n");
     1539      TRACE("Could not find page to remove!\n");
    14961540      return FALSE;
    14971541    }
    1498   }
    1499 
    1500 //  TRACE(propsheet, "total pages %d removing page %d active page %d\n",
    1501 //        psInfo->nPages, index, psInfo->active_page);
     1542
     1543  TRACE("total pages %d removing page %d active page %d\n",
     1544        psInfo->nPages, index, psInfo->active_page);
    15021545  /*
    15031546   * Check if we're removing the active page.
     
    15201563    else
    15211564    {
    1522 //      TRACE(propsheet, "Removing the only page, close the dialog!\n");
     1565      TRACE("Removing the only page, close the dialog!\n");
    15231566
    15241567      if (psInfo->isModeless)
     
    15341577    psInfo->active_page--;
    15351578
     1579  /* Destroy page dialog window.
     1580   * If it's last page in modal dialog, it has been destroyed by EndDialog
     1581   */
     1582  if (psInfo->isModeless || psInfo->nPages > 1)
     1583     DestroyWindow(psInfo->proppage[index].hwndPage);
     1584 
    15361585  /* Remove the tab */
    15371586  SendMessageA(hwndTabControl, TCM_DELETEITEM, index, 0);
     
    15401589  psInfo->proppage = COMCTL32_Alloc(sizeof(PropPageInfo) * psInfo->nPages);
    15411590
    1542   if (index > 0)
     1591  if (index > 0) 
    15431592    memcpy(&psInfo->proppage[0], &oldPages[0], index * sizeof(PropPageInfo));
    15441593
     
    17641813      GetWindowTextA(hwnd, psInfo->strPropertiesFor, MAX_CAPTION_LENGTH);
    17651814
     1815      PROPSHEET_CreateTabControl(hwnd, psInfo);
     1816
    17661817      if (psInfo->ppshheader->dwFlags & PSH_WIZARD)
    17671818      {
     
    17801831      else
    17811832      {
    1782         PROPSHEET_CreateTabControl(hwnd, psInfo);
    1783 
    17841833        if (PROPSHEET_IsTooSmall(hwnd, psInfo))
    17851834        {
     
    17891838      }
    17901839
     1840      if (psInfo->useCallback)
     1841             (*(psInfo->ppshheader->pfnCallback))(hwnd,
     1842                                              PSCB_INITIALIZED, (LPARAM)0);
     1843
    17911844      ppshpage = PROPSHEET_GetPSPPage(psInfo, psInfo->active_page);     
    17921845      PROPSHEET_CreatePage(hwnd, psInfo->active_page, psInfo, ppshpage, TRUE);
     
    17971850      SetPropA(hwnd, PropSheetInfoStr, (HANDLE)psInfo);
    17981851
    1799       PROPSHEET_SetTitleA(hwnd,
    1800                           psInfo->ppshheader->dwFlags,
    1801                           psInfo->ppshheader->pszCaption);
     1852
     1853      if (!HIWORD(psInfo->ppshheader->pszCaption) &&
     1854              psInfo->ppshheader->hInstance)
     1855      {
     1856         char szText[256];
     1857
     1858         if (LoadStringA(psInfo->ppshheader->hInstance,
     1859                 (UINT)psInfo->ppshheader->pszCaption, szText, 255))
     1860            PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags, szText);
     1861      }
     1862      else
     1863      {
     1864         PROPSHEET_SetTitleA(hwnd, psInfo->ppshheader->dwFlags,
     1865                         psInfo->ppshheader->pszCaption);
     1866      }
    18021867
    18031868      return TRUE;
     
    18841949      }
    18851950
     1951      if(pnmh->code == TCN_SELCHANGING)
     1952      {
     1953        BOOL bRet = PROPSHEET_CanSetCurSel(hwnd);
     1954        SetWindowLongA(hwnd, DWL_MSGRESULT, !bRet);
     1955        return TRUE;
     1956      }
     1957
     1958
    18861959      return 0;
    18871960    }
     
    19221995      BOOL msgResult;
    19231996
    1924       msgResult = PROPSHEET_SetCurSel(hwnd,
    1925                                       (int)wParam,
    1926                                       (HPROPSHEETPAGE)lParam);
     1997      msgResult = PROPSHEET_CanSetCurSel(hwnd);
     1998      if(msgResult != FALSE)
     1999      {
     2000        msgResult = PROPSHEET_SetCurSel(hwnd,
     2001                                       (int)wParam,
     2002                                       (HPROPSHEETPAGE)lParam);
     2003      }
    19272004
    19282005      SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
     
    19832060
    19842061    case PSM_ADDPAGE:
    1985       PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
     2062    {
     2063      /*
     2064       * Note: MSVC++ 6.0 documentation says that PSM_ADDPAGE does not have
     2065       *       a return value. This is not true. PSM_ADDPAGE returns TRUE
     2066       *       on success or FALSE otherwise, as specified on MSDN Online.
     2067       *       Also see the MFC code for
     2068       *       CPropertySheet::AddPage(CPropertyPage* pPage).
     2069       */
     2070
     2071      BOOL msgResult = PROPSHEET_AddPage(hwnd, (HPROPSHEETPAGE)lParam);
     2072
     2073      SetWindowLongA(hwnd, DWL_MSGRESULT, msgResult);
     2074
    19862075      return TRUE;
     2076    }
    19872077
    19882078    case PSM_REMOVEPAGE:
     
    19922082    case PSM_ISDIALOGMESSAGE:
    19932083    {
    1994 //      FIXME("Unimplemented msg PSM_ISDIALOGMESSAGE\n");
     2084      FIXME("Unimplemented msg PSM_ISDIALOGMESSAGE\n");
    19952085      return 0;
    19962086    }
     
    20092099
    20102100    case PSM_SETTITLEW:
    2011 //        FIXME("Unimplemented msg PSM_SETTITLE32W\n");
     2101        FIXME("Unimplemented msg PSM_SETTITLE32W\n");
    20122102        return 0;
    20132103    case PSM_SETCURSELID:
    2014 //        FIXME("Unimplemented msg PSM_SETCURSELID\n");
     2104        FIXME("Unimplemented msg PSM_SETCURSELID\n");
    20152105        return 0;
    20162106    case PSM_SETFINISHTEXTW:
    2017 //        FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
     2107        FIXME("Unimplemented msg PSM_SETFINISHTEXT32W\n");
    20182108        return 0;
    20192109
Note: See TracChangeset for help on using the changeset viewer.