void CDirectoryTreeCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if (nChar == VK_SPACE)
	{
		HTREEITEM hItem = GetSelectedItem();
		if (hItem)
		{
			ShareSubDirTree(hItem, GetKeyState(VK_CONTROL) & 0x8000);

			// if Ctrl+Space is passed to the tree control, it just beeps and does not check/uncheck the item!
			SetCheck(hItem, !GetCheck(hItem));
			return;
		}
	}

	CTreeCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
//-----------------------------------------------------------------------------
// Purpose:
// Input  : nFlags -
//			point -
//-----------------------------------------------------------------------------
void CGroupList::OnLButtonUp(UINT nFlags, CPoint point)
{
    KillTimer(TIMER_GROUP_DRAG_SCROLL);
    ReleaseCapture();

    if (!m_hDragItem)
    {
        unsigned int uFlags;
        HTREEITEM hItemHit = HitTest(point, &uFlags);
        if (hItemHit != NULL)
        {
            if (uFlags & TVHT_ONITEMICON)
            {
                //
                // Notify our parent window that this item's state has changed.
                //
                CWnd *pwndParent = GetParent();
                if (pwndParent != NULL)
                {
                    int nCheckState = GetCheck(hItemHit);
                    if (!nCheckState)
                    {
                        nCheckState = 1;
                    }
                    else
                    {
                        nCheckState = 0;
                    }

                    CVisGroup *pGroup = (CVisGroup *)GetItemData(hItemHit);
                    pwndParent->PostMessage(g_uToggleStateMsg, (WPARAM)pGroup, nCheckState);
                }

                // Don't forward to the base if they clicked on the check box.
                // This prevents undesired expansion/collapse of tree.
                return;
            }
        }

        CTreeCtrl::OnLButtonUp(nFlags, point);
        return;
    }

    Drop(DROP_LEFT, nFlags, point);
}
void CButtonExtn::OnCustomDraw(NMHDR *pNotifyStruct, LRESULT *pLResult)
{
  // Code originally by Nikita Leontiev in answer to "Change checkBox text color Win32"
  // in MS's Forum: "Visual Studio Developer Center > Visual Studio vNext Forums > Visual C++ General"
  // Modified for MFC, Checkbox and Radio buttons by DK

  LPNMCUSTOMDRAW lpNMCustomDraw = (LPNMCUSTOMDRAW)pNotifyStruct;
  *pLResult = CDRF_DODEFAULT;

  switch (lpNMCustomDraw->dwDrawStage) {
    case CDDS_PREPAINT:
      BOOL fChecked = GetCheck() & BST_CHECKED;
      BOOL fHot = lpNMCustomDraw->uItemState & CDIS_HOT;
      BOOL fFocus = lpNMCustomDraw->uItemState & CDIS_FOCUS;
      DrawButton(lpNMCustomDraw->hdr.hwndFrom, lpNMCustomDraw->hdc,
				     		&lpNMCustomDraw->rc, fChecked, fHot, fFocus);
  }
}
void CSingleCheckListBox::OnLButtonDown(UINT nFlags, CPoint point)
{
	BOOL bInCheck;
	int nIndex=CheckFromPoint(point, bInCheck);
	int nCheck=GetCheck( nIndex );
	if(bInCheck)
	{
		if(nCheck==1)
			return;
		else if(nCheck==0)
		{
			SetCheck(m_nLastChecked,0);
			m_nLastChecked=nIndex;
		}
	}

	CCheckListBox::OnLButtonDown(nFlags,point);
}
Exemple #5
0
	void CCheckBoxUI::DoEvent(TEventUI& event)
	{
		if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
			if( m_pParent != NULL ) m_pParent->DoEvent(event);
			else COptionUI::DoEvent(event);
			return;
		}

		if( m_bAutoCheck && (event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK)) {
			if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) {
				SetCheck(!GetCheck()); 
				m_pManager->SendNotify(this, DUI_MSGTYPE_CHECKCLICK, 0, 0);
				Invalidate();
			}
			return;
		}
		COptionUI::DoEvent(event);
	}
