Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
propdlg.c
Package: shell.rar [view]
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 134k
Category:
Windows Kernel
Development Platform:
Visual C++
- SetWindowLongPtr( hDlg, DWLP_MSGRESULT, PSNRET_INVALID_NOCHANGEPAGE );
- return TRUE;
- }
- }
- return PSNRET_NOERROR;
- case PSN_RESET :
- if (lpallobjs->fPropDlgChanged && !lpallobjs->fPropDlgPrompted)
- {
- // BUGBUG typo here but I don't know what the author wanted
- if (ISavePropDlgChanges(lpallobjs, hDlg, ((NMHDR FAR *)lParam)->hwndFrom) != IDNO);
- return(TRUE);
- }
- // User cancelled the changes, so just delete the tmp stuff.
- FSwapTmpUDProps (lpallobjs->lpUDObj);
- FDeleteTmpUDProps (lpallobjs->lpUDObj);
- return TRUE;
- case PSN_SETACTIVE :
- return TRUE;
- default:
- break;
- } // switch
- break;
- case WM_CONTEXTMENU:
- WinHelp((HANDLE)wParam, NULL, HELP_CONTEXTMENU, (DWORD_PTR)rgIdhCustom);
- break;
- case WM_HELP:
- WinHelp(((LPHELPINFO)lParam)->hItemHandle, NULL, HELP_WM_HELP, (DWORD_PTR)rgIdhCustom);
- break;
- } // switch
- return FALSE;
- } // FCustomDlgProc
- //
- // FGetCustomPropFromDlg
- //
- // Purpose: To get a custom property from the dialog.
- // I.e. the user hit Add/Modify.
- //
- BOOL FGetCustomPropFromDlg(LPALLOBJS lpallobjs, HWND hDlg)
- {
- UDTYPES udtype;
- NUM dbl;
- LPVOID lpv;
- int iItemT;
- LPTSTR lpstzName;
- LPVOID lpvSaveAsDword;
- DWORD cch;
- BOOL f;
- lpstzName = NULL;
- cch = 0;
- if (FAllocAndGetValLpstz (hDlg, IDD_CUSTOM_NAME, &glpstzName))
- {
- LPUDPROP lpudp;
- #ifdef __CUSTOM_LINK_ENABLED__
- lpallobjs->CDP_fLink = SendDlgItemMessage(hDlg, IDD_CUSTOM_LINK, BM_GETCHECK, 0, 0);
- #else
- lpallobjs->CDP_fLink = FALSE; // just to be sure.
- #endif __CUSTOM_LINK_ENABLED__
- Assert(lpallobjs->CDP_fLink == TRUE || lpallobjs->CDP_fLink == FALSE);
- // HACK: If the user enters a name that is already
- // a property name, the default action of the object
- // is to replace the data, treating it as an update.
- // This will cause there to be 2 names in the listview
- // though unless we just update the original one. So, first
- // see if the new name is in the list already, and if
- // it is, find it in the listview and set up to update it.
- lpudp = LpudpropFindMatchingName (lpallobjs->lpUDObj, (LPTSTR)PSTR (glpstzName));
- if (lpudp != NULL)
- {
- LV_FINDINFO lvfi;
- lvfi.flags = LVFI_STRING;
- lvfi.psz = (LPTSTR) PSTR (glpstzName);
- iItemT = ListView_FindItem (lpallobjs->CDP_hWndCustomLV, -1, &lvfi);
- // If the property is being modified and the link
- // box is not checked, we need to remove the link
- // data and the IMoniker from the object.
- // if (!lpallobjs->CDP_fLink)
- // {
- // FUserDefAddProp (lpallobjs->lpUDObj, PSTR (glpstzName), NULL,
- // wUDlpsz, TRUE, FALSE, FALSE);
- // FUserDefAddProp (lpallobjs->lpUDObj, PSTR (glpstzName), NULL,
- // wUDlpsz, FALSE, FALSE, TRUE);
- // }
- }
- else
- iItemT = -1;
- // Let's get the type, since this might be a MODIFY case
- lpallobjs->CDP_iszType = (int)SendMessage(lpallobjs->CDP_hWndType, CB_GETCURSEL,0, 0);
- // If the user has checked the link box, then the value
- // must come from the client.
- if (lpallobjs->CDP_fLink)
- {
- DWORD irg;
- // Get the link name from the combobox, and store
- // the link name and static value.
- irg = (int)SendMessage (lpallobjs->CDP_hWndLinkVal, CB_GETCURSEL, 0, 0);
- Assert ((lpallobjs->lpfnDwQueryLinkData != NULL));
- Assert (((irg < lpallobjs->CDP_cLinks) && (irg >= 0)));
- cch = (DWORD)SendMessage (lpallobjs->CDP_hWndLinkVal, CB_GETLBTEXTLEN, irg, 0)+1; // Include the null-terminator
- if (!FAllocString (&lpstzName, cch))
- return(FALSE);
- SendMessage (lpallobjs->CDP_hWndLinkVal, CB_GETLBTEXT, irg, (LPARAM) PSTR (lpstzName));
- // Set up the static type and value for display
- // in the listbox
- udtype = (UDTYPES) (*lpallobjs->lpfnDwQueryLinkData) (QLD_LINKTYPE, irg, NULL, (LPTSTR)PSTR (lpstzName));
- (*lpallobjs->lpfnDwQueryLinkData) (QLD_LINKVAL, irg, &lpv, (LPTSTR)PSTR (lpstzName));
- //
- // HACK alert
- //
- // We want lpv to point to the value, not to be overloaded in the case of a dword or bool.
- //
- if ((udtype == wUDdw) || (udtype == wUDbool))
- {
- lpvSaveAsDword = lpv; // Really a DWORD
- lpv = &lpvSaveAsDword;
- }
- // Add the link name itself to the object
- // FUserDefAddProp (lpallobjs->lpUDObj, PSTR (glpstzName), PSTR (lpstzName),
- // wUDlpsz, TRUE, FALSE, FALSE);
- } // if (lpallobjs->CDP_fLink)
- else
- {
- if (lpallobjs->CDP_iszType != iszBOOL)
- {
- if (!FAllocAndGetValLpstz (hDlg, IDD_CUSTOM_VALUE, &glpstzValue))
- return(FALSE);
- }
- // Convert the type in the combobox to a UDTYPES
- switch (lpallobjs->CDP_iszType)
- {
- case iszTEXT :
- udtype = wUDlpsz;
- (LPTSTR) lpv = (LPTSTR)PSTR (glpstzValue);
- break;
- case iszNUM :
- udtype = UdtypesGetNumberType (glpstzValue, &dbl,
- ((LPUDINFO)lpallobjs->lpUDObj->m_lpData)->lpfnFSzToNum);
- switch (udtype)
- {
- case wUDdw :
- lpv = (DWORD *) &dbl;
- break;
- case wUDfloat :
- (NUM *) lpv = &dbl;
- break;
- default :
- (LPTSTR) lpv = (LPTSTR)PSTR (glpstzValue);
- // If the user doesn't want to convert the value to text, they can press "Cancel" and try again.
- if (FDisplayConversionWarning (hDlg))
- {
- SetFocus(lpallobjs->CDP_hWndType);
- return(FALSE);
- }
- udtype = wUDlpsz;
- } // switch (udtype)
- break;
- case iszDATE :
- if (FConvertDate (glpstzValue, (LPFILETIME) &dbl))
- {
- udtype = wUDdate;
- (NUM *) lpv = &dbl;
- }
- else
- {
- udtype = wUDlpsz;
- (LPTSTR) lpv = (LPTSTR)PSTR (glpstzValue);
- // If the user doesn't want to convert the value to text, they can press "Cancel" and try again.
- if (FDisplayConversionWarning (hDlg))
- {
- SetFocus(lpallobjs->CDP_hWndType);
- return(FALSE);
- }
- }
- break;
- case iszBOOL :
- {
- udtype = wUDbool;
- f = (BOOL)(SendMessage (lpallobjs->CDP_hWndBoolTrue, BM_GETSTATE, 0, 0) & BST_CHECKED);
- lpv = &f;
- break;
- }
- default :
- AssertSz (0,TEXT("IDD_CUSTOM_TYPE combobox is whacked!"));
- udtype = wUDinvalid;
- } // switch (lpallobjs->CDP_iszType)
- } // if (lpallobjs->CDP_fLink) ... else
- // If we got valid input, add the property to the object
- // and listbox.
- if (udtype != wUDinvalid)
- {
- // The PropVariant created when we add this property.
- LPPROPVARIANT lppropvar = NULL;
- // The link data (link name itself) would have
- // been stored above if the property was a link.
- // This stores the static value that will eventually
- // appear in the list view.
- lppropvar = LppropvarUserDefAddProp (lpallobjs->lpUDObj, glpstzName, lpv, udtype,
- (lpstzName != NULL) ? lpstzName : NULL,
- (lpstzName != NULL) ? TRUE : FALSE, FALSE);
- // HACK alert
- //
- // Here we want lpv be overloaded in the case of a dword or bool, since
- // AddUDPropToListView calls WUdtypeToSz which assumes lpv is overloaded.
- //
- if ((udtype == wUDdw) || (udtype == wUDbool))
- {
- lpv = *(LPVOID *)lpv;
- }
- AddUDPropToListView (lpallobjs->lpUDObj, lpallobjs->CDP_hWndCustomLV, (LPTSTR)PSTR (glpstzName), lppropvar, iItemT, lpallobjs->CDP_fLink, fTrue, fTrue);
- // For links, dealloc the buffer.
- if (lpallobjs->CDP_fLink)
- DeallocValue (&lpv, udtype);
- // Clear out the edit fields and disable the Add button again
- SetCustomDlgDefButton(hDlg, gOKButtonID);
- EnableWindow (lpallobjs->CDP_hWndAdd, FALSE);
- SendMessage(lpallobjs->CDP_hWndName, CB_SETEDITSEL, 0, MAKELPARAM(0,-1)); // Select entire string
- SendMessage(lpallobjs->CDP_hWndName, WM_CLEAR, 0, 0);
- EnableWindow (lpallobjs->CDP_hWndDelete, FALSE);
- // See bug 213
- // if (fLink)
- // {
- // fLink = !fLink;
- // SendDlgItemMessage (hDlg, IDD_CUSTOM_LINK, BM_SETCHECK, (WPARAM) fLink, 0);
- // }
- FSwapControls (lpallobjs->CDP_hWndVal, lpallobjs->CDP_hWndLinkVal,
- lpallobjs->CDP_hWndBoolTrue, lpallobjs->CDP_hWndBoolFalse,
- lpallobjs->CDP_hWndGroup, lpallobjs->CDP_hWndType,
- lpallobjs->CDP_hWndValText, lpallobjs->CDP_fLink, lpallobjs->CDP_iszType == iszBOOL);
- FSetupAddButton (lpallobjs->CDP_iszType, lpallobjs->CDP_fLink, &lpallobjs->CDP_fAdd, lpallobjs->CDP_hWndAdd, lpallobjs->CDP_hWndVal, lpallobjs->CDP_hWndName, hDlg);
- // wUDbool doesn't use the edit control....
- if (lpallobjs->CDP_iszType != iszBOOL)
- ClearEditControl (lpallobjs->CDP_hWndVal, 0);
- } // if (udtype != wUDinvalid)
- SendDlgItemMessage(hDlg, IDD_CUSTOM_TYPE, CB_SETCURSEL, lpallobjs->CDP_iszType,0);
- SetFocus(lpallobjs->CDP_hWndName);
- // lpallobjs->fPropDlgChanged = TRUE;
- if (lpstzName != NULL)
- VFreeMemP(lpstzName, CBTSTR (lpstzName));
- return(TRUE);
- }
- return(FALSE);
- }
- /////////////////////////////////////////////////////////////////////////
- //
- // SetCustomDlgDefButton
- //
- // Set the new default button
- //
- /////////////////////////////////////////////////////////////////////////
- VOID SetCustomDlgDefButton(HWND hDlg, int IDNew)
- {
- int IDOld;
- if ((IDOld = LOWORD(SendMessage(hDlg, DM_GETDEFID, 0L, 0L))) != IDNew)
- {
- // Set the new default push button's control ID.
- SendMessage(hDlg, DM_SETDEFID, IDNew, 0L);
- // Set the new style.
- SendDlgItemMessage(hDlg, IDNew, BM_SETSTYLE, BS_DEFPUSHBUTTON, MAKELPARAM(TRUE,0));
- SendDlgItemMessage(hDlg, IDOld, BM_SETSTYLE, BS_PUSHBUTTON, MAKELPARAM(TRUE,0));
- }
- }
- #ifdef OFFICE_96
- ////////////////////////////////////////////////////////////////////////////////
- //
- // ListViewCompareFunc
- //
- // Purpose:
- // Compares two items in a listview
- // We only sort the name column.
- //
- // Returns
- // A negative value if item 1 should come before item 2
- // A positive value if item 1 should come after item 2
- // Zero if the two items are equivalent
- //
- ////////////////////////////////////////////////////////////////////////////////
- int CALLBACK ListViewCompareFunc
- (
- LPARAM lParam1, // lParam of the LV_ITEM struct (property name)
- LPARAM lParam2, // lParam of the LV_ITEM struct (property name)
- LPARAM lParamSort) // Index of column to sore
- {
- return(lstrcmp((LPTSTR)lParam1, (LPTSTR)lParam2));
- }
- #endif
- ////////////////////////////////////////////////////////////////////////////////
- //
- // PrintTimeInDlg
- //
- // Purpose:
- // Prints the locale-specific time representation in control in the dialog.
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef _WIN2000_DOCPROP_
- void PASCAL
- PrintTimeInDlg (
- HWND hDlg, // Dialog handle
- DWORD dwId, // Control id
- LPFILETIME lpft) // The time
- {
- SYSTEMTIME st;
- TCHAR szBuf[80], szTmp[64];
- const TCHAR *c_szSpace = TEXT(" ");
- if ((lpft != NULL) && (lpft->dwLowDateTime != 0) && (lpft->dwHighDateTime != 0))
- {
- FILETIME ft;
- FileTimeToLocalFileTime(lpft, &ft); // get in local time
- FileTimeToSystemTime(&ft, &st);
- GetDateFormat(LOCALE_USER_DEFAULT, DATE_LONGDATE, &st, NULL, szBuf,ARRAYSIZE(szBuf));
- // BUGBUG: this doesn't handle international: time may need to come first
- // don't bother with the time if it is NULL
- if (st.wHour || st.wMinute || st.wSecond)
- {
- lstrcat(szBuf, c_szSpace);
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, NULL, szTmp, ARRAYSIZE(szTmp));
- lstrcat(szBuf, szTmp);
- }
- SetDlgItemText(hDlg, dwId, szBuf);
- }
- } // PrintTimeInDlg
- #endif //_WIN2000_DOCPROP_
- ////////////////////////////////////////////////////////////////////////////////
- //
- // PrintEditTimeInDlg
- //
- // Purpose:
- // Prints the total edit time in the dialog.
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef _WIN2000_DOCPROP_
- void PASCAL PrintEditTimeInDlg (
- HWND hDlg, // Dialog handle
- LPFILETIME lpft) // The time
- {
- TCHAR sz[100];
- // Remember that the 64 bit number in lpft is units of 100ns
- VFtToSz(lpft, sz, ARRAYSIZE(sz), TRUE);
- SetDlgItemText(hDlg, IDD_STATISTICS_TOTALEDIT, sz);
- } // PrintEditTimeInDlg
- #endif _WIN2000_DOCPROP_
- ////////////////////////////////////////////////////////////////////////////////
- //
- // SetEditValLpsz
- //
- // Purpose:
- // If this PropVariant holds a LPTSTR, it is written
- // to the caller-specified Edit Control. If it is not
- // an LPTSTR, it is not treated as an error (it might
- // simply be a VT_EMPTY ... a non-existent property).
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef _WIN2000_DOCPROP_
- void PASCAL SetEditValLpsz(
- LPPROPVARIANT lppropvar, // PropVariant
- HWND hDlg, // Dialog handle
- DWORD dwID ) // Edit control ID
- {
- if (lppropvar->vt == VT_LPTSTR)
- {
- SendDlgItemMessage
- (hDlg, dwID, WM_SETTEXT, 0, (LPARAM) lppropvar->pszVal);
- PropVariantClear( lppropvar );
- }
- }
- #endif
- ////////////////////////////////////////////////////////////////////////////////
- //
- // GetEditValLpsz
- //
- // Purpose:
- // Reads the string from the caller-specified edit
- // control, and loads it into a PropVariant.
- // If the Edit control says that it has not been
- // modified, then we don't read anything, and
- // return FALSE.
- //
- ////////////////////////////////////////////////////////////////////////////////
- #ifndef _WIN2000_DOCPROP_
- BOOL PASCAL GetEditValLpsz(
- LPPROPVARIANT lppropvar, // Sum info PropVariants
- HWND hDlg, // Dialog handle
- DWORD dwId) // Edit control id
- {
- BOOL fChanged = FALSE;
- DWORD cb, cch;
- // Did the data change?
- if ((BOOL) SendDlgItemMessage (hDlg, dwId, EM_GETMODIFY, 0, 0))
- {
- LPTSTR tszNew;
- // Yes, it changed. Ask the Edit control how big the
- // string is.
- cch = (DWORD)SendDlgItemMessage (hDlg, dwId, WM_GETTEXTLENGTH, 0, 0);
- cb = ( cch + 1 ) * sizeof (TCHAR); // Includes the NULL.
- // Allocate a new string for this PropVariant, and set
- // the VT.
- if ( !(tszNew = CoTaskMemAlloc (cb)))
- {
- goto Exit;
- }
- PropVariantClear( lppropvar );
- lppropvar->vt = VT_LPTSTR;
- (LPTSTR) lppropvar->pszVal = tszNew;
- // Get the string from the edit control into the buffer
- // (the size of the buffer in characters is cch+1, including
- // the NULL).
- SendDlgItemMessage (hDlg, dwId, WM_GETTEXT, (WPARAM) cch+1,
- (LPARAM) lppropvar->pszVal);
- fChanged = TRUE;
- } // if ((BOOL) SendDlgItemMessage (hDlg, dwId, EM_GETMODIFY, 0, 0))
- // ----
- // Exit
- // ----
- Exit:
- return (fChanged);
- } // GetEditValLpsz
- #endif //_WIN2000_DOCPROP_
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FAllocAndGetValLpstz
- //
- // Purpose:
- // Gets the value from the edit box into the local buffer.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FAllocAndGetValLpstz (
- HWND hDlg, // Handle of dialog control is in
- DWORD dwId, // Id of control
- LPTSTR *lplpstz) // Buffer
- {
- DWORD cch;
- cch = (DWORD)SendDlgItemMessage (hDlg, dwId, WM_GETTEXTLENGTH, 0, 0);
- cch++;
- if (FAllocString (lplpstz, cch))
- {
- // Get the entry. Remember to null-terminate it.
- cch = (DWORD)SendDlgItemMessage (hDlg, dwId, WM_GETTEXT, cch, (LPARAM) PSTR (*lplpstz));
- ((LPTSTR)(PSTR (*lplpstz)))[cch] = TEXT('');
- return TRUE;
- }
- return FALSE;
- } // FAllocAndGetValLpstz
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FAllocString
- //
- // Purpose:
- // Allocates a string big enough to to hold cch char's. Only allocates if needed.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FAllocString (
- LPTSTR *lplpstz,
- DWORD cch)
- {
- // Figure out how many bytes we need to allocate.
- DWORD cbNew = (cch * sizeof(TCHAR));
- // And how many bytes we need to free.
- DWORD cbOld = *lplpstz == NULL
- ? 0
- : (CchTszLen (*lplpstz) + 1) * sizeof(TCHAR);
- // If we need to free or allocate data.
- if (*lplpstz == NULL || cbNew > cbOld)
- {
- LPTSTR lpszNew;
- // Allocate the new data.
- lpszNew = PvMemAlloc(cbNew);
- if (lpszNew == NULL)
- {
- return FALSE;
- }
- // Free the old data.
- if (*lplpstz != NULL)
- VFreeMemP(*lplpstz, cbOld);
- *lplpstz = lpszNew;
- }
- // Make this a valid (empty) string.
- **lplpstz = TEXT('');
- return TRUE;
- } // FAllocString
- ////////////////////////////////////////////////////////////////////////////////
- //
- // ClearEditControl
- //
- // Purpose:
- // Clears any text from an edit control
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL
- ClearEditControl
- (HWND hDlg, // Dialog handle
- DWORD dwId) // Id of edit control
- {
- // Really cheesey. Clear the edit control by selecting
- // everything then clearing the selection
- if (dwId == 0)
- {
- SendMessage (hDlg, EM_SETSEL, 0, -1);
- SendMessage (hDlg, WM_CLEAR, 0, 0);
- }
- else
- {
- SendDlgItemMessage (hDlg, dwId, EM_SETSEL, 0, -1);
- SendDlgItemMessage (hDlg, dwId, WM_CLEAR, 0, 0);
- }
- } // ClearEditControl
- ////////////////////////////////////////////////////////////////////////////////
- //
- // UdtypesGetNumberType
- //
- // Purpose:
- // Gets the number type from the string and returns the value, either
- // a float or dword in numval.
- //
- ////////////////////////////////////////////////////////////////////////////////
- UDTYPES PASCAL
- UdtypesGetNumberType
- (LPTSTR lpstz, // String containing the number
- NUM *lpnumval, // The value of the number
- BOOL (*lpfnFSzToNum)(NUM *, LPTSTR)) // Sz To Num routine, can be null
- {
- TCHAR *pc;
- errno = 0;
- *(DWORD *) lpnumval = strtol ((LPTSTR)PSTR (lpstz), &pc, 10);
- if ((!errno) && (*pc == TEXT('')))
- return wUDdw;
- // Try doing a float conversion if int fails
- if (lpfnFSzToNum != NULL)
- {
- if ((*lpfnFSzToNum)(lpnumval, (LPTSTR)PSTR(lpstz)))
- return wUDfloat;
- }
- return wUDinvalid;
- } // UdtypesGetNumberType
- ////////////////////////////////////////////////////////////////////////////////
- //
- // YearIndexFromShortDateFormat
- //
- //
- // Determines the zero-based position index of the year component
- // of a textual representation of the date based on the specified date format.
- // This value may be used as the iYear arg to ScanDateNums function.
- //
- ////////////////////////////////////////////////////////////////////////////////
- int YearIndexFromShortDateFormat( TCHAR chFmt )
- {
- switch( chFmt )
- {
- case MMDDYY:
- case DDMMYY:
- return 2;
- case YYMMDD:
- return 0;
- }
- return -1;
- }
- ////////////////////////////////////////////////////////////////////////////////
- //
- // IsGregorian
- //
- // Purpose:
- // Reports whether the specified calendar is a gregorian calendar.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL IsGregorian( CALID calid )
- {
- switch (calid)
- {
- case CAL_GREGORIAN:
- case CAL_GREGORIAN_US:
- case CAL_GREGORIAN_ME_FRENCH:
- case CAL_GREGORIAN_ARABIC:
- case CAL_GREGORIAN_XLIT_ENGLISH:
- case CAL_GREGORIAN_XLIT_FRENCH:
- return TRUE;
- // these are non-gregorian:
- //case CAL_JAPAN
- //case CAL_TAIWAN
- //case CAL_KOREA
- //case CAL_HIJRI
- //case CAL_THAI
- //case CAL_HEBREW
- }
- return FALSE;
- }
- ////////////////////////////////////////////////////////////////////////////////
- //
- // GregorianYearFromAbbreviatedYear
- //
- // Purpose:
- // Based on current locale settings, calculates the year corresponding to the
- // specified 1- or 2-digit abbreviated value.
- //
- ////////////////////////////////////////////////////////////////////////////////
- int GregorianYearFromAbbreviatedYear( LCID lcid, CALID calid, int nAbbreviatedYear )
- {
- TCHAR szData[16];
- LONG nYearHigh = -1;
- int nBaseCentury;
- int nYearInCentury = 0;
- // We're handling two-digit values for gregorian calendars only
- if (nAbbreviatedYear < 100)
- {
- // BUGBUG: why do we not support non-gregorian?
- if( !IsGregorian( calid )
- || !GetCalendarInfo( lcid, calid, CAL_ITWODIGITYEARMAX|CAL_RETURN_NUMBER,
- NULL, 0, &nYearHigh ) )
- {
- // In the absence of a default, use 2029 as the cutoff, just like monthcal.
- nYearHigh = 2029;
- }
- //
- // Copy the century of nYearHigh into nAbbreviatedYear.
- //
- nAbbreviatedYear += (nYearHigh - nYearHigh % 100);
- //
- // If it exceeds the max, then drop to previous century.
- //
- if (nAbbreviatedYear > nYearHigh)
- nAbbreviatedYear -= 100;
- }
- return nAbbreviatedYear;
- }
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FConvertDate
- //
- // Purpose:
- // Converts the given string to a date.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FConvertDate
- (LPTSTR lpstz, // String having the date
- LPFILETIME lpft) // The date in FILETIME format
- {
- FILETIME ft;
- SYSTEMTIME st;
- TCHAR szSep[3];
- TCHAR szFmt[10];
- TCHAR szCalID[8];
- unsigned int ai[3];
- int iYear =-1; // index of ai member that represents the year value
- CALID calid;
- TCHAR szDate[256];
- TCHAR szMonth[256];
- TCHAR *pch;
- TCHAR *pchT;
- DWORD cch;
- DWORD i;
- if (!(GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_IDATE, szFmt, ARRAYSIZE(szFmt))) ||
- !(GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_SDATE, szSep, ARRAYSIZE(szSep))) ||
- !(GetLocaleInfo (LOCALE_USER_DEFAULT, LOCALE_ICALENDARTYPE, szCalID, ARRAYSIZE(szCalID))) )
- return FALSE;
- iYear = YearIndexFromShortDateFormat(szFmt[0]);
- // Augh! It's an stz so we need to pass the DWORDs at the start
- if (!ScanDateNums(lpstz, szSep, ai, sizeof(ai)/sizeof(unsigned int),iYear))
- {
- // Could be that the string contains the short version of the month, e.g. 03-Mar-95
- PbMemCopy(szDate, lpstz, CBTSTR(lpstz));
- pch = szDate;
- // Let's get to the first character of the month, if there is one
- while((isdigit(*pch) || (*pch == szSep[0])) && (*pch != 0))
- ++pch;
- // If we got to the end of the string, there really was an error
- if (*pch == 0)
- return(FALSE);
- // Let's find the length of the month string
- pchT = pch+1;
- while ((*pchT != szSep[0]) && (*pchT != 0))
- ++pchT;
- cch = (DWORD)(pchT - pch);
- // Loop through all the months and see if we match one
- // There can be 13 months
- for (i = 1; i <= 13; ++i)
- {
- if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1+i-1,
- szMonth, ARRAYSIZE(szMonth)))
- return(FALSE);
- if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE | NORM_IGNOREKANATYPE | NORM_IGNOREWIDTH,
- pch, cch, szMonth, CchTszLen(szMonth)) == 2)
- break;
- }
- if (i > 13)
- return(FALSE);
- // We found the month. wsprintf zero-terminates
- cch = wsprintf(pch, TEXT("%u"), i);
- pch += cch;
- while (*pch++ = *(pch+1));
- // Try and convert again
- if (!ScanDateNums(szDate, szSep, ai, 3, iYear))
- return(FALSE);
- } // if (!ScanDateNums(lpstz, szSep, ai, 3))
- FillBuf (&st, 0, sizeof(st));
- switch (szFmt[0])
- {
- case MMDDYY:
- st.wMonth = (WORD)ai[0];
- st.wDay = (WORD)ai[1];
- st.wYear = (WORD)ai[2];
- break;
- case DDMMYY:
- st.wDay = (WORD)ai[0];
- st.wMonth = (WORD)ai[1];
- st.wYear = (WORD)ai[2];
- break;
- case YYMMDD:
- st.wYear = (WORD)ai[0];
- st.wMonth = (WORD)ai[1];
- st.wDay = (WORD)ai[2];
- break;
- default:
- return FALSE;
- }
- if (st.wYear < ONECENTURY)
- {
- calid = strtol( szCalID, NULL, 10 );
- st.wYear = (WORD)GregorianYearFromAbbreviatedYear(
- LOCALE_USER_DEFAULT, calid, st.wYear );
- }
- if (!SystemTimeToFileTime (&st, &ft))
- return(FALSE);
- return(LocalFileTimeToFileTime(&ft, lpft));
- } // FConvertDate
- ////////////////////////////////////////////////////////////////////////////////
- //
- // PopulateUDListView
- //
- // Purpose:
- // Populates the entire ListView with the User-defined properties
- // in the given object.
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL
- PopulateUDListView
- (HWND hWnd, // Handle of list view window
- LPUDOBJ lpUDObj) // UD Prop object
- {
- LPUDITER lpudi;
- LPPROPVARIANT lppropvar;
- BOOL fLink;
- BOOL fLinkInvalid;
- // Iterate through the list of user-defined properties, adding each
- // one to the listview.
- for( lpudi = LpudiUserDefCreateIterator (lpUDObj);
- FUserDefIteratorValid (lpudi);
- FUserDefIteratorNext (lpudi)
- )
- {
- // Get the name of this property.
- LPTSTR tszPropertyName
- = LpszUserDefIteratorName( lpudi, 1, (LPTSTR) UD_PTRWIZARD );
- // If the property has no name, or the name indicates that it
- // is a hidden property, then move on to the next property.
- if( tszPropertyName == NULL
- ||
- *tszPropertyName == HIDDENPREFIX )
- {
- continue;
- }
- lppropvar = LppropvarUserDefGetIteratorVal (lpudi, &fLink, &fLinkInvalid);
- if (lppropvar == NULL)
- return;
- // If this isn't a supported type, don't display it.
- if( !ISUDTYPE(lppropvar->vt) )
- continue;
- #ifdef SHELL
- //
- // In the Shell, we want all links to show up as invalid, so set that here...
- //
- fLinkInvalid = TRUE;
- #endif
- AddUDPropToListView (lpUDObj, hWnd, LpszUserDefIteratorName (lpudi, 1, (TCHAR *) UD_PTRWIZARD),
- lppropvar, -1, fLink, fLinkInvalid, FALSE);
- } // for( lpudi = LpudiUserDefCreateIterator (lpUDObj); ...
- FUserDefDestroyIterator (&lpudi);
- } // PopulateUDListView
- ////////////////////////////////////////////////////////////////////////////////
- //
- // AddUDPropToListView
- //
- // Purpose:
- // Adds the given property to the list view or updates an existing one
- // if iItem >= 0
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL AddUDPropToListView (
- LPUDOBJ lpUDObj,
- HWND hWnd, // Handle of list view
- LPTSTR lpszName, // Name of property
- LPPROPVARIANT lppropvar, // The property value.
- int iItem, // Index to add item at
- BOOL fLink, // Indicates the value is a link
- BOOL fLinkInvalid, // Is the link invalid?
- BOOL fMakeVisible) // Should the property be forced to be visible
- {
- LV_ITEM lvi;
- TCHAR sz[BUFMAX];
- WORD irg;
- BOOL fSuccess;
- BOOL fUpdate;
- // If iItem >= 0, then the item should be updated, otherwise,
- // it should be added.
- if (fUpdate = (iItem >= 0))
- {
- lvi.iItem = iItem;
- if (fLink)
- lvi.iImage = (fLinkInvalid) ? giInvLinkIcon : giLinkIcon;
- else
- lvi.iImage = giBlankIcon;
- lvi.mask = LVIF_IMAGE;
- lvi.iSubItem = iszNAME;
- fSuccess = ListView_SetItem (hWnd, &lvi);
- Assert (fSuccess); // We don't *really* care, just want to know when it happens
- }
- else
- {
- // This always adds to the end of the list....
- lvi.iItem = ListView_GetItemCount (hWnd);
- // First add the label to the list
- lvi.iSubItem = iszNAME;
- lvi.pszText = lpszName;
- if (fLink)
- lvi.iImage = (fLinkInvalid) ? giInvLinkIcon : giLinkIcon;
- else
- lvi.iImage = giBlankIcon;
- lvi.mask = LVIF_TEXT | LVIF_IMAGE;
- lvi.iItem = ListView_InsertItem (hWnd, &lvi);
- if (lvi.iItem == 0)
- ListView_SetItemState(hWnd, 0, LVIS_FOCUSED, LVIS_FOCUSED);
- }
- // Convert the data to a string and print it
- lvi.mask = LVIF_TEXT;
- irg = WUdtypeToSz (lppropvar, sz, BUFMAX, ((LPUDINFO)lpUDObj->m_lpData)->lpfnFNumToSz);
- lvi.pszText = sz;
- lvi.iSubItem = iszVAL;
- fSuccess = ListView_SetItem (hWnd, &lvi);
- Assert (fSuccess); // We don't *really* care, just want to know when it happens
- // Put the type in the listview
- lvi.iSubItem = iszTYPE;
- lvi.pszText = (LPTSTR) rgszTypes[irg];
- fSuccess = ListView_SetItem (hWnd, &lvi);
- Assert (fSuccess); // We don't *really* care, just want to know when it happens
- if (fMakeVisible)
- {
- fSuccess = ListView_EnsureVisible(hWnd, lvi.iItem, FALSE);
- Assert (fSuccess); // We don't *really* care, just want to know when it happens
- }
- // if (fUpdate)
- // {
- // ListView_RedrawItems (hWnd, lvi.iItem, lvi.iItem);
- // UpdateWindow (hWnd);
- // }
- } // AddUDPropToListView
- ////////////////////////////////////////////////////////////////////////////////
- //
- // AddItemToListView
- //
- // Purpose:
- // Adds the given string and number to the end of a listview
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL
- AddItemToListView
- (HWND hWnd, // ListView handle
- DWORD_PTR dw, // Number to add
- const TCHAR *lpsz, // String to add
- BOOL fString) // Indicates if dw is actually a string
- {
- LV_ITEM lvi;
- TCHAR sz[BUFMAX];
- BOOL fSuccess;
- if (!fString)
- // _itoa (dw, sz, BASE10);
- wsprintf(sz, TEXT("%lu"), dw);
- // This always adds to the end of the list....
- lvi.iItem = ListView_GetItemCount (hWnd);
- // First add the label to the list
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = iszNAME;
- lvi.pszText = (LPTSTR) lpsz;
- lvi.iItem = ListView_InsertItem (hWnd, &lvi);
- if (lvi.iItem == 0) // Adding the 1st item
- ListView_SetItemState(hWnd, 0, LVIS_FOCUSED, LVIS_FOCUSED);
- Assert ((lvi.iItem != -1));
- // Then add the value
- lvi.mask = LVIF_TEXT;
- lvi.iSubItem = iszVAL;
- lvi.pszText = (fString) ? (LPTSTR) dw : sz;
- fSuccess = ListView_SetItem (hWnd, &lvi);
- Assert (fSuccess);
- } // AddItemToListView
- ////////////////////////////////////////////////////////////////////////////////
- //
- // InitListView
- //
- // Purpose:
- // Initializes a list view control
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL
- InitListView
- (HWND hWndLV, // Handle of parent dialog
- int irgLast, // Index of last column in array
- TCHAR rgsz[][SHORTBUFMAX], // Array of column headings
- BOOL fImageList) // Should the listview have an image list
- {
- HICON hIcon;
- RECT rect;
- HIMAGELIST hImlS;
- LV_COLUMN lvc;
- int irg;
- lvc.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
- lvc.fmt = LVCFMT_LEFT;
- // Initially force all columns to be the same size & fill the control.
- GetClientRect(hWndLV, &rect);
- // Subtract fudge factor
- lvc.cx = (rect.right-rect.left)/(irgLast+1)-(GetSystemMetrics(SM_CXVSCROLL)/(irgLast+1));
- // Add in all the columns.
- for (irg = 0; irg <= irgLast; irg++)
- {
- lvc.pszText = rgsz[irg];
- lvc.iSubItem = irg;
- ListView_InsertColumn (hWndLV, irg, &lvc);
- }
- if (!fImageList)
- return;
- hIcon = LoadIcon (g_hmodThisDll, MAKEINTRESOURCE (IDD_BLANK_ICON));
- if (hIcon != NULL)
- {
- hImlS = MsoImageList_Create (16, 16, TRUE, ICONSMAX, 0);
- ListView_SetImageList (hWndLV, hImlS, LVSIL_SMALL);
- giBlankIcon = MsoImageList_ReplaceIcon (hImlS, -1, hIcon);
- Assert ((giBlankIcon != -1));
- }
- } // InitListView
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FSwapControls
- //
- // Purpose:
- // Swaps the controls needed to display link info.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL
- FSwapControls
- (HWND hWndVal, // Handle of Value window
- HWND hWndLinkVal, // Handle of Link Value Combo box
- HWND hWndBoolTrue, // Handle of True radio button
- HWND hWndBoolFalse, // Handle of False radio button
- HWND hWndGroup, // Handle of Group box
- HWND hWndType, // Handle of Type window
- HWND hWndValText,
- BOOL fLink, // Flag indicating a link
- BOOL fBool) // Flag indicating a bool
- {
- if (fLink)
- {
- SendMessage (hWndValText, WM_SETTEXT, 0, (LPARAM) rgszValue[iszSOURCE]);
- ShowWindow (hWndVal, SW_HIDE);
- ShowWindow (hWndBoolTrue, SW_HIDE);
- ShowWindow (hWndBoolFalse, SW_HIDE);
- ShowWindow (hWndGroup, SW_HIDE);
- ShowWindow (hWndLinkVal, SW_SHOW);
- EnableWindow (hWndType, FALSE);
- ClearEditControl (hWndVal, 0);
- }
- else
- {
- SendMessage (hWndValText, WM_SETTEXT, 0, (LPARAM) rgszValue[iszVALUE]);
- ShowWindow (hWndLinkVal, SW_HIDE);
- EnableWindow (hWndType, TRUE);
- if (fBool)
- {
- ShowWindow (hWndVal, SW_HIDE);
- ShowWindow (hWndBoolTrue, SW_SHOW);
- ShowWindow (hWndBoolFalse, SW_SHOW);
- ShowWindow (hWndGroup, SW_SHOW);
- SendMessage (hWndBoolTrue, BM_SETCHECK, (WPARAM) CHECKED, 0);
- SendMessage (hWndBoolFalse, BM_SETCHECK, (WPARAM) CLEAR, 0);
- SendMessage (hWndType, CB_SETCURSEL, iszBOOL, 0);
- ClearEditControl (hWndVal, 0);
- }
- else
- {
- ShowWindow (hWndVal, SW_SHOW);
- EnableWindow(hWndVal, TRUE);
- ShowWindow (hWndBoolTrue, SW_HIDE);
- ShowWindow (hWndBoolFalse, SW_HIDE);
- ShowWindow (hWndGroup, SW_HIDE);
- SendMessage (hWndType, CB_SETCURSEL, iszTEXT, 0);
- }
- }
- return TRUE;
- } // FSwapControls
- ////////////////////////////////////////////////////////////////////////////////
- //
- // PopulateControls
- //
- // Purpose:
- // Populates the edit controls with the appropriate date from the object
- //
- ////////////////////////////////////////////////////////////////////////////////
- VOID PASCAL PopulateControls (
- LPUDOBJ lpUDObj, // Pointer to object
- LPTSTR szName, // Name of the item to populate controls with
- DWORD cLinks, // Number of links
- DWQUERYLD lpfnDwQueryLinkData, // Pointer to app link callback
- HWND hDlg, // Handle of the dialog
- HWND hWndName, // Handle of the Name window
- HWND hWndVal, // Handle of Value window
- HWND hWndValText, // Handle of Value LTEXT
- HWND hWndLink, // Handle of Link checkbox
- HWND hWndLinkVal, // Handle of Link Value window
- HWND hWndType, // Handle of Type window
- HWND hWndBoolTrue, // Handle of True radio button
- HWND hWndBoolFalse, // Handle of False radio button
- HWND hWndGroup, // Handle of Group window
- HWND hWndAdd, // Handle of Add button
- HWND hWndDelete, // Handle of Delete button
- BOOL *pfLink, // Indicates that the value is a link
- BOOL *pfAdd) // Indicates the state of the Add button
- {
- UDTYPES udtype;
- LPVOID lpv;
- LPPROPVARIANT lppropvar; // A property from the UDObj linked-list.
- BOOL f,fT;
- TCHAR sz[BUFMAX];
- LPUDPROP lpudp;
- // Grab the type for the string and set up the dialog to have the right
- // controls to display it.
- udtype = UdtypesUserDefType (lpUDObj, szName);
- AssertSz ((udtype != wUDinvalid), TEXT("User defined properties or ListView corrupt"));
- // Get a name-specified property from the UD linked-list.
- lppropvar = LppropvarUserDefGetPropVal (lpUDObj, szName, pfLink, &fT);
- Assert (lppropvar != NULL || udtype == wUDbool || udtype == wUDdw);
- if (lppropvar == NULL)
- return;
- lpv = LpvoidUserDefGetPropVal (lpUDObj, szName, 1, NULL, UD_STATIC | UD_PTRWIZARD, pfLink, &fT);
- Assert((lpv != NULL) || (udtype == wUDbool) || (udtype == wUDdw));
- FSwapControls (hWndVal, hWndLinkVal, hWndBoolTrue, hWndBoolFalse, hWndGroup, hWndType, hWndValText, *pfLink, (udtype == wUDbool));
- SendMessage (hWndType, CB_SETCURSEL, (WPARAM) WUdtypeToSz (lppropvar, (TCHAR *) sz, BUFMAX,
- ((LPUDINFO)lpUDObj->m_lpData)->lpfnFNumToSz), 0);
- SendMessage (hWndLink, BM_SETCHECK, (WPARAM) *pfLink, 0);
- if (cLinks) // Let's make sure we enable the window if links are allowed
- EnableWindow(hWndLink, TRUE);
- if (*pfLink)
- {
- FCreateListOfLinks (cLinks, lpfnDwQueryLinkData, hWndLinkVal);
- lpv = LpvoidUserDefGetPropVal (lpUDObj, szName, 1, NULL, UD_LINK | UD_PTRWIZARD, pfLink, &fT);
- Assert (lpv != NULL || udtype == wUDbool || udtype == wUDdw);
- // if (lpfnDwQueryLinkData == NULL)
- // {
- // SetCustomDlgDefButton(hDlg, gOKButtonID);
- // EnableWindow (hWndAdd, FALSE);
- // SendMessage (hWndLinkVal, CB_INSERTSTRING, (WPARAM) -1, (LPARAM) lpv);
- // }
- AssertSz ((lpv != NULL), TEXT("Dialog is corrupt in respect to Custom Properties database"));
- // This code is added for bug 188 and the code is ugly !! :)
- lpudp = LpudpropFindMatchingName (lpUDObj, szName);
- if ((lpudp != NULL) && (lpudp->fLinkInvalid))
- {
- SetCustomDlgDefButton(hDlg, IDD_CUSTOM_DELETE);
- SendMessage(hWndName, WM_SETTEXT, 0, (LPARAM)szName);
- SendMessage(hWndVal, WM_SETTEXT, 0, (LPARAM)lpv);
- EnableWindow(hWndDelete, TRUE);
- EnableWindow(hWndAdd, FALSE);
- EnableWindow(hWndLink, FALSE);
- EnableWindow(hWndType, FALSE);
- ShowWindow(hWndLinkVal, SW_HIDE);
- ShowWindow(hWndVal, SW_SHOW);
- EnableWindow(hWndVal, FALSE);
- return;
- }
- // Select the current link for this property in the combobox. If the link
- // name no longer exists (there's some contrived cases where this can
- // happen) then this will select nothing.
- SendMessage (hWndLinkVal, CB_SELECTSTRING, 0, (LPARAM) lpv);
- EnableWindow(hWndLink, TRUE);
- }
- else if (udtype == wUDbool)
- {
- SendMessage ((lpv) ? hWndBoolTrue : hWndBoolFalse, BM_SETCHECK, CHECKED, 0);
- SendMessage ((lpv) ? hWndBoolFalse : hWndBoolTrue, BM_SETCHECK, CLEAR, 0);
- EnableWindow(hWndType, TRUE);
- }
- else
- {
- SendMessage (hWndVal, WM_SETTEXT, 0, (LPARAM) sz);
- EnableWindow (hWndVal, TRUE);
- EnableWindow(hWndType, TRUE);
- }
- if (*pfAdd)
- {
- SendMessage (hWndAdd, WM_SETTEXT, 0, (LPARAM) rgszAdd[iszMODIFY]);
- *pfAdd = FALSE;
- }
- // HACK: Because the EN_UPDATE handler for hWndName checks fAdd to
- // see if the button should be set to Add, when we set the text
- // in the edit control, the button will change to Add unless
- // fAdd is set to TRUE. Temporarily set the flag to TRUE to force
- // the button to not change. Restore the original value after the
- // text has been set.
- f = *pfAdd;
- *pfAdd = TRUE;
- SendMessage (hWndName, WM_SETTEXT, 0, (LPARAM) szName);
- *pfAdd = f;
- // If we can fill the data in the controls, turn on the
- // Delete button too.
- // fItemSel = TRUE;
- EnableWindow (hWndDelete, TRUE);
- SetCustomDlgDefButton(hDlg, gOKButtonID);
- EnableWindow (hWndAdd, FALSE);
- } // PopulateControls
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FSetupAddButton
- //
- // Purpose:
- // Sets up the Add button correctly based on the type & flags.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL
- FSetupAddButton
- (DWORD iszType, // Index of the type in combobox
- BOOL fLink, // Indicates a link
- BOOL *pfAdd, // Indicates if the Add button is showing
- HWND hWndAdd, // Handle of Add button
- HWND hWndVal, // Handle of value button
- HWND hWndName, // Handle of Name
- HWND hDlg) // Handle of dialog
- {
- // Once the user starts typing, we can enable the Add button
- // if there is text in the name & the value (unless this
- // is a link or boolean, in which case we don't care about
- // the value).
- BOOL f;
- if ((iszType != iszBOOL) && (!fLink))
- {
- if (SendMessage (hWndVal, EM_LINELENGTH, 0, 0) != 0)
- {
- f = (SendMessage (hWndName, WM_GETTEXTLENGTH, 0, 0) != 0);
- if (f)
- SetCustomDlgDefButton(hDlg, IDD_CUSTOM_ADD);
- else
- SetCustomDlgDefButton(hDlg, gOKButtonID);
- EnableWindow (hWndAdd, f);
- }
- else
- {
- SetCustomDlgDefButton(hDlg, gOKButtonID);
- EnableWindow (hWndAdd, FALSE);
- }
- }
- // If it's a bool or link, just check to see that the name
- // has stuff in it.
- else
- {
- f = SendMessage (hWndName, WM_GETTEXTLENGTH, 0, 0) != 0;
- if (f)
- SetCustomDlgDefButton(hDlg, IDD_CUSTOM_ADD);
- else
- SetCustomDlgDefButton(hDlg, gOKButtonID);
- EnableWindow (hWndAdd, f);
- }
- if (!*pfAdd)
- {
- SendMessage (hWndAdd, WM_SETTEXT, 0, (LPARAM) rgszAdd[iszADD]);
- *pfAdd = TRUE;
- }
- return TRUE;
- } // FSetupAddButton
- ////////////////////////////////////////////////////////////////////////////////
- //
- // WUdtypeToSz
- //
- // Purpose:
- // Converts the given type into a string representation. Returns the
- // index in the type combobox of the type.
- //
- ////////////////////////////////////////////////////////////////////////////////
- WORD PASCAL WUdtypeToSz (
- LPPROPVARIANT lppropvar, // Value with the type to be converted.
- LPTSTR sz, // Buffer to put converted val in
- DWORD cchMax, // Size of buffer (in chars)
- BOOL (*lpfnFNumToSz)(NUM *, LPTSTR, DWORD))
- {
- SYSTEMTIME st;
- WORD irg;
- FILETIME ft;
- Assert (lppropvar != NULL);
- switch (lppropvar->vt)
- {
- case wUDlpsz :
- PbSzNCopy (sz, lppropvar->pwszVal, cchMax);
- irg = iszTEXT;
- break;
- case wUDdate :
- if (FScanMem((LPBYTE)&lppropvar->filetime,
- 0, sizeof(FILETIME))) // if the date struct is all 0's
- {
- *sz = 0; // display the empty string
- }
- else if (!FileTimeToLocalFileTime(&lppropvar->filetime, &ft)
- || !FileTimeToSystemTime (&ft, &st)
- || (!GetDateFormat (LOCALE_USER_DEFAULT, DATE_SHORTDATE, &st, NULL, sz, cchMax)))
- {
- #ifdef DEBUG
- DWORD dwErr = GetLastError();
- #endif DEBUG
- irg = iszUNKNOWN;
- *sz = 0;
- break;
- }
- irg = iszDATE;
- break;
- case wUDdw :
- Assert(cchMax >= 11);
- Assert(lppropvar->vt == VT_I4);
- wsprintf (sz, TEXT("%ld"), lppropvar->lVal);
- irg = iszNUM;
- break;
- case wUDfloat :
- if (lpfnFNumToSz != NULL)
- irg = (*lpfnFNumToSz)((NUM*)&lppropvar->dblVal, sz, cchMax) ? iszNUM : iszUNKNOWN;
- else
- {
- irg = iszUNKNOWN;
- *sz = 0;
- }
- break;
- case wUDbool :
- PbSzNCopy (sz,
- lppropvar->boolVal ? (LPTSTR) &rgszBOOL[iszTRUE] : (LPTSTR) &rgszBOOL[iszFALSE],
- cchMax);
- irg = iszBOOL;
- break;
- default :
- irg = iszUNKNOWN;
- } // switch
- return irg;
- } // WUdtypeToSz
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FCreateListOfLinks
- //
- // Purpose:
- // Creates the dropdown list of linkable items.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FCreateListOfLinks(
- DWORD cLinks, // Number of links
- DWQUERYLD lpfnDwQueryLinkData, // Link data callback
- HWND hWndLinkVal) // Link Value window handle
- {
- DWORD irg;
- LPTSTR lpstz;
- // If the combobox is already filled, don't fill it
- if (irg = (int)SendMessage(hWndLinkVal, CB_GETCOUNT,0, 0))
- {
- Assert(irg == cLinks);
- return(TRUE);
- }
- lpstz = NULL;
- // Call back the client app to get the list of linkable
- // values, and put them in the value combobox.
- for (irg = 0; irg < cLinks; irg++)
- {
- lpstz = (TCHAR *) ((*lpfnDwQueryLinkData) (QLD_LINKNAME, irg, &lpstz, NULL));
- if (lpstz != NULL)
- {
- SendMessage (hWndLinkVal, CB_INSERTSTRING, (WPARAM) -1, (LPARAM) PSTR (lpstz));
- VFreeMemP(lpstz, CBTSTR(lpstz));
- // REVIEW: We probably ought to figure out a way to be more efficient here....
- }
- }
- return TRUE;
- } // FCreateListOfLinks
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FSetTypeControl
- //
- // Purpose:
- // Sets the type control to have the given type selected.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FSetTypeControl (
- UDTYPES udtype, // Type to set the type to
- HWND hWndType) // Handle of type control
- {
- WORD iType;
- switch (udtype)
- {
- case wUDlpsz :
- iType = iszTEXT;
- break;
- case wUDfloat :
- case wUDdw :
- iType = iszNUM;
- break;
- case wUDbool :
- iType = iszBOOL;
- break;
- case wUDdate :
- iType = iszDATE;
- break;
- default:
- return FALSE;
- }
- SendMessage (hWndType, CB_SETCURSEL, (WPARAM) iType, 0);
- return TRUE;
- } // FSetTypeControl
- ////////////////////////////////////////////////////////////////////////////////
- //
- // DeleteItem
- //
- // Purpose:
- // Deletes an item from the UD object and the listview.
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL DeleteItem (
- LPUDOBJ lpUDObj,
- HWND hWndLV,
- int iItem,
- TCHAR sz[])
- {
- int i;
- ListView_DeleteItem (hWndLV, iItem);
- FUserDefDeleteProp (lpUDObj, sz);
- // We just nuked the item with the focus, so let's get the new one
- // if there are still items in the listview
- if ((i = ListView_GetItemCount(hWndLV)) != 0)
- {
- // Figure out the index of the item to get the focus
- i = (i == iItem) ? iItem - 1 : iItem;
- ListView_SetItemState(hWndLV, i, LVIS_FOCUSED, LVIS_FOCUSED);
- }
- } // DeleteItem
- ////////////////////////////////////////////////////////////////////////////////
- //
- // ResetTypeControl
- //
- // Purpose:
- // Resets the value of the type control to Text.
- //
- ////////////////////////////////////////////////////////////////////////////////
- void PASCAL ResetTypeControl (
- HWND hDlg, // Handle of dialog
- DWORD dwId, // Id of control
- DWORD *piszType) // The type we've reset to
- {
- SendDlgItemMessage (hDlg, dwId, CB_SETCURSEL, iszTEXT, 0);
- *piszType = iszTEXT;
- } // ResetTypeControl
- ////////////////////////////////////////////////////////////////////////////////
- //
- // FDisplayConversionWarning
- //
- // Purpose:
- // Displays a warning about types being converted. Returns TRUE if
- // the user presses "Cancel"
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FDisplayConversionWarning(HWND hDlg) // Handle of parent window
- {
- return (IdDoAlert(hDlg, idsPEWarningText, MB_ICONEXCLAMATION | MB_OKCANCEL) == IDCANCEL);
- } // FDisplayConversionWarning
- ////////////////////////////////////////////////////////////////////////////////
- //
- // LoadTextStrings
- //
- // Purpose:
- // Loads all of the text needed by the dialogs from the DLL.
- //
- ////////////////////////////////////////////////////////////////////////////////
- BOOL PASCAL FLoadTextStrings (void)
- {
- register int cLoads = 0;
- register int cAttempts = 0;
- // CchGetString returns a cch, so make it into a 1 or 0
- // then add up the results,making sure we load as many as
- // we try.
- cLoads += (CchGetString (idsPEB, rgszOrders[iszBYTES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEKB, rgszOrders[iszORDERKB], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEMB, rgszOrders[iszORDERMB], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEGB, rgszOrders[iszORDERGB], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPETB, rgszOrders[iszORDERTB], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEBytes, rgszStats[iszBYTES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEPages, rgszStats[iszPAGES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEPara, rgszStats[iszPARA], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPELines, rgszStats[iszLINES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEWords, rgszStats[iszWORDS], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEChars, rgszStats[iszCHARS], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPESlides, rgszStats[iszSLIDES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPENotes, rgszStats[iszNOTES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEHiddenSlides, rgszStats[iszHIDDENSLIDES], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEMMClips, rgszStats[iszMMCLIPS], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEFormat, rgszStats[iszFORMAT], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEText, rgszTypes[iszTEXT], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEDate, rgszTypes[iszDATE], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPENumber, rgszTypes[iszNUM], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEBool, rgszTypes[iszBOOL], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEUnknown, rgszTypes[iszUNKNOWN], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEStatName, rgszStatHeadings[iszNAME], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEValue, rgszStatHeadings[iszVAL], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEPropName, rgszHeadings[iszNAME], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEValue, rgszHeadings[iszVAL], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEType, rgszHeadings[iszTYPE], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPETrue, rgszBOOL[iszTRUE], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEFalse, rgszBOOL[iszFALSE], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEAdd, rgszAdd[iszADD], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEModify, rgszAdd[iszMODIFY], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPESource, rgszValue[iszSOURCE], SHORTBUFMAX) && TRUE);
- cAttempts++;
- cLoads += (CchGetString (idsPEValueColon, rgszValue[iszVALUE], BUFMAX) && TRUE);
- cAttempts++;
- return (cLoads == cAttempts);
- } // LoadTextStrings
- //
- // Function: ISavePropDlgChanges
- //
- // Parameters:
- //
- // hwndDlg - dialog window handle
- // hwndFrom - window handle from the NMHDR struct (see code above)
- //
- // Returns:
- //
- // TRUE since we handled the message.
- //
- // History:
- //
- // Created 09/16/94 martinth
- //
- int PASCAL ISavePropDlgChanges(LPALLOBJS lpallobjs, HWND hwndDlg, HWND hwndFrom)
- {
- TCHAR sz[BUFMAX];
- int iRet = IDABORT; // MessageBox return.
- LRESULT lRet = 0L; // (FALSE == dismiss property sheet).
- if (CchGetString(idsCustomWarning, sz, ARRAYSIZE(sz)) == 0)
- return(FALSE);
- lpallobjs->fPropDlgPrompted = TRUE; // no warning next time!
- iRet = MessageBox( hwndDlg, sz, TEXT("Warning"),
- MB_ICONEXCLAMATION | MB_YESNOCANCEL );
- switch( iRet )
- {
- case IDYES:
- PropSheet_Apply(hwndFrom); // Let's get them changes
- break;
- // case IDNO: // do nothing
- case IDCANCEL: // cancel and disallow sheet destroy.
- lRet = TRUE;
- break;
- }
- SetWindowLongPtr( hwndDlg, DWLP_MSGRESULT, lRet );
- return iRet;
- }