コード例 #1
0
ファイル: init.cpp プロジェクト: tweimer/miranda-ng
int CMPlugin::Unload()
{
	if (IsWindow(g_clistApi.hwndContactList))
		DestroyWindow(g_clistApi.hwndContactList);
	ClcShutdown(0, 0);
	UnLoadCLUIFramesModule();
	return 0;
}
コード例 #2
0
ファイル: init.cpp プロジェクト: TonyAlloa/miranda-dev
extern "C" int __declspec(dllexport) Unload(void)
{
	if (IsWindow(pcli->hwndContactList))
		DestroyWindow(pcli->hwndContactList);
	ImageList_Destroy(himlExtraImages);
	ClcShutdown(0, 0);
	UnLoadCLUIFramesModule();
	return 0;
}
コード例 #3
0
ファイル: clui.c プロジェクト: raoergsls/miranda
LRESULT CALLBACK ContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{     
	/*
	This registers a window message with RegisterWindowMessage() and then waits for such a message,
	if it gets it, it tries to open a file mapping object and then maps it to this process space,
	it expects 256 bytes of data (incl. NULL) it will then write back the profile it is using the DB to fill in the answer.
	
	  The caller is expected to create this mapping object and tell us the ID we need to open ours.	
	*/
	if (msg==hMsgGetProfile && wParam != 0) { /* got IPC message */
		HANDLE hMap;
		char szName[MAX_PATH];
		int rc=0;
		_snprintf(szName,SIZEOF(szName),"Miranda::%u", wParam); // caller will tell us the ID of the map
		hMap = OpenFileMappingA(FILE_MAP_ALL_ACCESS,FALSE,szName);
		if (hMap != NULL) {
			void *hView=NULL;
			hView=MapViewOfFile(hMap, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH);
			if (hView) {
				char szFilePath[MAX_PATH], szProfile[MAX_PATH];
				CallService(MS_DB_GETPROFILEPATH,MAX_PATH,(LPARAM)&szFilePath);
				CallService(MS_DB_GETPROFILENAME,MAX_PATH,(LPARAM)&szProfile);
				_snprintf(hView,MAX_PATH,"%s\\%s",szFilePath,szProfile);
				UnmapViewOfFile(hView);
				rc=1;
			}
			CloseHandle(hMap);
		}
		return rc;
	}

	switch (msg) {
	case WM_CREATE:
		TranslateMenu(GetMenu(hwnd));
		DrawMenuBar(hwnd);
		showOpts=DBGetContactSettingByte(NULL,"CLUI","SBarShow",1);		

		//create the status wnd
		//pcli->hwndStatus = CreateStatusWindow(WS_CHILD | (DBGetContactSettingByte(NULL,"CLUI","ShowSBar",1)?WS_VISIBLE:0), "", hwnd, 0);	
		CluiProtocolStatusChanged(0,0);
		
		hMsgGetProfile = RegisterWindowMessageA( "Miranda::GetProfile" ); // don't localise
		
		if ( DBGetContactSettingByte( NULL, "CList", "Transparent", 0 )) {
			SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
			if ( MySetLayeredWindowAttributes )
				MySetLayeredWindowAttributes(hwnd, RGB(0,0,0), (BYTE)DBGetContactSettingByte(NULL,"CList","Alpha",SETTING_ALPHA_DEFAULT), LWA_ALPHA);
		}
		transparentFocus=1;
		return FALSE;

	case M_SETALLEXTRAICONS:
		return TRUE;

	case M_CREATECLC:
		CreateCLC(hwnd);
		return TRUE;

	case WM_SIZE:
	{
		RECT rc;
		if ( wParam != SIZE_MINIMIZED ) {
			if ( pcli->hwndContactList != NULL )
				CLUIFramesOnClistResize((WPARAM)hwnd,(LPARAM)0);

			GetWindowRect(hwnd, &rc);		
			if(!CallService(MS_CLIST_DOCKINGISDOCKED,0,0)) {
				//if docked, dont remember pos (except for width)
				DBWriteContactSettingDword(NULL,"CList","Height",(DWORD)(rc.bottom - rc.top));
				DBWriteContactSettingDword(NULL,"CList","x",(DWORD)rc.left);
				DBWriteContactSettingDword(NULL,"CList","y",(DWORD)rc.top);
			}
			DBWriteContactSettingDword(NULL,"CList","Width",(DWORD)(rc.right - rc.left));		
		}
		if ( wParam == SIZE_MINIMIZED ) {
			if ( DBGetContactSettingByte(NULL,"CList","Min2Tray",SETTING_MIN2TRAY_DEFAULT )) {
				ShowWindow(hwnd, SW_HIDE);
				DBWriteContactSettingByte(NULL,"CList","State",SETTING_STATE_HIDDEN);
			}
			else DBWriteContactSettingByte(NULL,"CList","State",SETTING_STATE_MINIMIZED);
		}
		return 0;
	}
			
	case WM_SETFOCUS:
	{	
		boolean isfloating;
		if ( hFrameContactTree ) {					
			isfloating = CallService(MS_CLIST_FRAMES_GETFRAMEOPTIONS,MAKEWPARAM(FO_FLOATING,hFrameContactTree),0);
			if ( isfloating == FALSE)
				SetFocus(pcli->hwndContactTree);
		}
		return 0;
	}
   case WM_TIMER:
		if ((int)wParam>=TM_STATUSBARUPDATE&&(int)wParam<=TM_STATUSBARUPDATE+64) {
			int status,i;

			ProtoTicks *pt=NULL;
			for (i=0;i<64;i++) {
				pt=&CycleStartTick[i];
				if (pt->szProto!=NULL&&pt->TimerCreated==1) {
					status=CallProtoService(pt->szProto,PS_GETSTATUS,0,0);
					if (!(status>=ID_STATUS_CONNECTING&&status<=ID_STATUS_CONNECTING+MAX_CONNECT_RETRIES))
					{													
						pt->CycleStartTick=0;
						KillTimer(hwnd,TM_STATUSBARUPDATE+pt->n);
						pt->TimerCreated=0;
			}	}	}

			pt=&CycleStartTick[wParam-TM_STATUSBARUPDATE];
			{
				RECT rc;
				GetStatsuBarProtoRect(pcli->hwndStatus,pt->szProto,&rc);
				rc.right=rc.left+GetSystemMetrics(SM_CXSMICON)+1;
				rc.top=0;

				if(IsWindowVisible(pcli->hwndStatus)) InvalidateRect(pcli->hwndStatus,&rc,TRUE);
				pcli->pfnTrayIconUpdateBase(pt->szProto);
			}
			//SendMessage(pcli->hwndStatus,WM_PAINT,0,0);
			UpdateWindow(pcli->hwndStatus);
			return TRUE;
		}
		break;

	case WM_DRAWITEM:
	{
		LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
		if ( dis->hwndItem == pcli->hwndStatus ) {
			DrawDataForStatusBar(dis);
			return 0;
		}
		if ( dis->CtlType != ODT_MENU )
			return 0;
		break;
	}
	case WM_KEYDOWN:
		CallService(MS_CLIST_MENUPROCESSHOTKEY,wParam,MPCF_MAINMENU|MPCF_CONTACTMENU);
		if (wParam==VK_F5)
			SendMessage(pcli->hwndContactTree,CLM_AUTOREBUILD,0,0);
		return TRUE;
				
	case WM_GETMINMAXINFO:
		DefWindowProc(hwnd,msg,wParam,lParam);
		((LPMINMAXINFO)lParam)->ptMinTrackSize.x=18;
		if (requr==0){((LPMINMAXINFO)lParam)->ptMinTrackSize.y=CLUIFramesGetMinHeight();}
		return 0;
				
	//MSG FROM CHILD CONTROL
	case WM_NOTIFY:
		if (((LPNMHDR)lParam)->hwndFrom == pcli->hwndContactTree) {
			switch (((LPNMHDR)lParam)->code) {
			case CLN_NEWCONTACT:
				{
					NMCLISTCONTROL *nm=(NMCLISTCONTROL *)lParam;
					if (nm!=NULL) SetAllExtraIcons(pcli->hwndContactTree,nm->hItem );
					return TRUE;
				}
			case CLN_LISTREBUILT:
				SetAllExtraIcons(pcli->hwndContactTree,0);
				return(FALSE);

			case CLN_LISTSIZECHANGE:
				{
					NMCLISTCONTROL *nmc=(NMCLISTCONTROL*)lParam;
					RECT rcWindow,rcTree,rcWorkArea;
					int maxHeight,newHeight;
					int winstyle;

					if ( !disableautoupd && DBGetContactSettingByte( NULL, "CLUI", "AutoSize", 0 )) {
						if ( !CallService(MS_CLIST_DOCKINGISDOCKED,0,0) && hFrameContactTree != 0 ) {
							maxHeight=DBGetContactSettingByte(NULL,"CLUI","MaxSizeHeight",75);
							GetWindowRect(hwnd,&rcWindow);
							GetWindowRect(pcli->hwndContactTree,&rcTree);
							winstyle=GetWindowLong(pcli->hwndContactTree,GWL_STYLE);

							SystemParametersInfo(SPI_GETWORKAREA,0,&rcWorkArea,FALSE);
							lastreqh=nmc->pt.y;
							newHeight=max(nmc->pt.y,3)+1+((winstyle&WS_BORDER)?2:0)+(rcWindow.bottom-rcWindow.top)-(rcTree.bottom-rcTree.top);
							if (newHeight != rcWindow.bottom - rcWindow.top ) {
								if(newHeight>(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100)
									newHeight=(rcWorkArea.bottom-rcWorkArea.top)*maxHeight/100;
								if(DBGetContactSettingByte(NULL,"CLUI","AutoSizeUpward",0)) {
									rcWindow.top=rcWindow.bottom-newHeight;
									if(rcWindow.top<rcWorkArea.top) rcWindow.top=rcWorkArea.top;
								}
								else {
									rcWindow.bottom=rcWindow.top+newHeight;
									if(rcWindow.bottom>rcWorkArea.bottom) rcWindow.bottom=rcWorkArea.bottom;
								}
								
								if (requr == 0) {
									requr=1;					
									SetWindowPos(hwnd,0,rcWindow.left,rcWindow.top,rcWindow.right-rcWindow.left,rcWindow.bottom-rcWindow.top,SWP_NOZORDER|SWP_NOACTIVATE);
									GetWindowRect(hwnd,&rcWindow);
									requr=0;
					}	}	}	}
					return TRUE;
				}
			case NM_CLICK:
				{	
					NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
					DWORD hitFlags;
					HANDLE hItem = (HANDLE)SendMessage(pcli->hwndContactTree,CLM_HITTEST,(WPARAM)&hitFlags,MAKELPARAM(nm->pt.x,nm->pt.y));

					if (hitFlags&CLCHT_ONITEMEXTRA) {					
						if (!IsHContactGroup(hItem)&&!IsHContactInfo(hItem))
						{
							int extra;
							pdisplayNameCacheEntry pdnce; 

							pdnce = (pdisplayNameCacheEntry)pcli->pfnGetCacheEntry(nm->hItem);
							if (pdnce==NULL) return 0;

							extra = ColumnNumToExtra(nm->iColumn);
							NotifyEventHooks(hExtraImageClick, (WPARAM)nm->hItem, extra);

							if (!ServiceExists("ExtraIcon/Register"))
							{
								int v,e,w;
								v=ExtraToColumnNum(EXTRA_ICON_PROTO);
								e=ExtraToColumnNum(EXTRA_ICON_EMAIL);
								w=ExtraToColumnNum(EXTRA_ICON_ADV1);

								if(nm->iColumn==v)
									CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);

								if(nm->iColumn==e) {
									//CallService(MS_USERINFO_SHOWDIALOG,(WPARAM)nm->hItem,0);
									char *email,buf[4096];
									email=DBGetStringA(nm->hItem,"UserInfo", "Mye-mail0");
									if (email) {
										sprintf(buf,"mailto:%s",email);
										ShellExecuteA(hwnd,"open",buf,NULL,NULL,SW_SHOW);
									}											
								}	
								if(nm->iColumn==w) {
									char *homepage;
									homepage=DBGetStringA(pdnce->hContact,pdnce->szProto, "Homepage");
									if (homepage!=NULL)
										ShellExecuteA(hwnd,"open",homepage,NULL,NULL,SW_SHOW);
					}	}	}	}

					if(hItem) break;
					if((hitFlags&(CLCHT_NOWHERE|CLCHT_INLEFTMARGIN|CLCHT_BELOWITEMS))==0) break;
					if (DBGetContactSettingByte(NULL,"CLUI","ClientAreaDrag",SETTING_CLIENTDRAG_DEFAULT)) {
						POINT pt;
						pt=nm->pt;
						ClientToScreen(pcli->hwndContactTree,&pt);
						return SendMessage(hwnd, WM_SYSCOMMAND, SC_MOVE|HTCAPTION,MAKELPARAM(pt.x,pt.y));
					}
					return TRUE;
				}
			}
		}
		else if(((LPNMHDR)lParam)->hwndFrom==pcli->hwndStatus) {
			if (((LPNMHDR)lParam)->code == NM_CLICK ) {
				int nParts=0, nPanel=0;
				NMMOUSE *nm=(NMMOUSE*)lParam;
				HMENU hMenu;
				RECT rc;
				POINT pt;
				int totcount;
				ProtocolData *PD;
				int menuid;
				int startoffset=DBGetContactSettingDword(NULL,"StatusBar","FirstIconOffset",0);
				int extraspace=DBGetContactSettingDword(NULL,"StatusBar","BkExtraSpace",0);
				boolean UseOwnerDrawStatusBar=DBGetContactSettingByte(NULL,"CLUI","UseOwnerDrawStatusBar",0);
					
				hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
				nParts=SendMessage(pcli->hwndStatus,SB_GETPARTS,0,0);
						
				if (nm->dwItemSpec==0xFFFFFFFE) {
					nPanel=nParts-1;
					SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
					if (nm->pt.x < rc.left) return FALSE;
				} 
				else { 
					if (!((startoffset)!=0&&UseOwnerDrawStatusBar))
					{								
						nPanel=nm->dwItemSpec; 
						SendMessage(pcli->hwndStatus,SB_GETRECT,nPanel,(LPARAM)&rc);
					}
					else {
						RECT clrc;
						int sectwidth;

						memset(&rc,0,sizeof(RECT));
						GetClientRect(pcli->hwndStatus,&clrc);
						clrc.right-=clrc.left;
						clrc.right-=startoffset;
						sectwidth=clrc.right/nParts;

						for (nPanel=0;nPanel<nParts;nPanel++) {
							PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
							if(PD==NULL)
								continue;

							rc.top=0;
							rc.bottom=clrc.bottom;
							rc.left=nPanel*sectwidth+startoffset;
							rc.right=rc.left+sectwidth-1;

							if (PtInRect(&rc,nm->pt))
								break;
				}	}	}

				totcount=DBGetContactSettingDword(0,"Protocols","ProtoCount",0);
				PD=(ProtocolData *)SendMessage(pcli->hwndStatus,SB_GETTEXT,(WPARAM)nPanel,(LPARAM)0);
				if(PD==NULL){return(0);}
				menuid=nPanel;
						
				if (menuid<0){break;}
				hMenu=(HMENU)CallService(MS_CLIST_MENUGETSTATUS,0,0);
                {
                    int i;
                    unsigned int cpnl = 0;
                    int mcnt = GetMenuItemCount(hMenu);
                    for (i=0; i<mcnt; ++i) {
					    HMENU hMenus = GetSubMenu(hMenu, i);
                        if (hMenus && cpnl++ == menuid) { 
                            hMenu = hMenus; 
                            break; 
                        }
                    }
                }
                {
					char buf[256];
					sprintf(buf,"nPanel: %d, PD->protopos: %d,PD->RealName %s\r\n",nPanel,PD->protopos,PD->RealName);
					OutputDebugStringA(buf);
				}

				if (hMenu != NULL) {						
					GetCursorPos(&pt);
					TrackPopupMenu(hMenu,TPM_BOTTOMALIGN|TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,NULL);
			}	}
			return TRUE;
		}
		break;

	case WM_DESTROY:
		{
			//saving state
			int state = DBGetContactSettingByte(NULL,"CList","State",SETTING_STATE_NORMAL);
			
			FreeProtocolData();
			if ( hSettingChangedHook != 0 )
				UnhookEvent(hSettingChangedHook);
			
			if ( state == SETTING_STATE_NORMAL )
				ShowWindow(hwnd,SW_HIDE);

			CallService(MS_CLIST_FRAMES_REMOVEFRAME,(WPARAM)hFrameContactTree,(LPARAM)0);
			DestroyWindow(pcli->hwndContactTree);
			pcli->hwndContactList=NULL;

			UnLoadCLUIFramesModule();		
			DBWriteContactSettingByte(NULL,"CList","State",(BYTE)state);
       		PostQuitMessage(0);
		}
		break;
	}

	return saveContactListWndProc( hwnd, msg, wParam, lParam );
}