Esempio n. 1
0
void DoSelectionDefaultAction(HWND hwnd,struct ClcData *dat)
{
	struct ClcContact *contact;

	if(dat->selection==-1) return;
	dat->szQuickSearch[0]=0;
	if(GetRowByIndex(dat,dat->selection,&contact,NULL)==-1) return;
	if(contact->type==CLCIT_GROUP)
		SetGroupExpand(hwnd,dat,contact->group,-1);
	if(contact->type==CLCIT_CONTACT)
		CallService(MS_CLIST_CONTACTDOUBLECLICKED,(WPARAM)contact->hContact,0);
}
Esempio n. 2
0
void DeleteFromContactList(HWND hwnd,struct ClcData *dat)
{
	struct ClcContact *contact;
	if(dat->selection==-1) return;
	dat->szQuickSearch[0]=0;
	if(GetRowByIndex(dat,dat->selection,&contact,NULL)==-1) return;
	switch (contact->type) {
		case CLCIT_GROUP: CallService(MS_CLIST_GROUPDELETE,(WPARAM)(HANDLE)contact->groupId,0); break;
		case CLCIT_CONTACT: 
			CallService("CList/DeleteContactCommand",(WPARAM)(HANDLE)
			contact->hContact,(LPARAM)hwnd); break;
	}
}
Esempio n. 3
0
void EndRename(HWND hwnd,struct ClcData *dat,int save)
{   
    HWND hwndEdit;
    if (!dat) return;
	hwndEdit=dat->hwndRenameEdit;

	if(dat->hwndRenameEdit==NULL) return;
	dat->hwndRenameEdit=NULL;
	if(save) {
		TCHAR text[120];
		struct ClcContact *contact;
		GetWindowText(hwndEdit,text,sizeof(text));
		if(GetRowByIndex(dat,dat->selection,&contact,NULL)!=-1) {
			if(lstrcmp(contact->szText,text)) {
				if(contact->type==CLCIT_GROUP&&!_tcsstr(text,TEXT("\\"))) {
					TCHAR szFullName[256];
					if(contact->group->parent && contact->group->parent->parent)
					{
						TCHAR * tc=(TCHAR*)CallService(MS_CLIST_GROUPGETNAMET,(WPARAM)contact->group->parent->groupId,(LPARAM)(int*)NULL);
							_sntprintf(szFullName,sizeof(szFullName),TEXT("%s\\%s"),tc,text);						
					}
					else lstrcpyn(szFullName,text,sizeof(szFullName));
					CallService(MS_CLIST_GROUPRENAME,contact->groupId,(LPARAM)szFullName);
				}
				else if(contact->type==CLCIT_CONTACT) {
					TCHAR *otherName=mir_strdupT((TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)contact->hContact,GCDNF_NOMYHANDLE|GCDNF_UNICODE/*|TODO: UNICODE*/));
					InvalidateDisplayNameCacheEntry(contact->hContact);
					if(text[0]==TEXT('\0')) {
						DBDeleteContactSetting(contact->hContact,"CList","MyHandle");
					}
					else {
						if(!lstrcmp(otherName,text)) DBDeleteContactSetting(contact->hContact,"CList","MyHandle");
						else DBWriteContactSettingTString(contact->hContact,"CList","MyHandle",text);
					}
					if (otherName) mir_free(otherName);
					InvalidateDisplayNameCacheEntry(contact->hContact);
				}
			}
		}
	}
	DestroyWindow(hwndEdit);
}
Esempio n. 4
0
int HitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcContact **contact,ClcGroup **group,DWORD *flags)
{
	struct ClcContact *hitcontact;
	ClcGroup *hitgroup;
	int hit,indent,width,i,cxSmIcon;
	int checkboxWidth, subident,ic = 0;
	SIZE textSize;
	HDC hdc;
	HFONT oldfont;
	RECT clRect;
	DWORD style = GetWindowLongPtr(hwnd,GWL_STYLE);

	if (flags) *flags = 0;
	GetClientRect(hwnd,&clRect);
	if (testx<0 || testy<0 || testy>=clRect.bottom || testx>=clRect.right) {
		if (flags) {
			if (testx<0) *flags |= CLCHT_TOLEFT;
			else if (testx>=clRect.right) *flags |= CLCHT_TORIGHT;
			if (testy<0) *flags |= CLCHT_ABOVE;
			else if (testy>=clRect.bottom) *flags |= CLCHT_BELOW;
		}
		return -1;
	}
	if (testx<dat->leftMargin) {
		if (flags) *flags |= CLCHT_INLEFTMARGIN|CLCHT_NOWHERE;
		return -1;
	}
	hit = GetRowByIndex(dat ,(testy+dat->yScroll)/dat->rowHeight,&hitcontact,&hitgroup);
	if (hit == -1) {
		if (flags) *flags |= CLCHT_NOWHERE|CLCHT_BELOWITEMS;
		return -1;
	}
	if (contact) *contact = hitcontact;
	if (group) *group = hitgroup;
	/////////
	if (hitcontact->type == CLCIT_CONTACT && hitcontact->isSubcontact)
		subident = dat->rowHeight/2;
	else
		subident = 0;

	for (indent = 0;hitgroup->parent;indent++,hitgroup = hitgroup->parent);
	if (testx<dat->leftMargin+indent*dat->groupIndent+subident) {
		if (flags) *flags |= CLCHT_ONITEMINDENT;
		return hit;
	}
	checkboxWidth = 0;
	if (style&CLS_CHECKBOXES && hitcontact->type == CLCIT_CONTACT) checkboxWidth = dat->checkboxSize+2;
	if (style&CLS_GROUPCHECKBOXES && hitcontact->type == CLCIT_GROUP) checkboxWidth = dat->checkboxSize+2;
	if (hitcontact->type == CLCIT_INFO && hitcontact->flags&CLCIIF_CHECKBOX) checkboxWidth = dat->checkboxSize+2;
	if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+subident) {
		if (flags) *flags |= CLCHT_ONITEMCHECK;
		return hit;
	}
	if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+subident) {
		if (flags) *flags |= CLCHT_ONITEMICON;
		return hit;
	}

	hdc = GetDC(hwnd);
	GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
	width = textSize.cx;

	cxSmIcon = GetSystemMetrics(SM_CXSMICON);

	for (i=0; i < dat->extraColumnsCount; i++) {
		int x;
		if (hitcontact->iExtraImage[i] == EMPTY_EXTRA_ICON)
			continue;

		if ((style & CLS_EX_MULTICOLUMNALIGNLEFT)) {
			x = (dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace-2+width);
			x += 16;
			x = x+dat->extraColumnSpacing*(ic);
			if (i == dat->extraColumnsCount-1) {x = clRect.right-18;}
		}
		else {
			int ir;
			if (dat->MetaIgnoreEmptyExtra) {
				ir = 0;
				for (int j = i;j<dat->extraColumnsCount;j++)
					if (hitcontact->iExtraImage[j] != EMPTY_EXTRA_ICON)
						ir++;
			}
			else ir = dat->extraColumnsCount-i;

			x = clRect.right-dat->extraColumnSpacing*ir;
		}
		ic++;

		if (testx >= x && testx < x + cxSmIcon) {
			if (flags)
				*flags |= CLCHT_ONITEMEXTRA|(i<<24);

			ReleaseDC(hwnd,hdc);
			return hit;
		}
	}

	if (hitcontact->type == CLCIT_GROUP)
		oldfont = (HFONT)SelectObject(hdc,dat->fontInfo[FONTID_GROUPS].hFont);
	else
		oldfont = (HFONT)SelectObject(hdc,dat->fontInfo[FONTID_CONTACTS].hFont);

	GetTextExtentPoint32(hdc,hitcontact->szText,lstrlen(hitcontact->szText),&textSize);
	width = textSize.cx;
	if (hitcontact->type == CLCIT_GROUP) {
		char *szCounts = pcli->pfnGetGroupCountsText(dat,hitcontact);
		if (szCounts[0]) {
			GetTextExtentPoint32A(hdc," ",1,&textSize);
			width += textSize.cx;
			SelectObject(hdc,dat->fontInfo[FONTID_GROUPCOUNTS].hFont);
			GetTextExtentPoint32A(hdc,szCounts,lstrlenA(szCounts),&textSize);
			width += textSize.cx;
		}
	}
	SelectObject(hdc,oldfont);
	ReleaseDC(hwnd,hdc);
	if (testx<dat->leftMargin+indent*dat->groupIndent+checkboxWidth+dat->iconXSpace+width+4+subident) {
		if (flags) *flags |= CLCHT_ONITEMLABEL;
		return hit;
	}
	if (flags) *flags |= CLCHT_NOWHERE;
	return -1;
}
Esempio n. 5
0
LRESULT CALLBACK ContactListControlWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{     
	struct ClcData *dat = (struct ClcData*)GetWindowLongPtr(hwnd,0);
	if ( msg >= CLM_FIRST && msg < CLM_LAST )
		return pcli->pfnProcessExternalMessages(hwnd,dat,msg,wParam,lParam);

	switch (msg) {
	case WM_CREATE:
		dat = (struct ClcData*)mir_calloc( sizeof(struct ClcData));
		SetWindowLong(hwnd,0,(LPARAM)dat);
		InitDisplayNameCache(&dat->lCLCContactsCache);
		break;

	case INTM_ICONCHANGED:
	{	struct ClcContact *contact=NULL;
		struct ClcGroup *group=NULL;
		int recalcScrollBar=0,shouldShow;
		HANDLE hSelItem=NULL;
		struct ClcContact *selcontact=NULL;
		pdisplayNameCacheEntry cacheEntry = GetContactFullCacheEntry((HANDLE)wParam);

		WORD status;
		int NeedResort=0;

		char *szProto = cacheEntry->szProto;
		if(szProto==NULL) status=ID_STATUS_OFFLINE;
		else status=cacheEntry->status;
		
		shouldShow=(GetWindowLong(hwnd,GWL_STYLE)&CLS_SHOWHIDDEN || !cacheEntry->Hidden) && (!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline || CallService(MS_CLIST_GETCONTACTICON,wParam,0)!=LOWORD(lParam));	//this means an offline msg is flashing, so the contact should be shown
		if(!FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL)) {				
			if(shouldShow && CallService(MS_DB_CONTACT_IS, wParam, 0)) {
				if(dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL)!=-1)
					hSelItem=pcli->pfnContactToHItem(selcontact);
				AddContactToTree(hwnd,dat,(HANDLE)wParam,0,0);
				NeedResort=1;
				recalcScrollBar=1;					
				FindItem(hwnd,dat,(HANDLE)wParam,&contact,NULL,NULL);
				if (contact) {						
					contact->iImage=(WORD)lParam;
					pcli->pfnNotifyNewContact(hwnd,(HANDLE)wParam);
					dat->NeedResort=1;
				}
			}				
		}
		else {
			//item in list already
			DWORD style=GetWindowLong(hwnd,GWL_STYLE);				
			if(contact->iImage== (WORD)lParam) break;				
			if (sortByStatus) dat->NeedResort=1;

			if(!shouldShow && !(style&CLS_NOHIDEOFFLINE) && (style&CLS_HIDEOFFLINE || group->hideOffline)) {
				if(dat->selection>=0 && GetRowByIndex(dat,dat->selection,&selcontact,NULL)!=-1)
					hSelItem=pcli->pfnContactToHItem(selcontact);
				RemoveItemFromGroup(hwnd,group,contact,0);
				recalcScrollBar=1;
				dat->NeedResort=1;
			}
			else {
				int oldflags;
				contact->iImage=(WORD)lParam;
				oldflags=contact->flags;
				if(!pcli->pfnIsHiddenMode(dat,status)||cacheEntry->noHiddenOffline) contact->flags|=CONTACTF_ONLINE;
				else contact->flags&=~CONTACTF_ONLINE;
				if (oldflags!=contact->flags)
					dat->NeedResort=1;
		}	}
		if(hSelItem) {
			struct ClcGroup *selgroup;
			if(FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL))
				dat->selection=GetRowsPriorTo(&dat->list,selgroup,li.List_IndexOf((SortedList*)&selgroup->cl, selcontact));
			else
				dat->selection=-1;
		}

		SortClcByTimer(hwnd);
		if(recalcScrollBar) RecalcScrollBar(hwnd,dat);			
		goto LBL_Exit;
	}
	case INTM_STATUSMSGCHANGED:
	{	struct ClcContact *contact=NULL;
		struct ClcGroup *group=NULL;
		DBVARIANT dbv;

		if (!(dat->style&CLS_SHOWSTATUSMESSAGES)) break;
		if(FindItem(hwnd,dat,(HANDLE)wParam,&contact,&group,NULL) && contact!=NULL) {
			contact->flags &= ~CONTACTF_STATUSMSG;
			if (!DBGetContactSettingTString((HANDLE)wParam, "CList", "StatusMsg", &dbv)) {
				int j;
				if (dbv.ptszVal==NULL||_tcslen(dbv.ptszVal)==0) break;
				lstrcpyn(contact->szStatusMsg, dbv.ptszVal, SIZEOF(contact->szStatusMsg));
				for (j=(int)_tcslen(contact->szStatusMsg)-1;j>=0;j--) {
					if (contact->szStatusMsg[j]=='\r' || contact->szStatusMsg[j]=='\n' || contact->szStatusMsg[j]=='\t') {
						contact->szStatusMsg[j] = ' ';
					}
				}
				DBFreeVariant(&dbv);
				if (_tcslen(contact->szStatusMsg)>0) {
					contact->flags |= CONTACTF_STATUSMSG;
					dat->NeedResort=TRUE;
				}
			}
		}

		InvalidateRect(hwnd,NULL,TRUE);

		SortClcByTimer(hwnd);
		RecalcScrollBar(hwnd,dat);
		goto LBL_Exit;
	}
	case WM_TIMER:
		if (wParam==TIMERID_DELAYEDREPAINT) {
			KillTimer(hwnd,TIMERID_DELAYEDREPAINT);
			InvalidateRect(hwnd,NULL,FALSE);
			break;
		}

		if ( wParam == TIMERID_SUBEXPAND) {		
			KillTimer(hwnd,TIMERID_SUBEXPAND);
			if (hitcontact) {
				if (hitcontact->SubExpanded) hitcontact->SubExpanded=0; else hitcontact->SubExpanded=1;
				DBWriteContactSettingByte(hitcontact->hContact,"CList","Expanded",hitcontact->SubExpanded);
			}
			hitcontact=NULL;
			dat->NeedResort=1;
			SortCLC(hwnd,dat,1);		
			RecalcScrollBar(hwnd,dat);
			break;
		}			
		break;

	case WM_DESTROY:
		FreeDisplayNameCache(&dat->lCLCContactsCache);
		stopStatusUpdater = 1;
		break;
	}

	{	LRESULT res = saveContactListControlWndProc(hwnd, msg, wParam, lParam);
		switch (msg) {
			case WM_CREATE:
				mir_forkthread(StatusUpdaterThread,0);
				break;
		}
		return res;
	}

