Ejemplo n.º 1
0
BOOL CSampleEditorDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	m_pSampleView = new CSampleView();
	m_pSampleView->SubclassDlgItem(IDC_SAMPLE, this);
	m_pSampleView->CalculateSample(m_pSample, IsDlgButtonChecked(IDC_DELTASTART) ? 64 : 0);
	m_pSampleView->UpdateInfo();

	CSliderCtrl *pitch = (CSliderCtrl*)GetDlgItem(IDC_PITCH);
	pitch->SetRange(0, 15);
	pitch->SetPos(15);

	MoveControls();

	// A timer for the flashing start cursor
	SetTimer(1, 500, NULL);

	CString title;
	GetWindowText(title);
	title.AppendFormat(_T(" [%s]"), m_pSample->Name);
	SetWindowText(title);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 2
0
BOOL CDlg_Search::OnInitDialog() 
{
	CDialog::OnInitDialog();

	LoadBtnBitmaps();
	MoveControls();	 
	
	if( m_edtSearch.GetSafeHwnd())
	{
		m_edtSearch.SetParent((CWnd*)this);
		m_edtSearch.Init();
	}

	GetRecWord();
	
	SetCurrType(TYPE_SRCH_RCMMWORD);
	EnableNetwork(FALSE);
//	ShowControls();

	if( m_btnSearch.GetSafeHwnd() )
		m_btnSearch.ShowWindow(FALSE);  	

	m_bInit = TRUE;

	m_nNodeState = TYPE_SRCH_NETWORK_STATUS_0;
	m_edtSearch.EnableWindow(FALSE);
	m_btnSearch.EnableWindow(FALSE);

	MakeRecommWnd();

	m_nRecommTimer = SetTimer(TID_RECWORDVALID, ELPS_RECWORDVALID, NULL);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 3
0
void CAutoSplitter::OnMove(POINT ptOld, POINT ptNew)
{
	int dx=ptNew.x - ptOld.x;
	int dy=ptNew.y - ptOld.y;

	MoveControls(dx, dy);
}
Ejemplo n.º 4
0
//##ModelId=474D3069039B
void CEditWnd::OnSize(UINT nType, int cx, int cy)
{
	CWnd::OnSize(nType, cx, cy);

	if(::IsWindow(m_ToolBar.GetSafeHwnd()))
	{
		MoveControls();
	}
}
Ejemplo n.º 5
0
//##ModelId=474D30680139
bool CEditWnd::EditIds(CClipIDs &Ids)
{
	int nCount = min(Ids.GetSize(), 10);
	for(int i = 0; i < nCount; i++)
	{
		if(IsIDAlreadyInEdit(Ids[i], true) < 0)
		{
			AddItem(Ids[i]);
		}
	}

	MoveControls();

	return true;
}
Ejemplo n.º 6
0
//##ModelId=474D306902CF
int CEditWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CWnd::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_ToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_TOOLTIPS);
	m_ToolBar.LoadToolBar(IDR_EDIT_WND);
	m_ToolBar.EnableWindow();
	
	m_Tabs.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|SCS_TOP, CRect(0, 0, 0, 0), this, 101);
	
	m_Font.CreatePointFont(90, _T("@Arial Unicode MS"));
	m_cbUpdateDescription.Create(theApp.m_Language.GetString("Update_Desc", "Update clip description on save?"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX, CRect(0,0,0,0), this, 101);
	m_cbUpdateDescription.SetFont(&m_Font);

	if(CGetSetOptions::GetUpdateDescWhenSavingClip())
	{
		m_cbUpdateDescription.SetCheck(BST_CHECKED);
	}

	MoveControls();

	m_ToolTip.Create(this);
	CRect cr;
	CString csText;

	m_ToolBar.GetItemRect(m_ToolBar.CommandToIndex(ID_BUTTON_NEW), cr);
	csText.Format(_T("%s     Ctrl - N"), theApp.m_Language.GetString("New_Clip", "New Clip"));
	m_ToolTip.AddTool(&m_ToolBar, csText, cr, 1);

	m_ToolBar.GetItemRect(m_ToolBar.CommandToIndex(ID_BUTTON_SAVE), cr);
	csText.Format(_T("%s    Ctrl - S"), theApp.m_Language.GetString("Save", "Save"));
	m_ToolTip.AddTool(&m_ToolBar, csText, cr, 2);

	m_ToolBar.GetItemRect(m_ToolBar.CommandToIndex(ID_BUTTON_SAVE_ALL), cr);
	csText.Format(_T("%s    Ctrl - Shift - S"), theApp.m_Language.GetString("Save_All", "Save All"));
	m_ToolTip.AddTool(&m_ToolBar, csText, cr, 3);

	m_ToolBar.GetItemRect(m_ToolBar.CommandToIndex(ID_BUTTON_CLOSE), cr);
	csText.Format(_T("%s    Escape"), theApp.m_Language.GetString("Close", "Close Current Tab"));
	m_ToolTip.AddTool(&m_ToolBar, csText, cr, 4);

	m_ToolBar.GetItemRect(m_ToolBar.CommandToIndex(ID_BUTTON_SAVE_CLOSE_CLIPBOARD), cr);
	csText.Format(_T("%s    Shift - Escape"), theApp.m_Language.GetString("Save_Close", "Save, Close and place on clipboard"));
	m_ToolTip.AddTool(&m_ToolBar, csText, cr, 4);

	return 0;
}
Ejemplo n.º 7
0
void CDlg_Search::OnSize(UINT nType, int cx, int cy) 
{
//	TRACE(_T("CDlg_Search::OnSize\r\n"));
//	CDialog::OnSize(nType, cx, cy);

	MoveControls();

	if( m_bMakeInfoNSetRange == FALSE )
	{
		if( cx == BTN_DLG_SRCH_WIDTH )
		{
			MakeInfoNSetRange();
			m_bMakeInfoNSetRange = TRUE;
		}			
	}
	
}
Ejemplo n.º 8
0
void CSectionHandler::MoveSize(int iX,int iY,int iWidth,int iHeight)
{
	int iXOffset=iX-GetX(),iYOffset=iY-GetY();
	if(iXOffset!=0 || iYOffset!=0)
	{
		ShiftControls(iXOffset,iYOffset);
		m_iX=iX;
		m_iY=iY;
	}

	int iWidthOffset=iWidth-GetWidth(),iHeightOffset=iHeight-GetHeight();
	if(iWidthOffset!=m_iWidthOffset || iHeightOffset!=m_iHeightOffset) 
	{
		MoveControls(
			iWidthOffset-m_iWidthOffset,iHeightOffset-m_iHeightOffset,
			GetSplitX(),GetSplitY());
		int iPreviousWOffset=m_iWidthOffset,iPreviousHOffset=m_iHeightOffset;
		m_iWidthOffset=iWidthOffset;
		m_iHeightOffset=iHeightOffset;
		InformResize(iPreviousWOffset,iPreviousHOffset);
	}
}
Ejemplo n.º 9
0
void CAutoSplitter::SetPosition(int iPos)
{
	if (iPos<0)
		return;

	ASSERT(GetSize()>0);

	// Get the first control
	CAutoSizeControl* pControl=GetAt(0);

	// Get its current position
	RECT rc;
	GetWindowRect(pControl->m_hWndControl, &rc);
	ScreenToClient(m_hWndParent, (LPPOINT)&rc.left);
	ScreenToClient(m_hWndParent, (LPPOINT)&rc.right);

	int dx=0;
	int dy=0;
	if (pControl->m_dwFlags & ASF_LEFT)
		{
		dx=iPos-rc.left;
		}
	if (pControl->m_dwFlags & ASF_RIGHT)
		{
		dx=iPos-rc.right;
		}
	if (pControl->m_dwFlags & ASF_TOP)
		{
		dy=iPos-rc.top;
		}
	if (pControl->m_dwFlags & ASF_BOTTOM)
		{
		dy=iPos-rc.bottom;
		}

	MoveControls(dx, dy);
}
Ejemplo n.º 10
0
void CSampleEditorDlg::OnSize(UINT nType, int cx, int cy)
{
	CDialog::OnSize(nType, cx, cy);
	MoveControls();
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
// LaunchAppDialogProc()
//-----------------------------------------------------------------------------
// DialogProc de la fenêtre de lancement d'application 
//-----------------------------------------------------------------------------
static int CALLBACK LaunchAppDialogProc(HWND w,UINT msg,WPARAM wp,LPARAM lp)
{
	UNREFERENCED_PARAMETER(lp);
//	TRACE((TRACE_DEBUG,_F_,"msg=0x%08lx LOWORD(wp)=0x%04x HIWORD(wp)=%d lp=%d",msg,LOWORD(wp),HIWORD(wp),lp));
	CheckIfQuitMessage(msg);
	int rc=FALSE;
	switch (msg)
	{
		case WM_INITDIALOG:		// ------------------------------------------------------- WM_INITDIALOG
			OnInitDialog(w);
			MoveControls(w); 
			break;
		case WM_DESTROY:
			//
			break;
		case WM_HELP:
			Help();
			break;
		case WM_TIMER:
			TRACE((TRACE_INFO,_F_,"WM_TIMER (SetForeground)"));
			if (giSetForegroundTimer==(int)wp) 
			{ 
				KillTimer(w,giSetForegroundTimer);
				SetForegroundWindow(w); 
				SetFocus(w); 
			}
			break;
		case WM_COMMAND:		// ------------------------------------------------------- WM_COMMAND
			//TRACE((TRACE_DEBUG,_F_,"WM_COMMAND LOWORD(wp)=0x%04x HIWORD(wp)=%d lp=%d",LOWORD(wp),HIWORD(wp),lp));
			switch (LOWORD(wp))
			{
				case IDOK:
					if (HIWORD(wp)==0) // les notifications autres que "from a control" ne nous intéressent pas !
					{
						LaunchSelectedApp(w);
					}
					break;
				case IDCANCEL:
					if (HIWORD(wp)==0) // les notifications autres que "from a control" ne nous intéressent pas !
					{
						SaveWindowPos(w);
						EndDialog(w,IDCANCEL);
					}
					break;
				case CK_VISIBLE:
					gbLaunchTopMost=(IsDlgButtonChecked(w,CK_VISIBLE)==BST_CHECKED);
					SetWindowPos(w,gbLaunchTopMost?HWND_TOPMOST:HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
					break;
			}
			break;
		case WM_SIZE:			// ------------------------------------------------------- WM_SIZE
			MoveControls(w); 
			break;
		case WM_NOTIFY:			// ------------------------------------------------------- WM_NOTIFY
			switch (((NMHDR FAR *)lp)->code) 
			{
				case NM_DBLCLK:
					if (wp==TV_APPLICATIONS) 
					{
						LaunchSelectedApp(w);
					}
					break;
				case TVN_KEYDOWN:
					{
						LPNMTVKEYDOWN ptvkd = (LPNMTVKEYDOWN)lp;
						switch (ptvkd->wVKey)
						{
							case VK_F5:
								FillTreeView(w);
								break;
						}
					}
					break;
			}
			break;
	}
	return rc;
}
Ejemplo n.º 12
0
// --------------------------------------------------
LRESULT CALLBACK GUIProc (HWND hwnd, UINT message,
                                 WPARAM wParam, LPARAM lParam)
{

	static const struct 
		{
			LRESULT from; // 変換元
			LRESULT to;   // 変換先
		}
	trans[] = 
		{
			{ HTLEFT,        HTBORDER }, // 左端の左右矢印 → 矢印なし
			{ HTRIGHT,       HTBORDER }, // 右端の左右矢印 → 矢印なし
			{ HTTOPLEFT,     HTTOP    }, // 左上隅の斜め矢印 → 縦矢印
			{ HTTOPRIGHT,    HTTOP    }, // 右上隅の斜め矢印 → 縦矢印
			{ HTBOTTOMLEFT,  HTBOTTOM }, // 左下隅の斜め矢印 → 縦矢印
			{ HTBOTTOMRIGHT, HTBOTTOM }, // 右下隅の斜め矢印 → 縦矢印
			{ HTTOP,         HTTOP    },
			{ HTBOTTOM,      HTBOTTOM }
		};


	bool rectflg = false;

   switch (message)
   {
       case WM_INITDIALOG:
			guiWnd = hwnd;

			shownChannels = false;
			logID = IDC_LIST1;		// log
			statusID = IDC_LIST2;	// status
			hitID = IDC_LIST4;		// hit
			chanID = IDC_LIST3;		// channels

			enableControl(IDC_BUTTON8,false);
			enableControl(IDC_BUTTON11,false);
			enableControl(IDC_BUTTON10,false);
			
			peercastApp->updateSettings();

			if (servMgr->autoServe)
				setButtonState(IDC_CHECK1,true);
			if (servMgr->autoConnect)
				setButtonState(IDC_CHECK2,true);


			guiThread.func = showConnections;
			if (!sys->startThread(&guiThread))
			{
				MessageBox(hwnd,"Unable to start GUI","PeerCast",MB_OK|MB_ICONERROR);
				PostMessage(hwnd,WM_DESTROY,0,0);
			}

			if (guiFlg){
				SetWindowPlacement(hwnd, &winPlace);
			}

			{	// for PCRaw (connection list)
				HWND hwndList;
				
				hwndList = GetDlgItem(guiWnd, chanID);
#ifndef WIN64
				wndOldListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC);
				SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ListBoxProc);

				hwndList = GetDlgItem(guiWnd, statusID);
				wndOldConnListBox = (WNDPROC)GetWindowLong(hwndList, GWL_WNDPROC);
				SetWindowLong(hwndList, GWL_WNDPROC, (DWORD)ConnListBoxProc);
#else
				wndOldListBox = (WNDPROC)GetWindowLongPtr(hwndList, GWLP_WNDPROC);
				SetWindowLongPtr(hwndList, GWLP_WNDPROC, (DWORD)ListBoxProc);

				hwndList = GetDlgItem(guiWnd, statusID);
				wndOldConnListBox = (WNDPROC)GetWindowLongPtr(hwndList, GWLP_WNDPROC);
				SetWindowLongPtr(hwndList, GWLP_WNDPROC, (DWORD)ConnListBoxProc);
#endif
			}

			break;

	  case WM_COMMAND:
			switch( wParam )
			{
				case IDC_CHECK1:		// start server
						if (getButtonState(IDC_CHECK1))
						{
							//SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Deactivate");

							SendDlgItemMessage(hwnd, IDC_EDIT3,WM_GETTEXT, 64, (LONG)servMgr->password);

							servMgr->serverHost.port = (unsigned short)getEditInt(IDC_EDIT1);
							servMgr->setMaxRelays(getEditInt(IDC_MAXRELAYS));


							enableControl(IDC_EDIT1,false);
							enableControl(IDC_EDIT3,false);
							enableControl(IDC_MAXRELAYS,false);
							enableControl(IDC_BUTTON8,true);
							enableControl(IDC_BUTTON11,true);
							enableControl(IDC_BUTTON10,true);

							//writeSettings();
							servMgr->autoServe = true;

							setEditStr(IDC_CHECK1,"Enabled");


						}else{
							//SendDlgItemMessage(hwnd, IDC_CHECK1,WM_SETTEXT, 0, (LPARAM)"Activate");

							servMgr->autoServe = false;

							enableControl(IDC_EDIT1,true);
							enableControl(IDC_EDIT3,true);
							enableControl(IDC_MAXRELAYS,true);
							enableControl(IDC_BUTTON8,false);
							enableControl(IDC_BUTTON11,false);
							enableControl(IDC_BUTTON10,false);

							setEditStr(IDC_CHECK1,"Disabled");

						}
						setControls(true);

					break;
				case IDC_CHECK11:		// DJ message
					if (getButtonState(IDC_CHECK11))
					{
						enableControl(IDC_EDIT9,false);
						SendDlgItemMessage(hwnd, IDC_EDIT9,WM_GETTEXT, 128, (LONG)chanMgr->broadcastMsg.cstr());
					}else{
						enableControl(IDC_EDIT9,true);
						chanMgr->broadcastMsg.clear();
					}
					break;
				case IDC_LOGDEBUG:		// log debug
					servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<<LogBuffer::T_DEBUG) : servMgr->showLog&~(1<<LogBuffer::T_DEBUG);
					break;
				case IDC_LOGERRORS:		// log errors
					servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<<LogBuffer::T_ERROR) : servMgr->showLog&~(1<<LogBuffer::T_ERROR);
					break;
				case IDC_LOGNETWORK:		// log network
					servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<<LogBuffer::T_NETWORK) : servMgr->showLog&~(1<<LogBuffer::T_NETWORK);
					break;
				case IDC_LOGCHANNELS:		// log channels
					servMgr->showLog = getButtonState(wParam) ? servMgr->showLog|(1<<LogBuffer::T_CHANNEL) : servMgr->showLog&~(1<<LogBuffer::T_CHANNEL);
					break;
				case IDC_CHECK9:		// pause log
					servMgr->pauseLog = getButtonState(wParam);
					break;
				case IDC_CHECK2:		// start outgoing

					if (getButtonState(IDC_CHECK2))
					{

						SendDlgItemMessage(hwnd, IDC_COMBO1,WM_GETTEXT, 128, (LONG)servMgr->connectHost);
						servMgr->autoConnect = true;
						//SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Disconnect");
						enableControl(IDC_COMBO1,false);
					}else{
						servMgr->autoConnect = false;
						//SendDlgItemMessage(hwnd, IDC_CHECK2,WM_SETTEXT, 0, (LPARAM)"Connect");
						enableControl(IDC_COMBO1,true);
					}
					break;
				case IDC_BUTTON11:		// broadcast
					{
						Host sh = servMgr->serverHost;
						if (sh.isValid())
						{
							char cmd[256];
							sprintf(cmd,"http://localhost:%d/admin?page=broadcast",sh.port);
							ShellExecute(hwnd, NULL, cmd, NULL, NULL, SW_SHOWNORMAL);
		
						}else{
							MessageBox(hwnd,"Server is not currently connected.\nPlease wait until you have a connection.","PeerCast",MB_OK);
						}
					}
					break;
				case IDC_BUTTON8:		// play selected
					{
						Channel *c = getListBoxChannel();
						if (c){
							chanMgr->playChannel(c->info);
						}
					}
					break;
				case IDC_BUTTON7:		// advanced
					sys->callLocalURL("admin?page=settings",servMgr->serverHost.port);
					break;
				case IDC_BUTTON6:		// servent disconnect
					{
/*						Servent *s = (Servent *)getListBoxSelData(statusID);
						if (s)
							s->thread.active = false;*/
						Servent *s = getListBoxServent();
						if (s){
							s->thread.active = false;
							s->thread.finish = true;
						}
						sleep_skip = true;
					}
					break;
				case IDC_BUTTON5:		// chan disconnect
					{
/*						Channel *c = (Channel *)getListBoxSelData(chanID);
						if (c)
							c->thread.active = false;*/

//						Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID));
						Channel *c = getListBoxChannel();
						if (c){
							c->thread.active = false;
							c->thread.finish = true;
						}
						sleep_skip = true;
					}
					break;
				case IDC_BUTTON3:		// chan bump
					{
/*						Channel *c = (Channel *)getListBoxSelData(chanID);
						if (c)
							c->bump = true;*/

//						Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID));
						Channel *c = getListBoxChannel();
						if (c){
							c->bump = true;
						}
					}

					break;
				case IDC_BUTTON4:		// get channel 
					{
						ChanHitList *chl = (ChanHitList *)getListBoxSelData(hitID);
						if (chl)
						{
							if (!chanMgr->findChannelByID(chl->info.id))
							{
								Channel *c = chanMgr->createChannel(chl->info,NULL);
								if (c)
									c->startGet();
							}
						}else{
							MessageBox(hwnd,"Please select a channel","PeerCast",MB_OK);
						}
					}
					break;

					case IDC_BUTTON9:		//JP-EX chan keep
					{
/*						Channel *c = (Channel *)getListBoxSelData(chanID);
						if (c)
						{
							if (!c->stayConnected)
							{
								//if (servMgr->getFirewall() == ServMgr::FW_OFF)
								c->stayConnected = true;
							}	
							else
								c->stayConnected = false;
						}*/

//						Channel *c = chanMgr->findChannelByChannelID((int)getListBoxSelData(chanID));
						Channel *c = getListBoxChannel();
						if (c){
							if (!c->stayConnected){
								c->stayConnected = true;
							} else {
								c->stayConnected = false;
							}
						}
					}
					break;

				case IDC_BUTTON1:		// clear log
					SendDlgItemMessage(guiWnd, logID, LB_RESETCONTENT, 0, 0);
					sys->logBuf->clear();	// for PCRaw (clear log)
					break;

				case IDC_BUTTON2:		// find
					{
						char str[64];
						SendDlgItemMessage(hwnd, IDC_EDIT2,WM_GETTEXT, 64, (LONG)str);
						SendDlgItemMessage(hwnd, hitID, LB_RESETCONTENT, 0, 0);
						ChanInfo info;
						info.init();
						info.name.set(str);
						chanMgr->startSearch(info);
					}
					break;

			}
			break;

		case WM_MEASUREITEM:
			if ((UINT) wParam==IDC_LIST3){
				LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam;
				lpMI->itemHeight = 12;
			} else if ((UINT) wParam==IDC_LIST2){
				LPMEASUREITEMSTRUCT lpMI = (LPMEASUREITEMSTRUCT)lParam;
				lpMI->itemHeight = 12;
			}
			break;
		case WM_DRAWITEM:
			if  ((UINT) wParam==IDC_LIST3)
			{
				LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam;
				HBRUSH   hBrush;
				ListData *ld;
				unsigned int idx = 0;
				bool flg = false;

				ld = list_top;
				while(ld){
					if (_DrawItem->itemID == idx){
						flg = true;
						break;
					}
					ld = ld->next;
					idx++;
				}
				if ((_DrawItem->itemState) & (ODS_SELECTED))
				{
					hBrush=CreateSolidBrush(RGB(49,106,197));
				}
				else  
				{
					hBrush=CreateSolidBrush(RGB(255,255,255));
				}
				FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush);                   
				DeleteObject(hBrush);
				if (flg){
					char buf[256];
					if (ld->status == Channel::S_RECEIVING){
						if (ld->chDisp.status == Channel::S_RECEIVING){
							if (ld->chDisp.relay){
								/* relay ok */
								SetTextColor(_DrawItem->hDC,RGB(0,255,0));
								SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
							} else {
								/* no more relay */
								if (ld->chDisp.numRelays){
									/* relay full */
									SetTextColor(_DrawItem->hDC,RGB(0,0,255));
									SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
								} else {
									/* relay ng */
									SetTextColor(_DrawItem->hDC,RGB(255,0,255));
									SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
								}
							}
						} else {
							/* status unmatch */
							SetTextColor(_DrawItem->hDC,RGB(0,0,0));
							SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
						}
						TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left,
							_DrawItem->rcItem.top,
							"■",
							2);
					} else {
						SetTextColor(_DrawItem->hDC,RGB(0,0,0));
						SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
						TextOut(_DrawItem->hDC,
								_DrawItem->rcItem.left,
								_DrawItem->rcItem.top,
								"□",
								2);
					}
					if ((_DrawItem->itemState) & (ODS_SELECTED))
					{
						SetTextColor(_DrawItem->hDC,RGB(255,255,255));
						SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ;
					} else {
						SetTextColor(_DrawItem->hDC,RGB(0,0,0));
						SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
					}
					if (servMgr->getFirewall() == ServMgr::FW_ON){
						SetTextColor(_DrawItem->hDC,RGB(255,0,0));
					} else if (ld->bTracker && (ld->status == Channel::S_RECEIVING)){
						if ((_DrawItem->itemState) & (ODS_SELECTED))
						{
							SetTextColor(_DrawItem->hDC,RGB(0,255,0));
							SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ;
						} else {
							SetTextColor(_DrawItem->hDC,RGB(0,128,0));
						}
					}

					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12,
							_DrawItem->rcItem.top,
							ld->name,
							strlen(ld->name));
/*					sprintf(buf, "- %4dkbps -", ld->bitRate);
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12 + 118,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12 + 118 + 80,
							_DrawItem->rcItem.top,
							ld->statusStr,
							strlen(ld->statusStr));
					sprintf(buf, "- %3d/%3d - [%3d/%3d] -", ld->totalListeners, ld->totalRelays, ld->localListeners, ld->localRelays);
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12 + 118 + 80 + 80,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));
					strcpy(buf, ld->stayConnected?"YES":"NO");
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12 + 118 + 80 + 80 + 130,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));*/
					sprintf(buf, "- %4dkbps - %s - %3d/%3d - [%3d/%3d] - %s",
						ld->bitRate,
						ld->statusStr,
						ld->totalListeners,
						ld->totalRelays,
						ld->localListeners,
						ld->localRelays,
						ld->stayConnected?"YES":"NO");
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12 + 118,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));
				}
			} else if  ((UINT) wParam==IDC_LIST2) {
				LPDRAWITEMSTRUCT _DrawItem=(LPDRAWITEMSTRUCT)lParam;
				HBRUSH   hBrush;
				ServentData *sd;
				unsigned int idx = 0;
				bool flg = false;

				sd_lock.on();

				sd = servent_top;
				while(sd){
					if (_DrawItem->itemID == idx){
						flg = true;
						break;
					}
					sd = sd->next;
					idx++;
				}
				if (flg){
					char buf[256];
					char hostName[64];
					sd->h.toStr(hostName);

					if ((_DrawItem->itemState) & (ODS_SELECTED))
					{
						hBrush=CreateSolidBrush(RGB(49,106,197));
					}
					else  
					{
						hBrush=CreateSolidBrush(RGB(255,255,255));
					}
					FillRect(_DrawItem->hDC,&_DrawItem->rcItem,hBrush);                   
					DeleteObject(hBrush);

					if (sd->infoFlg){
						if (sd->relay){
							/* relay ok */
							SetTextColor(_DrawItem->hDC,RGB(0,255,0));
//							SetBkColor(_DrawItem->hDC,RGB(255,255,255));
						} else {
							/* no more relay */
							if (sd->numRelays){
								/* relay full */
								SetTextColor(_DrawItem->hDC,RGB(0,0,255));
//								SetBkColor(_DrawItem->hDC,RGB(255,255,255));
							} else {
								/* relay ng */
								SetTextColor(_DrawItem->hDC,RGB(255,0,255));
//								SetBkColor(_DrawItem->hDC,RGB(255,255,255));
							}
						}
					} else {
						/* no info */
						SetTextColor(_DrawItem->hDC,RGB(0,0,0));
//						SetBkColor(_DrawItem->hDC,RGB(255,255,255));
					}

					if (sd->lastSkipTime + 120 > sys->getTime()){
						SetBkColor(_DrawItem->hDC,RGB(128,128,128));
						if (sd->type == Servent::T_RELAY){
							sprintf(buf, "▼(%d)",sd->lastSkipCount);
							TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));
						} else {
							SetTextColor(_DrawItem->hDC,RGB(0,0,0));
							sprintf(buf, "▽(%d)",sd->lastSkipCount);
							TextOut(_DrawItem->hDC,
									_DrawItem->rcItem.left,
									_DrawItem->rcItem.top,
									buf,
									strlen(buf));
						}
					} else {
						SetBkColor(_DrawItem->hDC,RGB(255,255,255));
						if (sd->type == Servent::T_RELAY){
							TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left,
							_DrawItem->rcItem.top,
							"■",
							2);
						} else {
							SetTextColor(_DrawItem->hDC,RGB(0,0,0));
							SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
							TextOut(_DrawItem->hDC,
									_DrawItem->rcItem.left,
									_DrawItem->rcItem.top,
									"□",
									2);
						}
					}

					if ((_DrawItem->itemState) & (ODS_SELECTED))
					{
						SetTextColor(_DrawItem->hDC,RGB(255,255,255));
						SetBkColor(_DrawItem->hDC,RGB(49,106,197)) ;
					} else {
						SetTextColor(_DrawItem->hDC,RGB(0,0,0));
						SetBkColor(_DrawItem->hDC,RGB(255,255,255)) ;
					}
					if (sd->firewalled){
						if (!sd->numRelays){
							SetTextColor(_DrawItem->hDC,RGB(255,0,0));
						} else {
							SetTextColor(_DrawItem->hDC,RGB(255,168,0));
						}
					}

					char buf2[16];
					if (sd->ver_ex_number){
						sprintf(buf2, "(%c%c%04d)", sd->ver_ex_prefix[0], sd->ver_ex_prefix[1], sd->ver_ex_number);
					} else if (sd->vp_ver){
						sprintf(buf2, "(VP%04d)", sd->vp_ver);
					} else {
						buf2[0] = '\0';
					}
					if (sd->type == Servent::T_RELAY){
						if (sd->status == Servent::S_CONNECTED){
							sprintf(buf, "(%d)RELAYING-%ds  - %d/%d -  %s  -  %d - %s%s",
								sd->lastSkipCount,
								sd->tnum,
								sd->totalListeners, sd->totalRelays,
								hostName,
								sd->syncpos, sd->agent.cstr(), buf2
								);
						} else {
							sprintf(buf, "%s-%s-%ds  - %d/%d -  %s  -  %d - %s%s",
								sd->typeStr, sd->statusStr, sd->tnum,
								sd->totalListeners, sd->totalRelays,
								hostName,
								sd->syncpos, sd->agent.cstr(), buf2
								);
						}
					} else if (sd->type == Servent::T_DIRECT){
						sprintf(buf, "%s-%s-%ds  -  %s  -  %d - %s ",
							sd->typeStr, sd->statusStr, sd->tnum,
							hostName,
							sd->syncpos, sd->agent.cstr()
							);
					} else {
						if (sd->status == Servent::S_CONNECTED){
							sprintf(buf, "%s-%s-%ds  -  %s  -  %d/%d",
								sd->typeStr, sd->statusStr, sd->tnum,
								hostName,
								sd->syncpos, sd->agent.cstr()
								);
						} else {
							sprintf(buf, "%s-%s-%ds  -  %s",
								sd->typeStr, sd->statusStr, sd->tnum,
								hostName
								);
						}
					}
					TextOut(_DrawItem->hDC,
							_DrawItem->rcItem.left + 12,
							_DrawItem->rcItem.top,
							buf,
							strlen(buf));
				}
				sd_lock.off();
			}
			break;

		case WM_SIZE:
			MoveControls(lParam);
			break;

		case WM_GETMINMAXINFO:
		{
			MINMAXINFO *pmmi = (MINMAXINFO *)lParam;
			if ( pmmi )
			{
				pmmi->ptMinTrackSize.x = 530;  // 最小幅
				pmmi->ptMinTrackSize.y = 435;  // 最小高
				pmmi->ptMaxTrackSize.x = 530; // 最大幅
				pmmi->ptMaxTrackSize.y = 1200;  // 最大高
			}
			return 0;
		}

/*		case WM_NCHITTEST:
		{
			LRESULT lResult; // カーソル位置判定結果

			// 変換一覧にあれば変換した値を返す。
			lResult = DefWindowProc( guiWnd, message, wParam, lParam );
			for( int i = 0; i < 8; i++ )
			{
				if ( lResult == trans[ i ].from )
				{
					return trans[ i ].to;
				}
			}
//			return lResult;
//			return HTCAPTION;
//			return 0;
		}*/
		
		case WM_CLOSE:
			GetWindowPlacement(hwnd, &winPlace);
			guiFlg = true;
			DestroyWindow( hwnd );
			break;

		case WM_DESTROY:
			GetWindowPlacement(hwnd, &winPlace);
			guiFlg = true;
			guiThread.active = false;
//			guiThread.lock();
			guiWnd = NULL;
//			guiThread.unlock();
			EndDialog(hwnd, LOWORD(wParam));
			break;

		//default:
			// do nothing
			//return DefDlgProc(hwnd, message, wParam, lParam);		// this recurses for ever
			//return DefWindowProc(hwnd, message, wParam, lParam);	// this stops window messages
   }
   return 0;
}
Ejemplo n.º 13
0
//////////////////////////////////////////////////////////////////////////
// NAME : ShowControls
// PARM : int nCurrType 
// RETN : void
// DESC : Type에 따라 Control Show
// DATE : 2005-12-28 coded by lizzy, origin
//////////////////////////////////////////////////////////////////////////
void CDlg_Search::ShowControls()
{
	if(m_bNetEnable)
	{
		switch(m_nCurrType)
		{	
		case TYPE_SRCH_RANGE_BTN :
			ShowRcmmWord(FALSE);
            if ( m_nSrchRange == TYPE_SRCH_RANGE_ALL )
            {
                m_btnSrchRangeN.ShowWindow(TRUE);
                m_btnSrchRangeAllLocal.ShowWindow(FALSE);
            }
            else
            {
                m_btnSrchRangeN.ShowWindow(FALSE);
                m_btnSrchRangeAllLocal.ShowWindow(TRUE);
            }
			m_btnNetworkLoad.ShowWindow(FALSE);

//			m_btnSrchAll.ShowWindow(TRUE);
//			m_btnSrchLocal.ShowWindow(TRUE);
			m_btnNetwork.ShowWindow(TRUE);
			break;
		case TYPE_SRCH_LOAD_DATA :
			ShowRcmmWord(FALSE);
            if ( m_nSrchRange == TYPE_SRCH_RANGE_ALL )
            {
                m_btnSrchRangeN.ShowWindow(TRUE);
                m_btnSrchRangeAllLocal.ShowWindow(FALSE);
            }
            else
            {
                m_btnSrchRangeN.ShowWindow(FALSE);
                m_btnSrchRangeAllLocal.ShowWindow(TRUE);
            }

            m_btnNetwork.ShowWindow(FALSE);
//			m_btnSrchAll.ShowWindow(FALSE);
//			m_btnSrchLocal.ShowWindow(FALSE);

			m_btnNetworkLoad.ShowWindow(TRUE);
			break;
		case TYPE_SRCH_RCMMWORD :
		default :
//			m_btnSrchAll.ShowWindow(FALSE);
// 			m_btnSrchLocal.ShowWindow(FALSE);
			m_btnNetworkLoad.ShowWindow(FALSE);

            if ( m_nNodeState == TYPE_SRCH_NETWORK_STATUS_0)
    			ShowRcmmWord(FALSE);
            else
                ShowRcmmWord(TRUE);

            if ( m_nSrchRange == TYPE_SRCH_RANGE_ALL )
            {
                m_btnSrchRangeN.ShowWindow(TRUE);
                m_btnSrchRangeAllLocal.ShowWindow(FALSE);
            }
            else
            {
                m_btnSrchRangeN.ShowWindow(FALSE);
                m_btnSrchRangeAllLocal.ShowWindow(TRUE);
            }
			m_btnNetwork.ShowWindow(TRUE);
			break;
		}
	}
	else
	{
		switch(m_nCurrType)
		{
		case TYPE_SRCH_RANGE_BTN:
            if ( m_nSrchRange == TYPE_SRCH_RANGE_ALL )
            {
                m_btnSrchRangeN.ShowWindow(TRUE);
                m_btnSrchRangeAllLocal.ShowWindow(FALSE);
            }
            else
            {
                m_btnSrchRangeN.ShowWindow(FALSE);
                m_btnSrchRangeAllLocal.ShowWindow(TRUE);
            }
// 			m_btnSrchLocal.ShowWindow(TRUE);
			break;

        default:
            if ( m_nSrchRange == TYPE_SRCH_RANGE_ALL )
            {
                m_btnSrchRangeN.ShowWindow(TRUE);
                m_btnSrchRangeAllLocal.ShowWindow(FALSE);
            }
            else
            {
                m_btnSrchRangeN.ShowWindow(FALSE);
                m_btnSrchRangeAllLocal.ShowWindow(TRUE);
            }
// 			m_btnSrchLocal.ShowWindow(FALSE);
		}
// 		m_btnSrchAll.ShowWindow(FALSE);
		m_btnNetwork.ShowWindow(TRUE);
		m_btnNetworkLoad.ShowWindow(FALSE);
		ShowRcmmWord(FALSE);
	}

	if( m_edtSearch.GetSafeHwnd())
	{
		m_edtSearch.SetSel(0, 0);
	}
	UpdateWindow();

	MoveControls();
}