Esempio n. 1
0
void ComboBoxArray_AddSoundFiles(HWND boxes[], int num)
{
	int i;
	char search[MAX_PATH];
	HANDLE hFind;
	WIN32_FIND_DATA FindFileData;
	memcpy(search, api.root, api.root_len);
	memcpy(search+api.root_len, "/waves/*", 9);
	for(i=0; i<num; ++i)
		ComboBox_AddString(boxes[i],"<  no sound  >");
	if((hFind=FindFirstFile(search, &FindFileData)) != INVALID_HANDLE_VALUE) {
		do{
			if(!(FindFileData.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY)) { // only files (also ignores . and ..)
				for(i=0; i<num; ++i)
					ComboBox_AddString(boxes[i], FindFileData.cFileName);
			}
		}while(FindNextFile(hFind, &FindFileData));
		FindClose(hFind);
	}
	for(i=0; i<num; ++i){
		if(ComboBox_GetTextLength(boxes[i])){
			ComboBox_GetText(boxes[i], search, sizeof(search));
			ComboBox_AddStringOnce(boxes[i], search, 1);
		}else
			ComboBox_SetCurSel(boxes[i], 0);
	}
}
Esempio n. 2
0
/*
 * TextInputSetText:  Set the contents of the text input box to the given string.
 *   If focus is True, set focus to text input box.
 */