Exemple #6
0
void CTextureTool::LoadTextureListBoxes () 
{
	HINSTANCE	hInst = AfxGetApp()->m_hInstance;
	char			name [80];
	int			bShowFrames;
	int			nTextures, iTexture, index;
	CComboBox	*cbTexture1 = CBTexture1 ();
	CComboBox	*cbTexture2 = CBTexture2 ();

GetMine ();
bShowFrames = GetCheck (IDC_TEXTURE_SHOWFRAMES);

INT16 texture1 = m_mine ? m_mine->CurrSide ()->nBaseTex : 0;
INT16 texture2 = m_mine ? m_mine->CurrSide ()->nOvlTex & 0x3fff : 0;

if ((texture1 < 0) || (texture1 >= MAX_TEXTURES))
	texture1 = 0;
if ((texture2 < 0) || (texture2 >= MAX_TEXTURES))
	texture2 = 0;

cbTexture1->ResetContent ();
cbTexture2->ResetContent ();
index = cbTexture1->AddString ("(none)");
texture_resource = (file_type == RDL_FILE) ? D1_TEXTURE_STRING_TABLE : D2_TEXTURE_STRING_TABLE;
nTextures = (file_type == RDL_FILE) ? MAX_D1_TEXTURES : MAX_D2_TEXTURES;
for (iTexture = 0; iTexture < nTextures; iTexture++) {
#if 0
	if (iTexture >= 910)
		sprintf (name, "xtra #%d", iTexture);
	else
#endif
		LoadString (hInst, texture_resource + iTexture, name, sizeof (name));
	if (bShowFrames || !strstr ((char *) name, "frame")) {
		index = cbTexture1->AddString (name);
		cbTexture1->SetItemData (index, iTexture);
		if (texture1 == iTexture)
			cbTexture1->SetCurSel (index);
		index = cbTexture2->AddString (iTexture ? name : "(none)");
		if (texture2 == iTexture)
			cbTexture2->SetCurSel (index);
		cbTexture2->SetItemData (index, iTexture);
		}
	}
}
//绘画数据
VOID CEasySkinListCtrl::DrawReportItem(CDC * pDC, INT nItem, CRect & rcSubItem, INT nColumnIndex)
{
	//获取文字
	TCHAR szString[256]=TEXT("");
	GetItemText(nItem,nColumnIndex,szString,CountArray(szString));

	//绘画文字
	rcSubItem.left+=5;

	//绘制CheckButton
	if( nColumnIndex == 0 )
	{
		if ((m_pCheckImg != NULL && !m_pCheckImg->IsNull()) && (m_pUnCheckImg != NULL && !m_pUnCheckImg->IsNull()))
		{
			if( GetCheck(nItem) )
				m_pCheckImg->DrawImage(pDC,rcSubItem.left+2,rcSubItem.top+(rcSubItem.Height()-m_pCheckImg->GetHeight())/2);
			else
				m_pUnCheckImg->DrawImage(pDC,rcSubItem.left+2,rcSubItem.top+(rcSubItem.Height()-m_pUnCheckImg->GetHeight())/2);

			rcSubItem.left+=(8+m_pCheckImg->GetWidth());
		}

		CItemImgArray::iterator iter = m_ItemImgArray.begin();

		for (;iter != m_ItemImgArray.end(); ++iter )
		{
			if ( iter->nItem == nItem )
			{
				CImageEx *pImage = iter->pImage;

				if (pImage != NULL && !pImage->IsNull())
				{
					pImage->DrawImage(pDC,rcSubItem.left+2,rcSubItem.top+(rcSubItem.Height()-pImage->GetHeight())/2);
					rcSubItem.left+=(8+pImage->GetWidth());
				}
				break;
			}
		}
	}

	pDC->DrawText(szString,lstrlen(szString),&rcSubItem,DT_VCENTER|DT_SINGLELINE|DT_END_ELLIPSIS);

	return;
}
void ShipCheckListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if (nChar == VK_SPACE)
	{
		int i, list_size;

		list_size = GetCount();
		for (i=0; i<list_size; i++)
			if (GetSel(i) > 0)
			{
				if (GetCheck(i))
					SetCheck(i, 0);
				else
					SetCheck(i, 1);
			}

	} else
		CCheckListBox::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CXTPCustomizeToolbarsPageCheckListBox::PreDrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	DRAWITEMSTRUCT drawItem;
	memcpy(&drawItem, lpDrawItemStruct, sizeof(DRAWITEMSTRUCT));

	if ((((LONG)drawItem.itemID) >= 0) &&
		((drawItem.itemAction & (ODA_DRAWENTIRE | ODA_SELECT)) != 0))
	{
		int cyItem = GetItemHeight(drawItem.itemID);

		CDC* pDC = CDC::FromHandle(drawItem.hDC);

		int nCheck = GetCheck(drawItem.itemID);

		CRect rectCheck = drawItem.rcItem;
		rectCheck.left += 1;
		rectCheck.top += 1 + max(0, (cyItem - m_sizeCheck.cy) / 2);
		rectCheck.right = rectCheck.left + m_sizeCheck.cx;
		rectCheck.bottom = rectCheck.top + m_sizeCheck.cy;

		CRect rectItem = drawItem.rcItem;
		rectItem.right = rectItem.left + m_sizeCheck.cx + 2;
		CRect rectCheckBox = OnGetCheckPosition(rectItem, rectCheck);

		if (m_themeHelper.IsAppThemeReady())
		{
			m_themeHelper.DrawThemeBackground(pDC->m_hDC, BP_CHECKBOX,
				nCheck ? CBS_CHECKEDNORMAL : CBS_UNCHECKEDNORMAL, &rectCheckBox, NULL);
		}
		else
		{
			ASSERT(rectCheck.IntersectRect(rectItem, rectCheckBox));
			ASSERT((rectCheck == rectCheckBox) && (rectCheckBox.Size() == m_sizeCheck));

			pDC->DrawFrameControl(rectCheckBox, DFC_BUTTON, DFCS_BUTTONCHECK | (nCheck ? DFCS_CHECKED : 0));
		}
	}

	drawItem.rcItem.left = drawItem.rcItem.left + m_sizeCheck.cx + 3;

	DrawItem(&drawItem);
}
bool COptionsPageFileExists::SavePage()
{
	enum CFileExistsNotification::OverwriteAction value;
	if (GetRCheck(XRCID("ID_DL_OVERWRITE")))
		value = CFileExistsNotification::overwrite;
	else if (GetRCheck(XRCID("ID_DL_OVERWRITEIFNEWER")))
		value = CFileExistsNotification::overwriteNewer;
	else if (GetRCheck(XRCID("ID_DL_OVERWRITESIZE")))
		value = CFileExistsNotification::overwriteSize;
	else if (GetRCheck(XRCID("ID_DL_OVERWRITESIZEORNEWER")))
		value = CFileExistsNotification::overwriteSizeOrNewer;
	else if (GetRCheck(XRCID("ID_DL_RESUME")))
		value = CFileExistsNotification::resume;
	else if (GetRCheck(XRCID("ID_DL_RENAME")))
		value = CFileExistsNotification::rename;
	else if (GetRCheck(XRCID("ID_DL_SKIP")))
		value = CFileExistsNotification::skip;
	else
		value = CFileExistsNotification::ask;
	m_pOptions->SetOption(OPTION_FILEEXISTS_DOWNLOAD, value);

	if (GetRCheck(XRCID("ID_UL_OVERWRITE")))
		value = CFileExistsNotification::overwrite;
	else if (GetRCheck(XRCID("ID_UL_OVERWRITEIFNEWER")))
		value = CFileExistsNotification::overwriteNewer;
	else if (GetRCheck(XRCID("ID_UL_OVERWRITESIZE")))
		value = CFileExistsNotification::overwriteSize;
	else if (GetRCheck(XRCID("ID_UL_OVERWRITESIZEORNEWER")))
		value = CFileExistsNotification::overwriteSizeOrNewer;
	else if (GetRCheck(XRCID("ID_UL_RESUME")))
		value = CFileExistsNotification::resume;
	else if (GetRCheck(XRCID("ID_UL_RENAME")))
		value = CFileExistsNotification::rename;
	else if (GetRCheck(XRCID("ID_UL_SKIP")))
		value = CFileExistsNotification::skip;
	else
		value = CFileExistsNotification::ask;
	m_pOptions->SetOption(OPTION_FILEEXISTS_UPLOAD, value);

	m_pOptions->SetOption(OPTION_ASCIIRESUME, GetCheck(XRCID("ID_ASCIIRESUME")));
	return true;
}
void CDummyUsbDevice::InterpretLine()
	{
	TLex8 lex(iLine);
	lex.SkipCharacters();
	iCommand = GetCommand(iLine.Left(lex.Offset()));
	lex.SkipSpace();
	lex.Val(iCommandValue);
	lex.SkipSpace();
	TInt pos = lex.Offset();
	lex.SkipCharacters();
	iAsyncOp = GetAsyncOp(iLine.Mid(pos,lex.Offset()-pos));
	lex.SkipSpace();
	lex.Val(iAsyncOpValue);
	lex.SkipSpace();
	pos = lex.Offset();
	lex.SkipCharacters();
	iCheck = GetCheck(iLine.Mid(pos,lex.Offset()-pos));
	lex.SkipSpace();
	lex.Val(iCheckValue);
	}
