⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchproc.c

📁 PGP8.0源码 请认真阅读您的文件包然后写出其具体功能
💻 C
📖 第 1 页 / 共 4 页
字号:
					break;
				}
			}

			break;
		}

		case WM_SIZE:
		{
			BOOL fwSizeType = wParam;      // resizing flag
			WORD newWidth = LOWORD(lParam);  // width of client area
			WORD newHeight = HIWORD(lParam); // height of client area
			int	 delta =  newWidth - oldWidth;
			RECT rectControl;
			HWND hwndControl;


			if( newWidth < originalWidth )
			{
				delta = originalWidth - oldWidth;
				newWidth = originalWidth;

			}

			if( newWidth >= originalWidth )
			{
				PCHOICE choice = NULL;

				oldWidth = newWidth;
				SetProp( hwnd, "oldWidth",(HANDLE) oldWidth);

				// move Search Button
				hwndControl = GetDlgItem(hwnd, IDC_SEARCH);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left + delta,
							rectControl.top,
							rectControl.right - rectControl.left,
							rectControl.bottom - rectControl.top,
							TRUE);

				// move Stop Button
				hwndControl = GetDlgItem(hwnd, IDC_STOP);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left + delta,
							rectControl.top,
							rectControl.right - rectControl.left,
							rectControl.bottom - rectControl.top,
							TRUE);

				// move Clear Button
				hwndControl = GetDlgItem(hwnd, IDC_CLEAR);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left + delta,
							rectControl.top,
							rectControl.right - rectControl.left,
							rectControl.bottom - rectControl.top,
							TRUE);


				// move Help Button
				hwndControl = GetDlgItem(hwnd, IDHELP);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left + delta,
							rectControl.top,
							rectControl.right - rectControl.left,
							rectControl.bottom - rectControl.top,
							TRUE);

				// move the Boxes
				hwndControl = GetDlgItem(hwnd, IDC_SPECIFIER_COMBO);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left,
							rectControl.top,
							rectControl.right - rectControl.left + delta,
							rectControl.bottom - rectControl.top,
							TRUE);

				hwndControl = UTF8EditGetHandle (
						GetDlgItem(hwnd, IDC_SPECIFIER_EDIT));
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left,
							rectControl.top,
							rectControl.right - rectControl.left  + delta,
							rectControl.bottom - rectControl.top,
							TRUE);

				hwndControl = GetDlgItem(hwnd, IDC_SPECIFIER_COMBO_LIST);
				GetWindowRect(hwndControl, &rectControl);
				MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
				MoveWindow(	hwndControl,
							rectControl.left,
							rectControl.top,
							rectControl.right - rectControl.left + delta,
							rectControl.bottom - rectControl.top,
							TRUE);

				// move all the choice windows
				choice = FirstChoice(hwnd);

				while( choice )
				{
					hwndControl =  choice->hwnd;
					GetWindowRect(hwndControl, &rectControl);
					MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
					MoveWindow(	hwndControl,
								rectControl.left,
								rectControl.top ,
								rectControl.right - rectControl.left + delta,
								rectControl.bottom - rectControl.top,
								TRUE);

					choice = NextChoice(hwnd, choice);
				}

				// move the more and less buttons and the pending checkbox
				if(oldHeight != newHeight)
				{
					delta = newHeight - oldHeight;

					oldHeight = newHeight;
					SetProp( hwnd, "oldHeight",(HANDLE) oldHeight);

					hwndControl = GetDlgItem(hwnd, IDC_MORE);
					GetWindowRect(hwndControl, &rectControl);
					MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
					MoveWindow(	hwndControl,
								rectControl.left,
								rectControl.top + delta,
								rectControl.right - rectControl.left,
								rectControl.bottom - rectControl.top,
								TRUE);

					hwndControl = GetDlgItem(hwnd, IDC_FEWER);
					GetWindowRect(hwndControl, &rectControl);
					MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
					MoveWindow(	hwndControl,
								rectControl.left,
								rectControl.top + delta,
								rectControl.right - rectControl.left,
								rectControl.bottom - rectControl.top,
								TRUE);

					hwndControl = GetDlgItem(hwnd, IDC_PENDING);
					GetWindowRect(hwndControl, &rectControl);
					MapWindowPoints(NULL, hwnd, (LPPOINT)&rectControl, 2);
					MoveWindow(	hwndControl,
								rectControl.left,
								rectControl.top + delta,
								rectControl.right - rectControl.left,
								rectControl.bottom - rectControl.top,
								TRUE);

				}
			}

			return TRUE;
		}

		case WM_PAINT:
		{
			RECT rect, rectParent;

			GetClientRect(hwnd, &rect);
			GetClientRect(GetParent(hwnd), &rectParent);

			if(rect.right != rectParent.right)
			{
				MapWindowPoints(hwnd, GetParent(hwnd), (LPPOINT)&rect, 2);

				rect.left	= rectParent.left;
				rect.top	= rectParent.top;
				rect.right	= rectParent.right;

				MoveWindow(	hwnd,
							rect.left,
							rect.top,
							rect.right - rect.left,
							rect.bottom - rect.top,
							TRUE);
			}
			break;
		}

		case WM_COMMAND:
		{
			WORD wNotifyCode = HIWORD(wParam); // notification code
			WORD wID = LOWORD(wParam);         // item, control id
			HWND hwndCtl = (HWND) lParam;      // handle of control

			switch( wID )
			{
				case IDC_MORE:
				{
					PCHOICE choice;
					RECT rectChoice;
					RECT rect;
					int height;

					if(wNotifyCode)
					{
						break;
					}

					choice = NewChoice(hwnd);

					if(choice)
					{
						SIZEREQUEST request;
						HWND hwndCtrl = NULL;


						GetClientRect(hwnd, &rect);
						GetClientRect(choice->hwnd, &rectChoice);

						height = rectChoice.bottom - rectChoice.top + 1;

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

						request.nmhdr.hwndFrom = hwnd;
						request.nmhdr.idFrom = IDD_SEARCH;
						request.nmhdr.code = SEARCH_REQUEST_SIZING;
						request.delta = height;

						if(SendMessage(	GetParent(hwnd),
										WM_NOTIFY,
										(WPARAM)hwnd,
										(LPARAM)&request))
						{
							NMHDR nmhdr;

							height += rect.bottom - rect.top;

							MapWindowPoints(hwnd,
											GetParent(hwnd),
											(LPPOINT)&rect,
											2);

							rect.bottom	= rect.top + height;

							MoveWindow(	hwnd,
										rect.left,
										rect.top,
										rect.right - rect.left,
										rect.bottom - rect.top,
										TRUE);

							ShowWindow(choice->hwnd, SW_SHOW);

							EnableWindow(GetDlgItem(hwnd, IDC_FEWER), TRUE);

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

							nmhdr.hwndFrom = hwnd;
							nmhdr.idFrom = IDD_SEARCH;
							nmhdr.code = SEARCH_SIZING;

							SendMessage(GetParent(hwnd),
										WM_NOTIFY,
										(WPARAM)hwnd,
										(LPARAM)&nmhdr);

							hwndCtrl = GetDlgItem(hwnd, IDC_MORE);
							InvalidateRect(hwndCtrl, NULL, FALSE);
							hwndCtrl = GetDlgItem(hwnd, IDC_FEWER);
							InvalidateRect(hwndCtrl, NULL, FALSE);

						}
						else
						{
							HWND hwndChoice;

							RemoveLastChoice(hwnd, &hwndChoice);
							UTF8EditDestroy (GetDlgItem (
									hwndChoice, IDC_SPECIFIER_EDIT));
							DestroyWindow(hwndChoice);

							PKMessageBox (hwnd, IDS_CAPTIONINFO, 
									IDS_NOMOREROOMFORCHOICES, 
									MB_OK|MB_ICONINFORMATION);
						}
					}

					break;
				}

				case IDC_FEWER:
				{
					PCHOICE choice;
					HWND hwndChoice;
					RECT rectChoice;
					RECT rect;
					int height;
					NMHDR nmhdr;

					if(wNotifyCode)
					{
						break;
					}

					choice = RemoveLastChoice(hwnd, &hwndChoice);

					GetClientRect(hwnd, &rect);
					GetClientRect(hwndChoice, &rectChoice);

					height = rect.bottom - rect.top;
					height -= rectChoice.bottom - rectChoice.top + 1;

					MapWindowPoints(hwnd, GetParent(hwnd), (LPPOINT)&rect, 2);

					rect.bottom	= rect.top + height;

					MoveWindow(	hwnd,
								rect.left,
								rect.top,
								rect.right - rect.left,
								rect.bottom - rect.top,
								TRUE);

					if(!choice)
					{
						EnableWindow(GetDlgItem(hwnd, IDC_FEWER), FALSE);
					}

					UTF8EditDestroy (GetDlgItem (hwndChoice, IDC_SPECIFIER_EDIT));
					DestroyWindow(hwndChoice);

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

					nmhdr.hwndFrom = hwnd;
					nmhdr.idFrom = IDD_SEARCH;
					nmhdr.code = SEARCH_SIZING;

					SendMessage(GetParent(hwnd),
								WM_NOTIFY,
								(WPARAM)hwnd,
								(LPARAM)&nmhdr);

					break;
				}

				case IDC_CLEAR:
				{
					HWND	hwndItem	= NULL;
					int		count		= ChoiceCount(hwnd);

					if(wNotifyCode)
					{
						break;
					}

					// delete extra choices
					for(count; count > 0; count--)
					{
						SendMessage(hwnd,
									WM_COMMAND,
									MAKEWPARAM(IDC_FEWER, 0),
									0);
					}

					// reset default choice
					hwndItem = GetDlgItem(hwnd, IDC_ATTRIBUTE);
					ComboBox_SetCurSel(hwndItem, 0);

					ChangeAttributeSelection(hwndItem);

					hwndItem = GetDlgItem(hwnd, IDC_SPECIFIER_EDIT);
					UTF8EditSetText(hwndItem, "");

					break;
				}

				case IDC_SEARCH:
				{
					PGPFilterRef	filter = NULL;
					PGPFilterRef	SearchFilter = NULL;
					PCHOICE			choice = NULL;
					PGPError		error;
					int				action = 0;
					HWND			hwndStop = NULL;

					PSEARCHTHREADSTRUCT psts = NULL;

					psts = (PSEARCHTHREADSTRUCT)
								GetProp( hwnd, "SearchInfo");

					if(wNotifyCode)
					{
						break;
					}

					hwndStop = GetDlgItem(hwnd, IDC_STOP);

					// Take Care of the Default Search Item in ourself
					error = CreateFilter(hwnd,
							psts->keydbMain, &filter, &action);

					SearchFilter = filter;

					if( IsntPGPError (error ) )
					{
						// now iterate the children if there are any
						choice = FirstChoice(hwnd);

						while( choice && IsntPGPError (error ) )
						{
							error = CreateFilter(choice->hwnd,
										psts->keydbMain,
										&filter, &action);

							if( IsntPGPError (error ) )
							{
								PGPFilterRef CombinedFilter = NULL;

								// | the filters
								if( action == ACTION_UNION )
								{
									error = PGPUnionFilters(
													filter,
													SearchFilter,
													&CombinedFilter);
								}
								// & the filters
								else if( action == ACTION_INTERSECT )
								{
									error = PGPIntersectFilters(
														filter,
														SearchFilter,
														&CombinedFilter);

								}

								SearchFilter = CombinedFilter;
							}

							choice = NextChoice(hwnd, choice);
						}
					}

					if( IsPGPError(error) )
					{
						PGPclErrorBox (NULL, error);
					}

					if( IsntPGPError(error) )
					{
						if (!psts->threadHandle)
						{
							psts->hwnd = hwnd;
							psts->filter = SearchFilter;
							psts->bCancel = FALSE;

							SetProp( hwnd, "SearchInfo",(HANDLE) psts);

							EnableWindow (hwndStop, TRUE);
							ShowWindow(hwndStop, SW_SHOW);
							EnableWindow(hwndCtl, FALSE);
							ShowWindow(hwndCtl, SW_HIDE);

							psts->threadHandle = CreateThread(	NULL,
													0,
													SearchThreadRoutine,
													(void*)psts,
													0,
													&psts->threadID);
						}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -