Exemple #1
0
void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey)
{
	if (dataListEdit)
		dataListEdit->EndListEdit(0);

	POINT pt = { 0, 0 };
	ClientToScreen(hwndList, &pt);
	OffsetRect(rc, pt.x, pt.y);
	InflateRect(rc, -2, -2);
	rc->left -= 2;
	iEditItem = iItem;
	ListView_RedrawItems(hwndList, iEditItem, iEditItem);
	UpdateWindow(hwndList);

	dataListEdit = this;
	hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW | WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP | WS_BORDER | WS_VSCROLL,
											rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL);
	SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
	int itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);

	const SettingItem &si = setting[iSetting];
	SettingItemData &sid = settingData[iSetting];
	FieldNamesItem *list = (FieldNamesItem*)si.pList;

	// some country codes were changed leaving old details uknown, convert it for the user
	if (list == countryField) {
		if (sid.value == 420)
			sid.value = 42; // conversion of obsolete codes (OMG!)
		else if (sid.value == 421)
			sid.value = 4201;
		else if (sid.value == 102)
			sid.value = 1201;
	}

	if (list == timezonesField) {
		tmi.prepareList(NULL, ppro->m_szModuleName, hwndListEdit, TZF_PLF_LB);
	}
	else {
		int j, n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
		for (j = 0;; j++)
			if (!list[j].text) {
				SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
				if ((sid.value == 0 && list[j].code == 0) || (si.dbType != DBVT_ASCIIZ && sid.value == list[j].code))
					SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
				break;
			}

		for (j = 0; list[j].text; j++) {
			char str[MAX_PATH];
			n = ListBoxAddStringUtf(hwndListEdit, list[j].text);
			SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
			if ((si.dbType == DBVT_ASCIIZ && (!strcmpnull((char*)sid.value, list[j].text))
				|| (si.dbType == DBVT_ASCIIZ && (!strcmpnull((char*)sid.value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH))))
				|| ((char*)sid.value == NULL && list[j].code == 0))
				|| (si.dbType != DBVT_ASCIIZ && sid.value == list[j].code))
				SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
		}
		SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0);
	}

	int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0);
	if (itemHeight * listCount < 150)
		SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER | SWP_NOMOVE);
	mir_subclassWindow(hwndListEdit, ListEditSubclassProc);
	AnimateWindow(hwndListEdit, 200, AW_SLIDE | AW_ACTIVATE | AW_VER_POSITIVE);
	ShowWindow(hwndListEdit, SW_SHOW);
	SetFocus(hwndListEdit);
	if (wVKey)
		PostMessage(hwndListEdit, WM_KEYDOWN, wVKey, 0);
}
Exemple #2
0
void ChangeInfoData::BeginListEdit(int iItem, RECT *rc, int iSetting, WORD wVKey)
{
  int j,n;
  POINT pt;
  int itemHeight;
  char str[MAX_PATH];

  if (dataListEdit)
    dataListEdit->EndListEdit(0);

  pt.x=pt.y=0;
  ClientToScreen(hwndList,&pt);
  OffsetRect(rc,pt.x,pt.y);
  InflateRect(rc,-2,-2);
  rc->left-=2;
  iEditItem = iItem;
  ListView_RedrawItems(hwndList, iEditItem, iEditItem);
  UpdateWindow(hwndList);

  dataListEdit = this;
  hwndListEdit = CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_TOPMOST, _T("LISTBOX"), _T(""), WS_POPUP|WS_BORDER|WS_VSCROLL, rc->left, rc->bottom, rc->right - rc->left, 150, NULL, NULL, hInst, NULL);
  SendMessage(hwndListEdit, WM_SETFONT, (WPARAM)hListFont, 0);
  itemHeight = SendMessage(hwndListEdit, LB_GETITEMHEIGHT, 0, 0);

  FieldNamesItem *list = (FieldNamesItem*)setting[iSetting].pList;

  if (list == countryField)
  { // some country codes were changed leaving old details uknown, convert it for the user
    if (settingData[iSetting].value == 420) settingData[iSetting].value = 42; // conversion of obsolete codes (OMG!)
    else if (settingData[iSetting].value == 421) settingData[iSetting].value = 4201;
    else if (settingData[iSetting].value == 102) settingData[iSetting].value = 1201;
  }

  n = ListBoxAddStringUtf(hwndListEdit, "Unspecified");
  for (j=0; ; j++)
    if (!list[j].text)
    {
      SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
      if ((settingData[iSetting].value == 0 && list[j].code == 0)
       || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
        SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
      break;
    }

  for (j=0; list[j].text; j++) 
  {
    n = ListBoxAddStringUtf(hwndListEdit, list[j].text);
    SendMessage(hwndListEdit, LB_SETITEMDATA, n, j);
    if ((setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, list[j].text))
     || (setting[iSetting].dbType == DBVT_ASCIIZ && (!strcmpnull((char*)settingData[iSetting].value, ICQTranslateUtfStatic(list[j].text, str, MAX_PATH))))
     || ((char*)settingData[iSetting].value == NULL && list[j].code == 0))
     || (setting[iSetting].dbType != DBVT_ASCIIZ && settingData[iSetting].value == list[j].code))
      SendMessage(hwndListEdit, LB_SETCURSEL, n, 0);
  }
  SendMessage(hwndListEdit, LB_SETTOPINDEX, SendMessage(hwndListEdit, LB_GETCURSEL, 0, 0) - 3, 0);
  int listCount = SendMessage(hwndListEdit, LB_GETCOUNT, 0, 0);
  if (itemHeight * listCount < 150)
    SetWindowPos(hwndListEdit, 0, 0, 0, rc->right - rc->left, itemHeight * listCount + GetSystemMetrics(SM_CYBORDER) * 2, SWP_NOZORDER|SWP_NOMOVE);
  OldListEditProc = (WNDPROC)SetWindowLongPtr(hwndListEdit, GWLP_WNDPROC, (LONG_PTR)ListEditSubclassProc);
  if (MyAnimateWindow = (BOOL (WINAPI*)(HWND,DWORD,DWORD))GetProcAddress(GetModuleHandleA("user32"), "AnimateWindow")) 
  {
    BOOL enabled;

    SystemParametersInfo(SPI_GETCOMBOBOXANIMATION, 0, &enabled, FALSE);
    if (enabled) MyAnimateWindow(hwndListEdit, 200, AW_SLIDE|AW_ACTIVATE|AW_VER_POSITIVE);
  }
  ShowWindow(hwndListEdit, SW_SHOW);
  SetFocus(hwndListEdit);
  if (wVKey)
    PostMessage(hwndListEdit, WM_KEYDOWN, wVKey, 0);
}