void TextInputSetText(char *text, Bool focus)
{
   int len;

   ComboBox_SetText(hwndInput, text);
   len = ComboBox_GetTextLength(hwndInput);

   if (focus)
      SetFocus(hwndInput);

   ComboBox_SetEditSel(hwndInput, len, len);  // Move caret to end of text
}
Esempio n. 3
0
BOOL
PrepareFoldersToScan(
    IN PDEVINSTDATA DevInstData,
    IN BOOL IncludeRemovableDevices,
    IN BOOL IncludeCustomPath,
    IN HWND hwndCombo OPTIONAL)
{
    WCHAR drive[] = {'?',':',0};
    DWORD dwDrives = 0;
    DWORD i;
    UINT nType;
    DWORD CustomTextLength = 0;
    DWORD LengthNeeded = 0;
    LPWSTR Buffer;

    /* Calculate length needed to store the search paths */
    if (IncludeRemovableDevices)
    {
        dwDrives = GetLogicalDrives();
        for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1)
        {
            if (dwDrives & i)
            {
                nType = GetDriveTypeW(drive);
                if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM)
                {
                    LengthNeeded += 3;
                }
            }
        }
    }
    if (IncludeCustomPath)
    {
        CustomTextLength = 1 + ComboBox_GetTextLength(hwndCombo);
        LengthNeeded += CustomTextLength;
    }

    /* Allocate space for search paths */
    HeapFree(GetProcessHeap(), 0, DevInstData->CustomSearchPath);
    DevInstData->CustomSearchPath = Buffer = HeapAlloc(
        GetProcessHeap(),
        0,
        (LengthNeeded + 1) * sizeof(WCHAR));
    if (!Buffer)
    {
        TRACE("HeapAlloc() failed\n");
        SetLastError(ERROR_NOT_ENOUGH_MEMORY);
        return FALSE;
    }

    /* Fill search paths */
    if (IncludeRemovableDevices)
    {
        for (drive[0] = 'A', i = 1; drive[0] <= 'Z'; drive[0]++, i <<= 1)
        {
            if (dwDrives & i)
            {
                nType = GetDriveTypeW(drive);
                if (nType == DRIVE_REMOVABLE || nType == DRIVE_CDROM)
                {
                    Buffer += 1 + swprintf(Buffer, drive);
                }
            }
        }
    }
    if (IncludeCustomPath)
    {
        Buffer += 1 + GetWindowTextW(hwndCombo, Buffer, CustomTextLength);
    }
    *Buffer = '\0';

    return TRUE;
}
LRESULT CALLBACK DlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
   static SQLHENV henv;
   static SQLHDBC hdbc;
   static SQLHSTMT hstmt;
   static int ifconnect=0;
   static SQLCHAR server[32];
   static char Content[10240] ;
   static RECT rect;
   static PAINTSTRUCT ps;
   static HBRUSH hbrush;	
   static HDC hDC ;
	static RedrawFlag = 0;
	LPDRAWITEMSTRUCT pdis;
	//~ char Content2[10240] ;
	SQLCHAR sqlstr[1024];	
	SQLRETURN retcode;
 
	//~ SQLHENV env;
	char dsn[256];
	char desc[256];
	SQLSMALLINT dsn_ret;
	SQLSMALLINT desc_ret;
	SQLUSMALLINT direction;
	SQLRETURN ret;
	HWND hEditTN = GetDlgItem(hwndDlg, IDC_EDIT1);
	HWND hEdit = GetDlgItem(hwndDlg, IDC_EDIT2);
	HWND hCBox = GetDlgItem(hwndDlg,IDC_COMBO1);
	HWND hBTN1 = GetDlgItem(hwndDlg,IDC_BUTTON1);
	int curSel;
	char szTable[256]; // receives name of item to delete. 
	LPDRAWITEMSTRUCT dItem;
	char text[20];
	int len;
	SIZE sz;

	GetWindowRect(hBTN1,&rect);
	
	switch (uMsg)
	{

	case WM_INITDIALOG:// WM_INITDIALOG message is sent before dialog is displayed
		{
		   // Allocate environment handle
		   retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv);
		   // Set the ODBC version environment attribute
		   if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
			  retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);
		   }
		   else {
					MessageBoxPrintf("Prompt","fail to SQLAllocHandle SQL_HANDLE_ENV\n");
					return FALSE;
			}
			
		  direction = SQL_FETCH_FIRST;
		  while(SQL_SUCCEEDED(ret = SQLDataSources(henv, direction,
							   dsn, sizeof(dsn), &dsn_ret,
							   desc, sizeof(desc), &desc_ret))) 
		  {
			direction = SQL_FETCH_NEXT;
			//MessageBoxPrintf("DSN","%s\n",dsn);
			ComboBox_InsertString(hCBox,0,dsn);								   
			if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");
		  }
			
			return TRUE;
		}
		break;
	case WM_COMMAND://
		{
			switch (LOWORD(wParam)) 
            { 
                // Process the accelerator and menu commands. 
 
                case ID_ACCELERATOR1: 
				//~ MessageBoxPrintf("hi","hello");
				//~ GetModuleHandle()
				SendMessage(hEdit, EM_SETSEL,(WPARAM)0,(LPARAM) sizeof(Content)/sizeof(char));
			return TRUE;
			}
			
			switch(wParam)
			{
				case IDC_BUTTON1:
				{
					//disconnect
					if (ifconnect) {
						retcode = SQLDisconnect(hdbc);	
					   if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
							SetWindowText(GetDlgItem(hwndDlg, IDC_BUTTON1), (LPCTSTR )"Connect");				   
							//~ MessageBoxPrintf("Prompt","Disconnected from %s!\n",server);
							ifconnect = 0;
						InvalidateRect(GetDlgItem(hwndDlg, IDC_BUTTON1),NULL, TRUE);  
						UpdateWindow(GetDlgItem(hwndDlg, IDC_BUTTON1));						   
							return 0;
					   }
					   //~ else
					   //~ {
							//~ MessageBoxPrintf("Prompt","Not Connect yet!\n");						
						//~ }
					}

					  // Allocate connection handle
						 retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
					  if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
							 // Set login timeout to 5 seconds					  
							SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (SQLPOINTER)5, 0);	
					  }
					  else{
							SQLFreeHandle(SQL_HANDLE_DBC, hdbc);  
							SQLFreeHandle(SQL_HANDLE_ENV, henv);								
							return FALSE;					  
					  }

					// Connect to data source
						if(!ComboBox_GetTextLength(hCBox)){
							MessageBoxPrintf("ERROR","Please Select an Item!");
							return FALSE;
						}
						curSel=ComboBox_GetCurSel(hCBox);
						ComboBox_GetLBText(hCBox,curSel,server);
						retcode = SQLConnect(
						hdbc
						, (SQLCHAR*) server
						, SQL_NTS
						, (SQLCHAR*) NULL
						, 0
						, NULL
						, 0);
					  
					if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO) {
						ifconnect=1;
						SetWindowText(GetDlgItem(hwndDlg, IDC_BUTTON1), (LPCTSTR )"Connected");
						RedrawFlag=1;
						//~ SendMessage(hBTN1, WM_CTLCOLORBTN, (WPARAM)GetWindowDC(hBTN1), (LPARAM)hBTN1);
						//~ SendDlgItemMessage(hwndDlg,IDC_BUTTON1
						//~ ,WM_CTLCOLORBTN,(WPARAM)GetWindowDC(hBTN1), (LPARAM)hBTN1);
						InvalidateRect(GetDlgItem(hwndDlg, IDC_BUTTON1),NULL, TRUE);  
						UpdateWindow(GetDlgItem(hwndDlg, IDC_BUTTON1));
						//~ InvalidateRect(hwndDlg,NULL,TRUE);
						//~ MessageBoxPrintf("Prompt","Connected to %s!\n" ,server);							
					}
					else {
						MessageBoxPrintf("Prompt","Fail to Connect to %s!\n",server);	
						ShowDBStmtError(hwndDlg,hdbc);								
					}
				}
				break;
				
				case IDC_BUTTON3:
				{
					//~ MessageBoxPrintf("INFO","length:%d\n",Edit_GetTextLength(hEdit));
					if(!Edit_GetTextLength(hEditTN)){
						MessageBoxPrintf("Error","[SKM.]TABNAME");
						return FALSE;
					}
					
					ZeroMemory(Content,sizeof(Content)/sizeof(char));
					SetDlgItemText(hwndDlg,IDC_EDIT2,Content);										
					if (!ifconnect) {
						MessageBoxPrintf("Prompt","Not Connect yet!\n");						
						return 0;
					}
					//初始化语句句柄
					retcode = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
					//SQL_NTS telling the function the previous parameter is Null-Terminated String, 
					//please alculate the string length for me
                    if (!GetDlgItemText(hwndDlg, IDC_EDIT1, szTable, sizeof(szTable)/sizeof(SQLCHAR))) 
					{
						*szTable=0;
						MessageBoxPrintf("","%s\n",sqlstr);
					}
					
					// 判断表是否存在
					wsprintf(sqlstr,"select count(0) from syscat.columns where tabname = upper('%s')",szTable);
					retcode = SQLPrepare(hstmt,(SQLCHAR*)sqlstr,SQL_NTS);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					retcode =SQLExecute(hstmt);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					while ( SQLFetch(hstmt) != SQL_NO_DATA_FOUND ){
						SQLINTEGER id=0;
						SQLGetData(hstmt,1,SQL_C_ULONG,&id,sizeof(SQLINTEGER),(SQLINTEGER*)NULL);
						if(0==id){
						MessageBoxPrintf("ERROR","TABLE <%s> does not exists!",szTable);
							return FALSE;
						}
					}
					SQLFreeStmt(hstmt,SQL_CLOSE);

					// do the job
					wsprintf(sqlstr,"select COLNAME from syscat.columns where tabname = upper('%s') ORDER BY COLNO ASC",szTable);
					retcode = SQLPrepare(hstmt,(SQLCHAR*)sqlstr,SQL_NTS);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					retcode =SQLExecute(hstmt);
					CHECKDBSTMTERROR(hwndDlg,retcode,hstmt);
					while ( SQLFetch(hstmt) != SQL_NO_DATA_FOUND ){
						//~ SQLINTEGER id=0;
						char name[32];
						ZeroMemory(name,sizeof(name)/sizeof(char));
						//~ SQLGetData(hstmt,1,SQL_C_ULONG,&id,sizeof(SQLINTEGER),(SQLINTEGER*)NULL);
						SQLGetData(hstmt,1,SQL_C_CHAR,name,sizeof(name)/sizeof(SQLCHAR),(SQLINTEGER*)NULL);
						//~ MessageBoxPrintf("Result","%s",name);
						strncat(Content,name,32);
						strncat(Content,"\r\n,",32);
					}
					*(Content+strlen(Content)-1)=0;
					//~ strncpy(Content2,Content,strlen(Content)-2);
					SetDlgItemText(hwndDlg,IDC_EDIT2,Content);
					//~ SendMessage(hEdit, EM_LINESCROLL, 0, 80);//WS_VSCROLL
					SQLFreeStmt(hstmt,SQL_CLOSE);
				}				
				default:
					break;
			}
			return TRUE;
		}
		break;
		
	case WM_CTLCOLORBTN:
			//~ hDC = BeginPaint((HWND)wParam, &ps);
			//~ FillRect(hDC, &rect, hbrush);
			//~ EndPaint((HWND)wParam, &ps);		
			//~ if(RedrawFlag){
				//~ hbrush = CreateSolidBrush(RGB(0,255,0));			
				//~ SetTextColor((HDC)wParam,RGB(0,0,0));						
				//~ SetBkColor((HDC)wParam,RGB(0,255,0));
			//~ return (long)hbrush ;
			//~ }
			//~ else 
			//~ {
				//~ SetTextColor((HDC)wParam,RGB(255,0,0));	
				//~ SetBkColor((HDC)wParam,RGB(0,0,0));		
				//~ SetBkMode((HDC)wParam, TRANSPARENT);
				//~ return (long)hbrush ;
			//~ }
	break;
	
	case WM_CLOSE://Massage for terminate/exit (may close button clicked on title bar)
		{
			//Close dialog
			SQLFreeStmt(hstmt,SQL_CLOSE);	
			SQLDisconnect(hdbc);	
			SQLFreeHandle(SQL_HANDLE_DBC, hdbc);  
			SQLFreeHandle(SQL_HANDLE_ENV, henv);					
			//~ EndDialog(hwndDlg,0);
			DestroyWindow(hwndDlg);			
			break;
		}
	case WM_DESTROY:
		{
			PostQuitMessage(0); 
			return TRUE;
		}
	case WM_CTLCOLORDLG: //set its text and background colors using the specified display device context handle.
		{
			break;			
		}
	case WM_PAINT:
		{
			if (RedrawFlag == 1){
				hbrush = CreateSolidBrush(RGB(0,255,0));
				hDC = BeginPaint(hBTN1, &ps);
				FillRect(hDC, &rect, hbrush);
				EndPaint(hBTN1, &ps);
				return (LONG)hbrush;
			}
			break;	
		}
	case WM_DRAWITEM:
	{
				dItem = (DRAWITEMSTRUCT*)lParam;
				if (ifconnect){
				SetBkColor(dItem->hDC, RGB(0,255,0));				
					}
					else
					{
				SetBkColor(dItem->hDC, RGB(255,0,0));						
					}
                //~ SetTextColor(dItem->hDC, RGB(0,0,0xFF));
				memset(text, '\0', 20);

				GetWindowText(dItem->hwndItem, text, 20);
				len=lstrlen(text);

				GetTextExtentPoint32(dItem->hDC, text, len, &sz);

				ExtTextOut( dItem->hDC
							, ((dItem->rcItem.right - dItem->rcItem.left) / 2) + dItem->rcItem.left - (sz.cx / 2)
							, ((dItem->rcItem.bottom - dItem->rcItem.top) / 2) + dItem->rcItem.top - (sz.cy / 2)
							, ETO_OPAQUE | ETO_CLIPPED, &dItem->rcItem, text, len, NULL);

				DrawEdge( dItem->hDC, &dItem->rcItem
						, (dItem->itemState & ODS_SELECTED ? BDR_SUNKENOUTER : BDR_RAISEDOUTER), BF_RECT);
                return DefWindowProc(hwndDlg, uMsg, wParam, lParam);
break;			
		
	}
	case WM_CTLCOLORSTATIC: //可以控制静态控件的颜色
		{
			break;			
		}
	default:
		break;			
	}
	return FALSE;
}
Esempio n. 5
0
PGPError CreateFilter(HWND hwnd, PGPFilterRef* filter, int* action)
{
	PGPError error = kPGPError_NoErr;
	HWND hwndAttribute, hwndVerb;
	HWND hwndEditSpecifier, hwndComboSpecifier, hwndComboListSpecifier;
	HWND hwndTime;
	int AttributeSelection = 0;
	int VerbSelection = 0;
	int SpecifierSelection = 0;
	char* SpecifierBuffer = NULL;
	DWORD SpecifierLength = 0;
	int Month = 1;
	int Day = 1;
	int Year = 1970;
	BOOL bNegate = FALSE;
	SYSTEMTIME st;

	assert(hwnd);
	assert(filter);
	assert(action);

	// set default action
	*action = ACTION_INTERSECT;

	// find all our window handles
	hwndAttribute			= GetDlgItem(hwnd, IDC_ATTRIBUTE);
	hwndVerb				= GetDlgItem(hwnd, IDC_VERB);
	hwndEditSpecifier		= GetDlgItem(hwnd, IDC_SPECIFIER_EDIT);
	hwndComboSpecifier		= GetDlgItem(hwnd, IDC_SPECIFIER_COMBO);
	hwndComboListSpecifier	= GetDlgItem(hwnd, IDC_SPECIFIER_COMBO_LIST);
	hwndTime				= GetProp(hwnd, "hwndTime");
		
	// find what the user has chosen to search on
	AttributeSelection	= ComboBox_GetCurSel(hwndAttribute);
	VerbSelection		= ComboBox_GetCurSel(hwndVerb);
	SpecifierSelection	= ComboBox_GetCurSel(hwndComboSpecifier);
	if (SpecifierSelection < 0) 
		SpecifierSelection	= ComboBox_GetCurSel(hwndComboListSpecifier);

	// get date currently in time/date picker control
	SendMessage (hwndTime, DTM_GETSYSTEMTIME, 0, (LPARAM)&st);
	// struct tm represents months 0-11  so we have to subtract 1
	Month = st.wMonth - 1; 
	// struct tm represents days 1-31  we have don't subtract 1
	Day =	st.wDay;
	// struct tm represents years as offset from 1900
	Year =	st.wYear - 1900;

	// combo is zero based and the string list is not... adjust Selection
	switch( AttributeSelection + IDS_SEARCH_STRINGTABLE_BASE + 1 ) 
	{
		case IDS_ATTRIBUTE_1: // user id
		{
			SpecifierLength = Edit_GetTextLength(hwndEditSpecifier) + 1;
			SpecifierBuffer = (char*) malloc(SpecifierLength);

			if( SpecifierBuffer )
			{
				Edit_GetText(	hwndEditSpecifier, 
								SpecifierBuffer, 
								SpecifierLength);

				// MessageBox(NULL, SpecifierBuffer, "user id", MB_OK);

				switch( VerbSelection )
				{
					case IS_NOT:
						bNegate = TRUE;
					case IS:
					{
						error = PGPNewUserIDStringFilter(
										g_Context, 
										SpecifierBuffer, 
										kPGPMatchEqual,
										filter );

						if( bNegate && IsntPGPError(error) )
						{
							PGPFilterRef NegatedFilter = kPGPInvalidRef;

							error = PGPNegateFilter(*filter, 
													&NegatedFilter);

							if( IsntPGPError(error) )
							{
								*filter = NegatedFilter;
							}
						}

						break;
					}

					case DOES_NOT_CONTAIN:
						bNegate = TRUE;
					case CONTAINS:
					{
						
						error = PGPNewUserIDStringFilter(
										g_Context, 
										SpecifierBuffer, 
										kPGPMatchSubString,
										filter );

						if( bNegate && IsntPGPError(error) )
						{
							PGPFilterRef NegatedFilter = kPGPInvalidRef;

							error = PGPNegateFilter(*filter, 
													&NegatedFilter);

							if( IsntPGPError(error) )
							{
								*filter = NegatedFilter;
							}
						}

						break;
					}

					case IS_NOT_SIGNED_BY:
						bNegate = TRUE;
					case IS_SIGNED_BY:
					{
						PGPKeySetRef	ringSet		= kPGPInvalidRef;
						PGPKeySetRef	filteredSet	= kPGPInvalidRef;


						error = PGPOpenDefaultKeyRings(	g_Context, 
														0, 
														&ringSet);

						if(ringSet && IsntPGPError(error))
						{
							PGPFilterRef userIdFilter = kPGPInvalidRef;

							error = PGPNewUserIDStringFilter(
												g_Context, 
												SpecifierBuffer, 
												kPGPMatchSubString,
												&userIdFilter );

							if( IsntPGPError(error) )
							{
								error = PGPFilterKeySet(ringSet, 
														userIdFilter, 
														&filteredSet);

								PGPFreeFilter(userIdFilter);
							}

							if( IsntPGPError(error) )
							{
								error = KeyIdFilterFromKeySet(	filteredSet,
																filter);
								PGPFreeKeySet(filteredSet);
							}

							if (!PGPRefIsValid (*filter))
							{
								error = kPGPError_Win32_NoSigningKey;
							}

							PGPFreeKeySet(ringSet);
						}

						if( bNegate && IsntPGPError(error) )
						{
							PGPFilterRef NegatedFilter = kPGPInvalidRef;

							error = PGPNegateFilter(*filter, 
													&NegatedFilter);

							if( IsntPGPError(error) )
							{
								*filter = NegatedFilter;
							}
						}

						break;
					}
				}

				free(SpecifierBuffer);
			}
			else
			{
				error = kPGPError_OutOfMemory;
			}

			break;
		}

		case IDS_ATTRIBUTE_2: // key id
		{
			SpecifierLength = Edit_GetTextLength(hwndEditSpecifier) + 1;
			SpecifierBuffer = (char*) malloc(SpecifierLength);

			if( SpecifierBuffer )
			{
				Edit_GetText(	hwndEditSpecifier, 
								SpecifierBuffer, 
								SpecifierLength);

				//MessageBox(NULL, SpecifierBuffer, "key id", MB_OK);

				switch( VerbSelection )
				{
					case IS_NOT:
						bNegate = TRUE;
					case IS:
					{
						PGPKeyID keyId;

						error = PGPGetKeyIDFromString(	SpecifierBuffer, 
														&keyId );
						if(IsntPGPError(error))
						{
							error = PGPNewKeyIDFilter(	g_Context, 
													&keyId,
													filter );
					
							if( bNegate && IsntPGPError(error) )
							{
								PGPFilterRef NegatedFilter = kPGPInvalidRef;

								error = PGPNegateFilter(*filter, 
														&NegatedFilter);

								if( IsntPGPError(error) )
								{
									*filter = NegatedFilter;
								}
							}
						}

						break;
					}
				}

				free(SpecifierBuffer);
			}
			else
			{
				error = kPGPError_OutOfMemory;
			}

			break;
		}

		case IDS_ATTRIBUTE_3: // key type
		{
			PGPByte encryptAlgorithm = 0;

			if( SpecifierSelection == DH_KEY_TYPE )
			{
				encryptAlgorithm = kPGPPublicKeyAlgorithm_ElGamal;
			}
			else if( SpecifierSelection == RSA_KEY_TYPE )
			{
				encryptAlgorithm = kPGPPublicKeyAlgorithm_RSA;
			}
			
			error = PGPNewKeyEncryptAlgorithmFilter(g_Context, 
													encryptAlgorithm, 
			 										filter);
			break;
		}

		case IDS_ATTRIBUTE_4: // creation date
		{
			struct tm time;

			memset(&time, 0x00, sizeof(time));

			time.tm_mday	= Day;    /* day of the month - [1,31] */
			time.tm_mon		= Month;  /* months since January - [0,11] */
			time.tm_year	= Year;   /* years since 1900 */

			switch( VerbSelection )
			{

				// In order to simulate an "is date" without the
				// user having to enter the exact hour, min, sec
				// the key was created, we fake it by doing an
				// intersection between the entire day.
				case IS:
				{
					PGPFilterRef filterAM;
					PGPFilterRef filterPM;

					/* midnight AM */
					time.tm_sec		= 0; 
					time.tm_min		= 0;     
					time.tm_hour	= 0;

					error = PGPNewKeyCreationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchGreaterOrEqual, 
								&filterAM );

					if(IsPGPError(error))
					{
						break;
					}

					/* just before midnight PM */
					time.tm_sec		= 59; 
					time.tm_min		= 59;     
					time.tm_hour	= 23;

					error = PGPNewKeyCreationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchLessOrEqual, 
								&filterPM );

					if(IsntPGPError(error))
					{
						error = PGPIntersectFilters(filterAM,
													filterPM,
													filter);
					}
					
					break;
				}

				case IS_ON_OR_BEFORE:
				{
					
					/* just before midnight PM*/
					time.tm_sec		= 59; 
					time.tm_min		= 59;     
					time.tm_hour	= 23;

					error = PGPNewKeyCreationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)),  
								kPGPMatchLessOrEqual, 
								filter );
					break;
				}

				case IS_ON_OR_AFTER:
				{
					/* midnight AM*/
					time.tm_sec		= 0; 
					time.tm_min		= 0;     
					time.tm_hour	= 0;

					error = PGPNewKeyCreationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchGreaterOrEqual, 
								filter );

					break;
				}
			}
			break;
		}

		case IDS_ATTRIBUTE_5: // expiration date
		{
			struct tm time;
			
			memset(&time, 0x00, sizeof(time));

			time.tm_mday	= Day;    /* day of the month - [1,31] */
			time.tm_mon		= Month;  /* months since January - [0,11] */
			time.tm_year	= Year;   /* years since 1900 */

			switch( VerbSelection )
			{

				// In order to simulate an "is date" without the
				// user having to enter the exact hour, min, sec
				// the key was created, we fake it by doing an
				// intersection between the entire day.
				case IS:
				{
					PGPFilterRef filterAM;
					PGPFilterRef filterPM;

					/* midnight AM */
					time.tm_sec		= 0; 
					time.tm_min		= 0;     
					time.tm_hour	= 0;

					error = PGPNewKeyExpirationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchGreaterOrEqual, 
								&filterAM );

					if(IsPGPError(error))
					{
						break;
					}

					/* just before midnight PM */
					time.tm_sec		= 59; 
					time.tm_min		= 59;     
					time.tm_hour	= 23;

					error = PGPNewKeyExpirationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchLessOrEqual, 
								&filterPM );

					if(IsntPGPError(error))
					{
						error = PGPIntersectFilters(filterAM,
													filterPM,
													filter);

					}
					
					break;
				}

				case IS_ON_OR_BEFORE:
				{
					
					/* just before midnight PM*/
					time.tm_sec		= 59; 
					time.tm_min		= 59;     
					time.tm_hour	= 23;

					error = PGPNewKeyExpirationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)),  
								kPGPMatchLessOrEqual, 
								filter );
					break;
				}

				case IS_ON_OR_AFTER:
				{
					/* midnight AM*/
					time.tm_sec		= 0; 
					time.tm_min		= 0;     
					time.tm_hour	= 0;

					error = PGPNewKeyExpirationTimeFilter( 
								g_Context, 
								PGPGetPGPTimeFromStdTime(mktime(&time)), 
								kPGPMatchGreaterOrEqual, 
								filter );

					break;
				}
			}
			break;
		}

		case IDS_ATTRIBUTE_6: // key
		{
			if( SpecifierSelection == REVOKED )
			{
				error = PGPNewKeyRevokedFilter(	
							g_Context, 
							(PGPBoolean)!VerbSelection, 
							filter );
			}
			else if( SpecifierSelection == DISABLED )
			{
				error = PGPNewKeyDisabledFilter(	
							g_Context, 
							(PGPBoolean)!VerbSelection, 
							filter );
			}
			break;
		}

		case IDS_ATTRIBUTE_7: // key size
		{
			SpecifierLength = ComboBox_GetTextLength(hwndComboSpecifier) + 1;
			SpecifierBuffer = (char*) malloc(SpecifierLength);

			if( SpecifierBuffer )
			{
				ComboBox_GetText(	hwndComboSpecifier, 
									SpecifierBuffer, 
									SpecifierLength);

				//MessageBox(NULL, SpecifierBuffer, "Key Size", MB_OK);

				switch( VerbSelection )
				{
					case IS:
					{
						error = PGPNewKeyEncryptKeySizeFilter( 
											g_Context, 
											atol(SpecifierBuffer), 
			 								kPGPMatchEqual, 
											filter );
						break;
					}

					case IS_AT_LEAST:
					{
						error = PGPNewKeyEncryptKeySizeFilter( 
											g_Context, 
											atol(SpecifierBuffer), 
			 								kPGPMatchGreaterOrEqual, 
											filter );
						break;
					}

					case IS_AT_MOST:
					{
						error = PGPNewKeyEncryptKeySizeFilter( 
											g_Context, 
											atol(SpecifierBuffer), 
			 								kPGPMatchLessOrEqual, 
											filter );
						break;
					}
				}

				free(SpecifierBuffer);
			}
			else
			{
				error = kPGPError_OutOfMemory;
			}
			break;
		}

		default:
		{
			MessageBox(NULL, "DefaultFilter: Unknown Attribute", 0, MB_OK);
		}
	}

	return error;
}