/* Dialog Procedures */ #include "precomp.h" /************************************************************************/ /* */ /* Windows Cardfile - Written by Mark Cliggett */ /* (c) Copyright Microsoft Corp. 1985, 1994 - All Rights Reserved */ /* */ /************************************************************************/ int DBcmd; BOOL fRecursive; /* Avoid recursive IDD_BUTTON calls */ BOOL fValidDB; /* Are we validating on save, or not? local to DB */ HWND hwndLinkWait; /* Waits for "Set Link" callback */ BOOL fAutomatic; /* Did the link get changed to Automatic? */ BOOL DlgProc( HWND hDB, UINT message, WPARAM wParam, LPARAM lParam) { TCHAR *pResultBuf; TCHAR *pInit; int len; switch (message) { case WM_INITDIALOG: switch(DBcmd) { case DTHEADER: pInit = CurCardHead.line; break; default: pInit = TEXT(""); } SendDlgItemMessage(hDB, ID_EDIT, EM_LIMITTEXT, LINELENGTH, 0L); SetDlgItemText(hDB, ID_EDIT, pInit); SetFocus(GetDlgItem(hDB, ID_EDIT)); return(TRUE); case WM_COMMAND: pResultBuf = NULL; switch (LOWORD(wParam)) { case IDOK: if ((len = GetWindowTextLength(GetDlgItem(hDB, ID_EDIT))) || DBcmd == DTHEADER || DBcmd == DTADD) if (pResultBuf = (TCHAR *) LocalAlloc (LPTR, ByteCountOf(++len))) GetDlgItemText(hDB, ID_EDIT, pResultBuf, len); break; case IDCANCEL: break; default: return(FALSE); } EndDialog(hDB, (int)pResultBuf); /* return pointer to buffer */ return(TRUE); break; default: return(FALSE); } } /* Ole2Native - converts OLECHAR data to native character code. does it in-place, so you better have enough room. * * called with: Ole2Native( szBuf, num ) * * szBuf - input string * num - number of zero terminators in string * * returns: ptr to TCHAR string allocated from heap. caller must free. * on error, returns NULL * */ TCHAR* Ole2Native( OLECHAR* szBuf, INT num ) { #ifdef OLE_20 return szBuf; #else INT iWSize; // characters output INT iOleSize; // input size PTCHAR pszResult; // returned result OLECHAR* pszTemp; // for scanning for nulls INT i; // ditto pszTemp= szBuf; for( i=0; i