void CCheckBox::OnClicked() 
{
  BOOL bCheched = FALSE;
  
  switch(GetCheck()) {
    case 0:
      bCheched = FALSE;
    break;
    case 1:
      bCheched = TRUE;
    break;
    default:
      ASSERTALWAYS("Unknown state");
      return;
    break;
  }

  // control is in shader dialog
  theApp.m_dlgBarTreeView.ChangeFlagOnSelectedSurfaces(m_strID,bCheched,m_iIndex);
}
//
// This routine steps thru all the items and builds
// a string containing the checked items
//
void CCheckComboBox::RecalcText()
{
	if (!m_bTextUpdated) {
		CString strText;
		
		// Get the list count
		INT nCount    = GetCount();

		// Get the list separator
		TCHAR szBuffer[10] = {0};
		GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, szBuffer, sizeof(szBuffer));

		CString strSeparator = szBuffer;

		// If none found, the the ';'
		if (strSeparator.GetLength() == 0)
			strSeparator = ';';

		// Trim extra spaces
		strSeparator.TrimRight();

		// And one...
		strSeparator += ' ';

		for (INT i = 0; i < nCount; i++) {
			if (GetCheck(i)) {
				CString strItem;
				GetLBText(i, strItem);

				if (!strText.IsEmpty())
					strText += strSeparator;

				strText += strItem;
			}
		}

		// Set the text
		m_strText = strText;
		m_bTextUpdated = TRUE;
	}
}
Exemple #14
0
bool FileFilter::FilterEdit()
{
	if (bMenuOpen)
		return false;

	Changed = true;
	bMenuOpen = true;
	int ExitCode;
	bool bNeedUpdate=false;
	const auto FilterList = VMenu2::create(MSG(MFilterTitle), nullptr, 0, ScrY - 6);
	FilterList->SetHelp(L"FiltersMenu");
	FilterList->SetPosition(-1,-1,0,0);
	FilterList->SetBottomTitle(MSG(MFilterBottom));
	FilterList->SetMenuFlags(/*VMENU_SHOWAMPERSAND|*/VMENU_WRAPMODE);
	FilterList->SetId(FiltersMenuId);

	std::for_each(RANGE(FilterData(), i)
	{
		MenuItemEx ListItem(MenuString(&i));
		ListItem.SetCheck(GetCheck(i));
		FilterList->AddItem(ListItem);
	});
Exemple #15
0
void CStockList::OnSetStockDataInfo()
{
//	tabStoragStartArray* m_tabStoragStartArray = (tabStoragStartArray*)cbBuffer;
	int nItemCount = GetItemCount();
	if (nItemCount==0)
	{
		return;
	}
	BOOL nIsCheck = FALSE;
	int nCount = 0;
	CString szText;
	for (int nItem = 0;nItem<nItemCount;nItem++)
	{
		nIsCheck = GetCheck(nItem);
		if (nIsCheck == TRUE)
		{
			szText = GetItemText(nItem,5);
			m_tabStoragStartArray.StoragStart[nCount].dwServerID = _ttoi(szText);/*((tagUMSysGameSet*)GetItemData(nItem))->dwServerID*/;
			szText = GetItemText(nItem,2);
			m_tabStoragStartArray.StoragStart[nCount].lStoragStart = _ttoi(szText);//((tagUMSysGameSet*)GetItemData(nItem))->dwStoragStart;
			szText = GetItemText(nItem,3);
			m_tabStoragStartArray.StoragStart[nCount].dwStorageDeduct = _ttoi(szText);//((tagUMSysGameSet*)GetItemData(nItem))->dwStorageDeduct;
			m_tabStoragStartArray.StoragStart[nCount].bValid = 1;
		}else{
			szText = GetItemText(nItem,5);
			m_tabStoragStartArray.StoragStart[nCount].dwServerID = _ttoi(szText);//((tagUMSysGameSet*)GetItemData(nItem))->dwServerID;
			szText = GetItemText(nItem,2);
			m_tabStoragStartArray.StoragStart[nCount].lStoragStart = _ttoi(szText);//((tagUMSysGameSet*)GetItemData(nItem))->dwStoragStart;
			szText = GetItemText(nItem,3);
			m_tabStoragStartArray.StoragStart[nCount].dwStorageDeduct = _ttoi(szText);//((tagUMSysGameSet*)GetItemData(nItem))->dwStorageDeduct;
			m_tabStoragStartArray.StoragStart[nCount].bValid = 0;
		}

		nCount++;
	}
		m_tabStoragStartArray.dwCount = nCount;

/*		return sizeof(tabStoragStartArray);*/
}
void CMultiTreeCtrl::GetCheckItems(std::vector<HTREEITEM>& vecTreeItems, HTREEITEM hTreeItem)
{
	if (hTreeItem == NULL)
	{
		hTreeItem = GetRootItem();
	}

	HTREEITEM hNextItem = GetChildItem(hTreeItem);
	while(hNextItem!=NULL)
	{
		GetCheckItems(vecTreeItems, hNextItem);
		hNextItem = GetNextItem(hNextItem,TVGN_NEXT);
	}

	if (hTreeItem!=NULL)
	{
		//如果该节点复选框被选中
		if (GetCheck(hTreeItem))
		{
			vecTreeItems.push_back(hTreeItem);
		}
	}
}
Exemple #17
0
void CMyCheckBox::OnEnable(BOOL bEnable)
{
	CButton::OnEnable(bEnable);
	if (bEnable == 0)
	{
		m_edit->EnableWindow(0);
		m_interval_edit->EnableWindow(0);
	}
	else
	{
		if (GetCheck())
		{
			m_edit->EnableWindow(0);
			m_interval_edit->EnableWindow(0);
		}
		else
		{
			m_edit->EnableWindow(1);
			m_interval_edit->EnableWindow(1);
		}
	}
	// TODO:  在此处添加消息处理程序代码
}
bool COptionsPageConnectionActive::Validate()
{
	// Validate port limiting settings
	if (GetCheck(XRCID("ID_LIMITPORTS")))
	{
		wxTextCtrl* pLow = XRCCTRL(*this, "ID_LOWESTPORT", wxTextCtrl);

		long low;
		if (!pLow->GetValue().ToLong(&low) || low < 1024 || low > 65535)
			return DisplayError(pLow, _("Lowest available port has to be a number between 1024 and 65535."));

		wxTextCtrl* pHigh = XRCCTRL(*this, "ID_LOWESTPORT", wxTextCtrl);

		long high;
		if (!pHigh->GetValue().ToLong(&high) || high < 1024 || high > 65535)
			return DisplayError(pHigh, _("Highest available port has to be a number between 1024 and 65535."));

		if (low > high)
			return DisplayError(pLow, _("The lowest available port has to be less or equal than the highest available port."));
	}

	int mode;
	if (GetRCheck(XRCID("ID_ACTIVEMODE1")))
		mode = 0;
	else
		mode = GetRCheck(XRCID("ID_ACTIVEMODE2")) ? 1 : 2;

	if (mode == 1)
	{
		wxTextCtrl* pActiveIP = XRCCTRL(*this, "ID_ACTIVEIP", wxTextCtrl);
		if (!IsIpAddress(pActiveIP->GetValue()))
			return DisplayError(pActiveIP, _("You have to enter a valid IP address."));
	}

	return true;
}
Exemple #19
0
// Get the text for the entry control and map it to the data OI.
zSHORT
ZCheckBox::MapToOI( zLONG lFlag )
{
// if ( zstrcmp( *m_pzsTag, "CheckAutoCreateActOnCatChg" ) == 0 )
//    TraceLineS( "ZCheckBox::MapToOI ", *m_pzsTag );

   zVIEW vApp;

   // If the control is not Visible and Enabled, or if the view is not found,
   // do not do mapping.
   if ( m_pzsVName && (vApp = IsVisibleForMapToOI( *m_pzsVName )) != 0 &&
        CheckExistenceOfEntity( vApp, *m_pzsEName ) == 0 )
   {
      zBOOL bCheck = (GetCheck( ) == 1);

      return( SetAttributeFromVariable( vApp, *m_pzsEName, *m_pzsAName,
                                        bCheck ?
                                          *m_pzsValueOn : *m_pzsValueOff,
                                        zTYPE_STRING, 0, *m_pzsContext,
                                        (zSHORT) lFlag ) );
   }

   return( 0 );
}
void COptionsPage::SetOptionFromCheck(int control_id, int option_id)
{
	m_pOptions->SetOption(option_id, GetCheck(control_id) ? 1 : 0);
}
Exemple #21
0
//Server工作在完成端口模式下时,使用该方法代替OnAccept
void CServer::OnAccept(int nErrorCode)
{

    char strInfo[256]="";
    SOCKET clientSocket;
    struct sockaddr_in stClientAddress;
    int nClientAddressLen=sizeof(stClientAddress);

    clientSocket = WSAAccept (m_hSocket,
                              (struct sockaddr*)&stClientAddress,
                              &nClientAddressLen,
                              NULL,
                              0);

    if(clientSocket==INVALID_SOCKET)
    {
        ulong dwEorror = WSAGetLastError();
        return;
    }

    //判断是否超过最大连接数
    if(m_lCurClientCount >= m_lMaxClientConNum)
    {
        closesocket(clientSocket);
        PutTraceString(NET_MODULE,"the cur connect num(%d) greater the restrict num(%d)",m_lCurClientCount,m_lMaxClientConNum);

        return;
    }

    //察看此IP是否被禁止
    if(m_bCheck && FindForbidIP(stClientAddress.sin_addr.S_un.S_addr) == true)
    {
        closesocket(clientSocket);
        Log4c::Warn(NET_MODULE,"the ip address(%d) has already forbided",stClientAddress.sin_addr.S_un.S_addr);
        return;
    }

    //生成
    CServerClient* pServerClient=  AllocClient(true);
    if(NULL == pServerClient)
    {
        Log4c::Warn(NET_MODULE,"erro, Don't allocate the 'serverclient' instance.!");
        closesocket(clientSocket);
        return;
    }

    pServerClient->m_hSocket=clientSocket;
    pServerClient->SetFlag(GetFlag());
    /// 设置加解密所用Key.
    static bool bFirst = true;
    if (IsEncryptType(pServerClient->GetFlag()))
    {
        if (bFirst)
        {
            bFirst = false;
            struct sockaddr_in addr;
            int len = sizeof(addr);
            getsockname(clientSocket, (struct sockaddr *)&addr, &len);
            SetKey(addr.sin_addr.S_un.S_addr, addr.sin_port);
        }
        pServerClient->GetKn(m_kn);
    }

    //设置IP
    pServerClient->SetPeerIP(inet_ntoa(stClientAddress.sin_addr));
    pServerClient->SetPeerIP(stClientAddress.sin_addr.S_un.S_addr);
    pServerClient->SetPeerPort(stClientAddress.sin_port);
    pServerClient->SetParam(GetCheck(),GetMaxMsgLen(),m_lMaxBlockSendMsgNum,
                            m_lPendingWrBufNum,m_lPendingRdBufNum,
                            m_lMaxSendSizePerSecond,m_lMaxRecvSizePerSecond,0);
    pServerClient->SetClose(false);
    pServerClient->SetShutDown(false);

    //设置Socket的indexID
    pServerClient->SetSendRevBuf();
    //设置套接字选项
    pServerClient->SetSocketOpt();

    tagSocketOper *pSocketOper = AllocSockOper();
    pSocketOper->Init(SCOT_Init,pServerClient->GetIndexID(),pServerClient);
    m_SocketOperaCommands.Push_Back(pSocketOper);

    pServerClient->OnAccept();

    IncAcceptThreadTick();
}
void CPropTreeItemCheck::OnBnClicked() {
	int state = GetCheck();
	SetCheckState( GetCheck() == BST_CHECKED ? FALSE : TRUE );
	CommitChanges();
}
Exemple #23
0
int Config()
{
  static const MyInitDialogItem InitItems[]={
  /* 0*/ {DI_DOUBLEBOX, 3, 1,  DIALOG_WIDTH-4,DIALOG_HEIGHT-2, 0, MConfigTitle},

  /* 1*/ {DI_CHECKBOX,  5, 2,  0, 0, 0, MConfigAddToDisksMenu},
  /* 2*/ {DI_FIXEDIT,   7, 3,  7, 3, 0
#ifdef UNICODE
                                      |DIF_HIDDEN
#endif
                                                 , -1},
  /* 3*/ {DI_TEXT,      9, 3,  0, 0, 0
#ifdef UNICODE
                                      |DIF_HIDDEN
#endif
                                                 , MConfigDisksMenuDigit},
  /* 4*/ {DI_CHECKBOX, DC, 2,  0, 0, 0, MConfigAddToPluginsMenu},
  /* 5*/ {DI_TEXT,      5, 4,  0, 0, DIF_BOXCOLOR|DIF_SEPARATOR, -1},

  /* 6*/ {DI_CHECKBOX,  5, 5,  0, 0, 0, MConfigCommonPanel},
  /* 7*/ {DI_CHECKBOX,  5, 6,  0, 0, 0, MSafeModePanel},
  /* 8*/ {DI_CHECKBOX,  5, 7,  0, 0, 0, MAnyInPanel},
  /* 9*/ {DI_CHECKBOX,  5, 8,  0, 0, DIF_3STATE, MCopyContens},
  /*10*/ {DI_CHECKBOX, DC, 5,  0, 0, 0, MReplaceInFilelist},
  /*11*/ {DI_CHECKBOX, DC, 6,  0, 0, 0, MMenuForFilelist},
  /*12*/ {DI_CHECKBOX, DC, 7,  0, 0, 0, MNewPanelForSearchResults},

  /*13*/ {DI_TEXT,      5, 9,  0, 0, DIF_BOXCOLOR|DIF_SEPARATOR, -1},

  /*14*/ {DI_TEXT,      5,10,  0, 0, 0, MColumnTypes},
  /*15*/ {DI_EDIT,      5,11, 36,11, 0, -1},
  /*16*/ {DI_TEXT,      5,12,  0, 0, 0, MColumnWidths},
  /*17*/ {DI_EDIT,      5,13, 36,13, 0, -1},
  /*18*/ {DI_TEXT,     DC,10,  0, 0, 0, MStatusColumnTypes},
  /*19*/ {DI_EDIT,     DC,11, 72,11, 0, -1},
  /*20*/ {DI_TEXT,     DC,12,  0, 0, 0, MStatusColumnWidths},
  /*21*/ {DI_EDIT,     DC,13, 72,13, 0, -1},
  /*22*/ {DI_CHECKBOX,  5,14,  0, 0, 0, MFullScreenPanel},

  /*23*/ {DI_TEXT,      5,15,  0, 0, DIF_BOXCOLOR|DIF_SEPARATOR, -1},

  /*24*/ {DI_TEXT,      5,16,  0, 0, 0, MMask},
  /*25*/ {DI_EDIT,      5,17, 36,17, 0, -1},
  /*26*/ {DI_TEXT,     DC,16,  0, 0, 0, MPrefix},
  /*27*/ {DI_EDIT,     DC,17, 72,17, 0, -1},

  /*28*/ {DI_TEXT,      5,18,  0, 0, DIF_BOXCOLOR|DIF_SEPARATOR, -1},

  /*29*/ {DI_BUTTON,    0,19,  0, 0, DIF_CENTERGROUP,  MOk},
  /*30*/ {DI_BUTTON,    0,19,  0, 0, DIF_CENTERGROUP,  MCancel}
  };

  int i;
  struct FarDialogItem DialogItems[ARRAYSIZE(InitItems)];

  InitDialogItems(InitItems,DialogItems,ARRAYSIZE(InitItems));
  DialogItems[29].DefaultButton=1;
  DialogItems[2].Focus=1;

  GetOptions();
  for(i=AddToDisksMenu;i<=Prefix;i++)
    if (i<ColumnTypes)
      DialogItems[OptionsList[i].DialogItem].Selected=*(int*)(OptionsList[i].Option);
    else
#ifndef UNICODE
      lstrcpy(DialogItems[OptionsList[i].DialogItem].Data,(char*)OptionsList[i].Option);
#else
      DialogItems[OptionsList[i].DialogItem].PtrData = (TCHAR*)OptionsList[i].Option;
#endif

#ifndef UNICODE
  int Ret=Info.Dialog(Info.ModuleNumber,-1,-1,DIALOG_WIDTH,DIALOG_HEIGHT,"Config",
                      DialogItems,ARRAYSIZE(DialogItems));
#else
  HANDLE hDlg=Info.DialogInit(Info.ModuleNumber,-1,-1,DIALOG_WIDTH,DIALOG_HEIGHT,
                      L"Config",DialogItems,ARRAYSIZE(DialogItems),0,0,NULL,0);
  if (hDlg == INVALID_HANDLE_VALUE)
    return FALSE;

  int Ret=Info.DialogRun(hDlg);
#endif

  if((unsigned)Ret >= ARRAYSIZE(InitItems)-1) goto done;

  for(i=AddToDisksMenu;i<=Prefix;i++)
  {
    HKEY hKey;
    DWORD Disposition;
    RegCreateKeyEx(HKEY_CURRENT_USER,PluginRootKey,0,NULL,0,KEY_WRITE,NULL,
                   &hKey,&Disposition);
    if (i<ColumnTypes)
    {
      *((int*)OptionsList[i].Option)=GetCheck(OptionsList[i].DialogItem);
      RegSetValueEx(hKey,REGStr[i],0,REG_DWORD,(BYTE*)OptionsList[i].Option,
        sizeof(int));
    }
    else
    {
      FSF.Trim(lstrcpy((TCHAR*)OptionsList[i].Option,GetDataPtr(OptionsList[i].DialogItem)));
      RegSetValueEx(hKey,REGStr[i],0,REG_SZ,(BYTE*)OptionsList[i].Option,
        sizeof(TCHAR)*(lstrlen((TCHAR*)OptionsList[i].Option)+1));
    }
    RegCloseKey(hKey);
  }
  if(StartupOptFullScreenPanel!=Opt.FullScreenPanel ||
     StartupOptCommonPanel!=Opt.CommonPanel)
  {
    const TCHAR *MsgItems[]={GetMsg(MTempPanel),GetMsg(MConfigNewOption),GetMsg(MOk)};
    Info.Message(Info.ModuleNumber,0,NULL,MsgItems,ARRAYSIZE(MsgItems),1);
  }
done:
#ifdef UNICODE
  Info.DialogFree(hDlg);
#endif
  return((unsigned)Ret<ARRAYSIZE(InitItems));
}
Exemple #24
0
void CExtColorButton::_RenderImpl( // non-buffered paint
	CDC & dc,
	bool bTransparent // = false
	)
{
ICONINFO iiNewIcon;
	iiNewIcon.fIcon = true;	// set that it is an icon
	// create DC's
HDC hIconDC = ::CreateCompatibleDC( dc.GetSafeHdc() );
HDC hMaskDC = ::CreateCompatibleDC( dc.GetSafeHdc() );
	ASSERT(
		hIconDC != NULL && hMaskDC != NULL
		);
	// load bitmaps
	iiNewIcon.hbmColor = ::CreateCompatibleBitmap(
		dc.GetSafeHdc(),
		16,
		16
		);
	ASSERT( iiNewIcon.hbmColor != NULL );
	iiNewIcon.hbmMask = ::CreateCompatibleBitmap(
		hMaskDC,
		16,
		16
		);
	ASSERT( iiNewIcon.hbmMask != NULL );
HGDIOBJ hOldIconDC =
		::SelectObject(
			hIconDC,
			iiNewIcon.hbmColor
			);
	ASSERT( hOldIconDC != NULL );
HGDIOBJ hOldMaskDC =
		::SelectObject(
			hMaskDC,
			iiNewIcon.hbmMask
			);
	ASSERT( hOldMaskDC != NULL );

CBrush brColorItem( m_clrSelected );
CRect rcColorItem(0,0,16,16);
	::FillRect(
		hIconDC,
		&rcColorItem,
		(HBRUSH)brColorItem.GetSafeHandle()
		);
	::FillRect(
		hMaskDC,
		&rcColorItem,
		(HBRUSH)::GetStockObject(BLACK_BRUSH)
		);

	::SelectObject(hIconDC,hOldIconDC);
	::SelectObject(hMaskDC,hOldMaskDC);
HICON hIcon = CreateIconIndirect(&iiNewIcon);
	ASSERT( hIcon != NULL );
	// cleanup
	DeleteObject(iiNewIcon.hbmColor);
	DeleteObject(iiNewIcon.hbmMask);
	DeleteDC(hMaskDC);
	DeleteDC(hIconDC);



CRect rectClient;
	GetClientRect( &rectClient );
CString sWindowText( _T("") );
	GetWindowText( sWindowText );
bool bDrawFocusRect = (GetFocus() == this) ? true : false;
bool bDefault = GetDefault() ? true : false;
bool bPushed = (m_bPushed || GetCheck()) ? true : false;
bool bEnabled = IsWindowEnabled() ? true : false;
bool bFlat = GetFlat() ? true : false;
bool bHover =
		( m_bMouseOver
		&& !CExtPopupMenuWnd::IsMenuTracking() )
			? true : false;
	if( GetParent()->IsKindOf(RUNTIME_CLASS(CControlBar)) )
	{
		bDrawFocusRect = false;
		bFlat = true;
	}
	g_PaintManager->PaintPushButton(
		dc, true, rectClient, (LPCTSTR)sWindowText,
		hIcon, bFlat, bHover, bPushed,
		false, bEnabled,
		(m_bDrawBorder && (!CExtPopupMenuWnd::IsMenuTracking()))
			? true : false,
		(bDrawFocusRect && (!CExtPopupMenuWnd::IsMenuTracking())
			&& (!sWindowText.IsEmpty()) )
			? true : false,
		bDefault, m_nAlign,
		NULL, _IsMenuAvail(), 0, bTransparent
		);

	if( hIcon != NULL )
	{
		::DestroyIcon( hIcon );
	}
}
Exemple #25
0
BOOL CCheckBox::Save()
{
	m_Value = GetCheck() ? L"1" : L"0";

	return CProFileRecord::Save();
}
void CCheckBoxTree::OnLButtonDown(UINT nFlags, CPoint point)
{
    UINT nHitTestFlags = 0;
    HTREEITEM hItem = HitTest(point, &nHitTestFlags);
    //MessageBox( "BEFORE IF", "IF1", MB_OK);
    if((hItem != nullptr) && (TVHT_ONITEMSTATEICON & nHitTestFlags))
    {
        //MessageBox( "INSIDE IF", "IF1", MB_OK);
        //BOOL bCheck= GetCheck(hItem);
        BOOL bCheck = bIsItemChecked(hItem);

        //vSetCheck(hItem,!bCheck);

        vSetCheckChildren(hItem,!bCheck);


        if(!bCheck)
        {
            HTREEITEM root,parent;

            root=GetRootItem();
            SetCheck(root);

            parent=GetParentItem(hItem);
            SetCheck(parent);
        }

        if(bCheck)
        {

            HTREEITEM root;
            HTREEITEM child;
            root=GetRootItem();
            SetCheck(root,0);

            while(ItemHasChildren(root))
            {
                //MessageBox("wHILE1", "WHILE1", MB_OK);
                HTREEITEM parent=GetChildItem(root);
                while(ItemHasChildren(parent))
                {
                    if(GetCheck(parent))
                    {
                        SetCheck(parent,0);
                        child=GetChildItem(parent);
                        //MessageBox( "wHILE2", "WHILE2", MB_OK);
                        while(child)
                        {
                            if(GetCheck(child))
                            {

                                SetCheck(root);
                                SetCheck(parent);
                            }
                            child=GetNextSiblingItem(child);
                            if ( child == nullptr )
                            {
                                break;
                            }
                        }
                    }
                    parent=GetNextSiblingItem(parent);
                    if ( parent == nullptr )
                    {
                        break;
                    }

                }

                parent=GetNextSiblingItem(parent);
                if ( parent == nullptr )
                {
                    break;
                }

            }
        }
    }

    else
    {
        //MessageBox( "INSIDE ELSE", "ELSE", MB_OK);
        CTreeCtrl::OnLButtonDown(nFlags, point);
    }
}
Exemple #27
0
void CheckBox::OnClick()
{
	SetCheck(!GetCheck());
}
void CCheckComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) 
{
	HDC dc = lpDrawItemStruct->hDC;

	CRect rcBitmap = lpDrawItemStruct->rcItem;
	CRect rcText   = lpDrawItemStruct->rcItem;

	CString strText;

	// 0 - No check, 1 - Empty check, 2 - Checked
	INT nCheck = 0;

	// Check if we are drawing the static portion of the combobox
	if ((UINT(-1)) == lpDrawItemStruct->itemID || NULL == m_hListBox) {
		// Make sure the m_strText member is updated
		RecalcText();

		// Get the text
		strText = m_strText;

		// Don't draw any boxes on this item
		nCheck = 0;
	}
	// Otherwise it is one of the items
	else 
    {
		GetLBText(lpDrawItemStruct->itemID, strText);
		nCheck = 1 + (GetCheck(lpDrawItemStruct->itemID));

        TEXTMETRIC metrics = { 0 };
		GetTextMetrics(dc, &metrics);

		rcBitmap.left    = 0;
		rcBitmap.right   = rcBitmap.left + metrics.tmHeight + metrics.tmExternalLeading + 6;
		rcBitmap.top    += 1;
		rcBitmap.bottom -= 1;

		rcText.left = rcBitmap.right;
	}

	if (nCheck > 0) {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));

		UINT nState = DFCS_BUTTONCHECK;

		if (nCheck > 1)
        {
			nState |= DFCS_CHECKED;
        }
		// Draw the checkmark using DrawFrameControl
		DrawFrameControl(dc, rcBitmap, DFC_BUTTON, nState);
	}

	if (lpDrawItemStruct->itemState & ODS_SELECTED) {
		SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
		SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
	}
	else {
		SetBkColor(dc, GetSysColor(COLOR_WINDOW));
		SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
	}

	// Erase and draw
	ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rcText, 0, 0, 0);
	DrawText(dc, ' ' + strText, strText.GetLength() + 1, &rcText, DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);

	if ((lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED)) == (ODS_FOCUS|ODS_SELECTED))
		DrawFocusRect(dc, &rcText);
}
void CDragDropListCtrl::DropItem()
{
	RestorePrevDropItemState();

	// Drop after currently selected item.
	m_nDropIndex++;
	if (m_nDropIndex < 0 || m_nDropIndex > GetItemCount() - 1)
	{
		// Fail safe - invalid drop index, so drop at end of list.
		m_nDropIndex = GetItemCount();
	}

	int nColumns = 1;
	CHeaderCtrl* pHeader = (CHeaderCtrl*)GetDlgItem(0);
	if (pHeader)
	{
		nColumns = pHeader->GetItemCount();
	}

	// »Øµ÷
	if( m_callbackFunc != NULL )
	{	
		if( m_callbackFunc(m_nDropIndex, std::tr1::ref(m_anDragIndexes)) == false )
			return;
	}

	
	// Move all dragged items to their new positions.
	for (int nDragItem = 0; nDragItem < m_anDragIndexes.GetSize(); nDragItem++)
	{
		int nDragIndex = m_anDragIndexes[nDragItem];

		if (nDragIndex > -1 && nDragIndex < GetItemCount())
		{
			// Get information about this drag item.
			char szText[256];
			LV_ITEM lvItem;
			ZeroMemory(&lvItem, sizeof(LV_ITEM));
			lvItem.iItem		= nDragIndex;
			lvItem.mask			= LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
			lvItem.stateMask	= LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED | LVIS_STATEIMAGEMASK;
			lvItem.pszText		= szText;
			lvItem.cchTextMax	= sizeof(szText) - 1;
			GetItem(&lvItem);
			BOOL bChecked = GetCheck(nDragIndex);
			
			// Before moving drag item, make sure it is deselected in its original location,
			// otherwise GetSelectedCount() will return 1 too many.
			SetItemState(nDragIndex, static_cast<UINT>(~LVIS_SELECTED), LVIS_SELECTED);

			// Insert the dragged item at drop index.
			lvItem.iItem		= m_nDropIndex;
			InsertItem(&lvItem);
			if (bChecked)
			{
				SetCheck(m_nDropIndex);
			}
			
			// Index of dragged item will change if item has been dropped above itself.
			if (nDragIndex > m_nDropIndex)
			{
				nDragIndex++;
			}

			// Fill in all the columns for the dragged item.
			lvItem.mask		= LVIF_TEXT;
			lvItem.iItem	= m_nDropIndex;

			for (int nColumn = 1; nColumn < nColumns; nColumn++)
			{
				_tcscpy(lvItem.pszText, (LPCTSTR)(GetItemText(nDragIndex, nColumn)));
				lvItem.iSubItem = nColumn;
				SetItem(&lvItem);
			}
			
			// Delete the original item.
			DeleteItem(nDragIndex);

			// Need to adjust indexes of remaining drag items.
			for (int nNewDragItem = nDragItem; nNewDragItem < m_anDragIndexes.GetSize(); nNewDragItem++)
			{
				int nNewDragIndex = m_anDragIndexes[nNewDragItem];

				if (nDragIndex < nNewDragIndex && nNewDragIndex < m_nDropIndex)
				{
					// Item has been removed from above this item, and inserted after it,
					// so this item moves up the list.
					m_anDragIndexes[nNewDragItem] = max(nNewDragIndex - 1, 0);
				}
				else if (nDragIndex > nNewDragIndex && nNewDragIndex > m_nDropIndex)
				{
					// Item has been removed from below this item, and inserted before it,
					// so this item moves down the list.
					m_anDragIndexes[nNewDragItem] = nNewDragIndex + 1;
				}
			}
			if (nDragIndex > m_nDropIndex)
			{
				// Item has been added before the drop target, so drop target moves down the list.
				m_nDropIndex++;
			}
		}
	}

	
	if (m_dwStyle != NULL)
	{
		// Style was modified, so return it back to original style.
		ModifyStyle(NULL, m_dwStyle);
		m_dwStyle = NULL;
	}
}
Exemple #30
0
void CPlayerSubresyncBar::UpdatePreview()
{
	if (m_mode == VOBSUB || m_mode == TEXTSUB) {
		if (0/*m_fUnlink*/) {
			for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) {
				bool fStartMod, fEndMod, fStartAdj, fEndAdj;
				GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj);
				m_sts[i].start = (fStartMod || fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart;
				m_sts[i].end = (fEndMod || fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend;
			}
		} else {
			CAtlArray<int> schk;

			for (int i = 0, j = (int)m_sts.GetCount(); i < j;) {
				schk.RemoveAll();

				int start = i, end;

				for (end = i; end < j; end++) {
					int data = (int)m_list.GetItemData(end);
					if ((data & TSEP) && end > i) {
						break;
					}
					if (data & (TSMOD | TSADJ)) {
						schk.Add(end);
					}
				}

				if (schk.IsEmpty()) {
					for (; start < end; start++) {
						m_sts[start].start = m_subtimes[start].orgstart;
						m_sts[start].end = m_subtimes[start].orgend;
					}
				} else if (schk.GetCount() == 1) {
					int k = schk[0];
					int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart;
					for (; start < end; start++) {
						m_sts[start].start = m_subtimes[start].orgstart + dt;
						m_sts[start].end = (m_list.GetItemData(start)&TEMOD)
										   ? m_subtimes[start].newend
										   : (m_subtimes[start].orgend + dt);
					}
				} else if (schk.GetCount() >= 2) {
					int i0 = 0;
					int i1 = 0;
					int ti0 = 0;
					int ds = 0;
					double m = 0;

					int k, l;
					for (k = 0, l = (int)schk.GetCount() - 1; k < l; k++) {
						i0 = schk[k];
						i1 = schk[k + 1];

						ti0 = m_subtimes[i0].orgstart;
						ds = m_subtimes[i1].orgstart - ti0;

						if (ds == 0) {
							SetSTS0(start, i1, ti0);
						} else {
							m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds;
							SetSTS1(start, i1, ti0, m, i0);
						}

					}

					ASSERT(k > 0);
					if (ds == 0) {
						SetSTS0(start, end, ti0);
					} else {
						SetSTS1(start, end, ti0, m, i0);
					}
				}

				i = end;
			}
		}

		m_sts.CreateSegments();

		for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) {
			TCHAR buff[32];
			FormatTime(i, buff, _countof(buff), 2, false);
			m_list.SetItemText(i, COL_PREVSTART, buff);
			FormatTime(i, buff, _countof(buff), 2, true);
			m_list.SetItemText(i, COL_PREVEND, buff);
		}

		if (IsWindowVisible()) {
			SaveSubtitle();
		}
	}
}