LBL_Exit:
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
Esempio n. 6
0
int HitTest(HWND hwnd,struct ClcData *dat,int testx,int testy,struct ClcContact **contact,struct ClcGroup **group,DWORD *flags)
{
	struct ClcContact *hitcontact;
	struct ClcGroup *hitgroup;
	int hit;
	RECT clRect;

	if(flags) *flags=0;
	GetClientRect(hwnd,&clRect);
	if(testx<0 || testy<0 || testy>=clRect.bottom || testx>=clRect.right) {
		if(flags) {
			if(testx<0) *flags|=CLCHT_TOLEFT;
			else if(testx>=clRect.right) *flags|=CLCHT_TORIGHT;
			if(testy<0) *flags|=CLCHT_ABOVE;
			else if(testy>=clRect.bottom) *flags|=CLCHT_BELOW;
		}
		return -1;
	}
	if(testx<dat->leftMargin) {
		if(flags) *flags|=CLCHT_INLEFTMARGIN|CLCHT_NOWHERE;
		return -1;
	}

	// Get hit item 
	hit = RowHeights_HitTest(dat, dat->yScroll + testy);

	if (hit != -1) 
		hit = GetRowByIndex(dat, hit, &hitcontact, &hitgroup);
	
	if(hit==-1) {
		if(flags) *flags|=CLCHT_NOWHERE|CLCHT_BELOWITEMS;
		return -1;
	}
	if(contact) *contact=hitcontact;
	if(group) *group=hitgroup;
	/////////

	if (testx<hitcontact->pos_indent) 
	{
		if(flags) *flags|=CLCHT_ONITEMINDENT;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_check, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMCHECK;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_avatar, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMICON;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_icon, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMICON;
		return hit;
	}
	
//	if (testx>hitcontact->pos_extra) {
//		if(flags)
		{
//			int c = -1;
			int i;
			for(i = 0; i < dat->extraColumnsCount; i++) 
			{  
			if (RectHitTest(&hitcontact->pos_extra[i], testx, testy)) 
					{
				if(flags) *flags|=CLCHT_ONITEMEXTRA|(i<<24);
						return hit;
					}
				}
			}
	
	if (DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==1) // || DBGetContactSettingByte(NULL,"CLC","HiLightMode",0)==2)
		{
		if(flags) *flags|=CLCHT_ONITEMLABEL;
		return hit;
	}

	if (RectHitTest(&hitcontact->pos_label, testx, testy)) 
	{
		if(flags) *flags|=CLCHT_ONITEMLABEL;
		return hit;
	}

	if(flags) *flags|=CLCHT_NOWHERE;
	return -1;
}
Esempio n. 7
0
int GetDropTargetInformation(HWND hwnd,struct ClcData *dat,POINT pt)
{
	RECT clRect;
	int hit;
	struct ClcContact *contact,*movecontact;
	struct ClcGroup *group,*movegroup;
	DWORD hitFlags;

	GetClientRect(hwnd,&clRect);
	dat->selection=dat->iDragItem;
	dat->iInsertionMark=-1;
	if(!PtInRect(&clRect,pt)) return DROPTARGET_OUTSIDE;

	hit=HitTest(hwnd,dat,pt.x,pt.y,&contact,&group,&hitFlags);
	GetRowByIndex(dat,dat->iDragItem,&movecontact,&movegroup);
	if(hit==dat->iDragItem) return DROPTARGET_ONSELF;
	if(hit==-1 || hitFlags&CLCHT_ONITEMEXTRA) return DROPTARGET_ONNOTHING;

	if(movecontact->type==CLCIT_GROUP) {
		struct ClcContact *bottomcontact=NULL,*topcontact=NULL;
		struct ClcGroup *topgroup=NULL;
		int topItem=-1,bottomItem;
		int ok=0;
		if(pt.y+dat->yScroll<RowHeights_GetItemTopY(dat,hit)+dat->insertionMarkHitHeight) {
			//could be insertion mark (above)
			topItem=hit-1; bottomItem=hit;
			bottomcontact=contact;
			topItem=GetRowByIndex(dat,topItem,&topcontact,&topgroup);
			ok=1;
		}
		if(pt.y+dat->yScroll>=RowHeights_GetItemTopY(dat,hit+1)-dat->insertionMarkHitHeight) {
			//could be insertion mark (below)
			topItem=hit; bottomItem=hit+1;
			topcontact=contact; topgroup=group;
			bottomItem=GetRowByIndex(dat,bottomItem,&bottomcontact,NULL);
			ok=1;
		}
		if(ok) {
			ok=0;
			if(bottomItem==-1 || bottomcontact->type!=CLCIT_GROUP) {	   //need to special-case moving to end
				if(topItem!=dat->iDragItem) {
					for(;topgroup;topgroup=topgroup->parent) {
						if(topgroup==movecontact->group) break;
						if(topgroup==movecontact->group->parent) {ok=1; break;}
					}
					if(ok) bottomItem=topItem+1;
				}
			}
			else if(bottomItem!=dat->iDragItem && bottomcontact->type==CLCIT_GROUP && bottomcontact->group->parent==movecontact->group->parent) {
				if(bottomcontact!=movecontact+1) ok=1;
			}
			if(ok) {
			    dat->iInsertionMark=bottomItem;
				dat->selection=-1;
				return DROPTARGET_INSERTION;
			}
		}
	}
	if(contact->type==CLCIT_GROUP) {
		if(dat->iInsertionMark==-1) {
			if(movecontact->type==CLCIT_GROUP) {	 //check not moving onto its own subgroup
				for(;group;group=group->parent) if(group==movecontact->group) return DROPTARGET_ONSELF;
			}
			dat->selection=hit;
			return DROPTARGET_ONGROUP;
		}
	}
    dat->selection=hit;

    if (!MyStrCmp(contact->proto,"MetaContacts")&& (ServiceExists(MS_MC_ADDTOMETA))) return DROPTARGET_ONMETACONTACT;
    if (contact->isSubcontact && (ServiceExists(MS_MC_ADDTOMETA))) return DROPTARGET_ONSUBCONTACT;
	return DROPTARGET_ONCONTACT;
}
Esempio n. 8
0
void BeginRenameSelection(HWND hwnd,struct ClcData *dat)
{
	struct ClcContact *contact;
	struct ClcGroup *group;
	int indent,x,y,subident, h,w;
	RECT clRect;
  RECT r;


	KillTimer(hwnd,TIMERID_RENAME);
	ReleaseCapture();
	dat->iHotTrack=-1;
	dat->selection=GetRowByIndex(dat,dat->selection,&contact,&group);
	if(dat->selection==-1) return;
	if(contact->type!=CLCIT_CONTACT && contact->type!=CLCIT_GROUP) return;
	
	if (contact->type==CLCIT_CONTACT && contact->isSubcontact)
        subident=dat->subIndent;
	else 
		subident=0;
	
	for(indent=0;group->parent;indent++,group=group->parent);
	GetClientRect(hwnd,&clRect);
    x=indent*dat->groupIndent+dat->iconXSpace-2+subident;
	w=clRect.right-x;
	y=RowHeights_GetItemTopY(dat, dat->selection)-dat->yScroll;
    h=dat->row_heights[dat->selection];
    {
        int i;
        for (i=0; i<=FONTID_MAX; i++)
           if (h<dat->fontInfo[i].fontHeight+2) h=dat->fontInfo[i].fontHeight+2;
    }
    //TODO contact->pos_label 

  
{
      
       RECT rectW;      
       GetWindowRect(hwnd,&rectW);
//       w=contact->pos_full_first_row.right-contact->pos_full_first_row.left;
//       h=contact->pos_full_first_row.bottom-contact->pos_full_first_row.top;
       //w=clRect.right-x;
       x+=rectW.left;//+contact->pos_full_first_row.left;
       y+=rectW.top;//+contact->pos_full_first_row.top;
  }

  {
    int a=0;
    if (contact->type==CLCIT_GROUP)
    {
      if (dat->row_align_group_mode==1) a|=ES_CENTER;
      else if (dat->row_align_group_mode==2) a|=ES_RIGHT;
    }
    if (dat->text_rtl) a|=EN_ALIGN_RTL_EC;
	  dat->hwndRenameEdit=CreateWindow(TEXT("EDIT"),contact->szText,WS_POPUP|WS_BORDER|ES_AUTOHSCROLL|a,x,y,w,h,hwnd,NULL,g_hInst,NULL);
  }
    SetWindowLong(dat->hwndRenameEdit,GWL_STYLE,GetWindowLong(dat->hwndRenameEdit,GWL_STYLE)&(~WS_CAPTION)|WS_BORDER);
    SetWindowLong(dat->hwndRenameEdit,GWL_USERDATA,(LONG)dat);
	OldRenameEditWndProc=(WNDPROC)SetWindowLong(dat->hwndRenameEdit,GWL_WNDPROC,(LONG)RenameEditSubclassProc);
	SendMessage(dat->hwndRenameEdit,WM_SETFONT,(WPARAM)(contact->type==CLCIT_GROUP?dat->fontInfo[FONTID_GROUPS].hFont:dat->fontInfo[FONTID_CONTACTS].hFont),0);
	SendMessage(dat->hwndRenameEdit,EM_SETMARGINS,EC_LEFTMARGIN|EC_RIGHTMARGIN|EC_USEFONTINFO,0);
	SendMessage(dat->hwndRenameEdit,EM_SETSEL,0,(LPARAM)(-1));
 // SetWindowLong(dat->hwndRenameEdit,GWL_USERDATA,(LONG)hwnd);
    r.top=1;
    r.bottom=h-1;
    r.left=0;
    r.right=w;

    //ES_MULTILINE

    SendMessage(dat->hwndRenameEdit,EM_SETRECT,0,(LPARAM)(&r));
    
	ShowWindowNew(dat->hwndRenameEdit,SW_SHOW);
  SetWindowPos(dat->hwndRenameEdit,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
	SetFocus(dat->hwndRenameEdit);
}
Esempio n. 9
0
void SortCLC(HWND hwnd,struct ClcData *dat,int useInsertionSort)
{
	struct ClcContact *selcontact;
	struct ClcGroup *group=&dat->list,*selgroup;
	int dividers=dat->exStyle&CLS_EX_DIVIDERONOFF;
	HANDLE hSelItem;
	int tick=GetTickCount();
	if (dat->NeedResort==1 &&1)
	{

		if(GetRowByIndex(dat,dat->selection,&selcontact,NULL)==-1) hSelItem=NULL;
		else hSelItem=ContactToHItem(selcontact);
		group->scanIndex=0;
		
		SortGroup(dat,group,useInsertionSort);
		
		for(;;) {
			if(group->scanIndex==group->contactCount) {
				group=group->parent;
				if(group==NULL) break;
			}
			else if(group->contact[group->scanIndex].type==CLCIT_GROUP) {
				group=group->contact[group->scanIndex].group;
				group->scanIndex=0;
				SortGroup(dat,group,useInsertionSort);
				continue;
			}
			group->scanIndex++;
		}
		
		ClearClcContactCache(dat,INVALID_HANDLE_VALUE);

		if(hSelItem)
			if(FindItem(hwnd,dat,hSelItem,&selcontact,&selgroup,NULL,FALSE))
				dat->selection=GetRowsPriorTo(&dat->list,selgroup,selcontact-selgroup->contact);
		
		
		RecalcScrollBar(hwnd,dat);
		ClearRowByIndexCache();
	}else
	{
		//TRACE("Not need to sort\r\n");
	};
    
	InvalidateRectZ(hwnd,NULL,FALSE);
	dat->NeedResort=0;
   // LOCK_IMAGE_UPDATING=1;
   // RecalcScrollBar(hwnd,dat);
#ifdef _DEBUG
	tick=GetTickCount()-tick;
	{
	char buf[255];
	//sprintf(buf,"%s %s took %i ms",__FILE__,__LINE__,tick);
		if (tick>5) 
		{
			sprintf(buf,"SortCLC %d \r\n",tick);
			TRACE(buf);
			DBWriteContactSettingDword((HANDLE)0,"CLUI","PF:Last SortCLC Time:",tick);
		}
	}
#endif	
}