⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dipattn.c

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 C
📖 第 1 页 / 共 5 页
字号:
                   usFLowValue[i] = LOWORD(atol(szBuffer));
                   usFEnable |= (0x01 << i); 				   
				 }
				 else
				 { usFHiValue[i] = 0;
                   usFLowValue[i] = 0;}
                
            case IDCANCEL :
                EndDialog(hDlg, 0);
                return TRUE;

         }
         break;
    }
    return FALSE ;
}
/***************************************************************************
    FUNCTION: ConfigCounterProc(HWND, unsigned, WPARAM, LPARAM)

    PURPOSE:  Processes dialog box messages for scan time settings
****************************************************************************/

BOOL FTYPE ConfigCounterProc
(
    HWND        hDlg,                          // window handle
    unsigned    message,                       // type of message
    WPARAM      wParam,                        // additional information
    LPARAM      lParam                         // additional information
)
{
    char        szBuffer[40];
    USHORT      i;

    switch (message)
    {
    case WM_INITDIALOG :
        for(i=0; i<8; i++)
		{

		 EnableWindow(GetDlgItem(hDlg,(IDC_Counter0 + i)),TRUE);

		 if( usCEnable & (0x01 << i))
		 {   CheckDlgButton(hDlg,(IDC_Counter0 + i),TRUE);
			 EnableWindow(GetDlgItem(hDlg,(IDC_EDPeValue0 + i)),TRUE);
             sprintf(szBuffer, "%d", usCPreset[i]);
             SendDlgItemMessage(hDlg, (IDC_EDPeValue0 + i), EM_REPLACESEL, 0,
                             (LPARAM)((LPSTR)szBuffer));

			 EnableWindow(GetDlgItem(hDlg,(IDC_CMatch0 + i)),TRUE);
             if(usCMatchEnable & (0x01 << i))
			 {   CheckDlgButton(hDlg,(IDC_CMatch0 + i),TRUE);
			     EnableWindow(GetDlgItem(hDlg,(IDC_ED_Match0 + i)),TRUE);
                 sprintf(szBuffer, "%d", usCMatchValue[i]);
                 SendDlgItemMessage(hDlg, (IDC_ED_Match0 + i), EM_REPLACESEL, 0,
                                   (LPARAM)((LPSTR)szBuffer));}
			 else
			 {   CheckDlgButton(hDlg,(IDC_CMatch0 + i),FALSE);
			     EnableWindow(GetDlgItem(hDlg,(IDC_ED_Match0 + i)),FALSE);}

		     EnableWindow(GetDlgItem(hDlg,(IDC_COverflow0 + i)),TRUE);
			 if(usCOverflow & (0x01 << i))
			     CheckDlgButton(hDlg,(IDC_COverflow0 + i),TRUE);
			 else
			     CheckDlgButton(hDlg,(IDC_COverflow0 + i),FALSE);

			 EnableWindow(GetDlgItem(hDlg,(IDC_CTrigRedge0 + i)),TRUE);
			 EnableWindow(GetDlgItem(hDlg,(IDC_CTrigFedge0 + i)),TRUE);
             if(usTrigEdge & (0x01 << i))
				 CheckDlgButton(hDlg, (IDC_CTrigFedge0 + i),TRUE);
			 else
				 CheckDlgButton(hDlg, (IDC_CTrigRedge0 + i),TRUE);
		 
		 }else{   
			 EnableWindow(GetDlgItem(hDlg,(IDC_EDPeValue0 + i)),FALSE);
		     CheckDlgButton(hDlg,(IDC_EDPeValue0 + i),FALSE);
             
		     EnableWindow(GetDlgItem(hDlg,(IDC_CMatch0 + i)),FALSE);

			 EnableWindow(GetDlgItem(hDlg,(IDC_ED_Match0 + i)),FALSE);
			 CheckDlgButton(hDlg,(IDC_CMatch0 + i),FALSE);

		     EnableWindow(GetDlgItem(hDlg,(IDC_COverflow0 + i)),FALSE);

			 CheckDlgButton(hDlg,(IDC_COverflow0 + i),FALSE);

			 EnableWindow(GetDlgItem(hDlg,(IDC_CTrigRedge0 + i)),FALSE);

			 EnableWindow(GetDlgItem(hDlg,(IDC_CTrigFedge0 + i)),FALSE);
		 }

		}

        return TRUE;

    case WM_COMMAND :

         switch (LOWORD(wParam))
         {
		    case IDC_Counter0:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter0))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue0),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch0),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch0))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match0),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match0),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow0),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge0),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge0),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge0,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge0,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue0));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue0),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch0),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match0),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow0),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge0),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge0),FALSE);
				 }
				 break;
		    case IDC_Counter1:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter1))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue1),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch1),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch1))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match1),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match1),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow1),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge1),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge1),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge1,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge1,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue1));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue1),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch1),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match1),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow1),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge1),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge1),FALSE);
				 }
				 break;
		    case IDC_Counter2:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter2))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue2),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch2),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch2))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match2),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match2),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow2),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge2),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge2),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge2,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge2,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue2));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue2),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch2),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match2),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow2),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge2),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge2),FALSE);
				 }
				 break;
		    case IDC_Counter3:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter3))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue3),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch3),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch3))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match3),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match3),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow3),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge3),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge3),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge3,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge3,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue3));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue3),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch3),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match3),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow3),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge3),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge3),FALSE);
				 }
				 break;
		    case IDC_Counter4:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter4))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue4),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch4),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch4))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match4),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match4),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow4),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge4),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge4),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge4,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge4,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue4));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue4),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch4),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match4),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow4),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge4),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge4),FALSE);
				 }
				 break;
		    case IDC_Counter5:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter5))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue5),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch5),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch5))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match5),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match5),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow5),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge5),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge5),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge5,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge5,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue5));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue5),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch5),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match5),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow5),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge5),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge5),FALSE);
				 }
				 break;
		    case IDC_Counter6:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter6))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue6),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch6),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch6))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match6),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match6),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow6),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge6),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge6),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge6,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge6,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue6));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue6),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch6),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match6),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow6),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge6),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge6),FALSE);
				 }
				 break;
		    case IDC_Counter7:
                 if(IsDlgButtonChecked(hDlg, IDC_Counter7))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue7),TRUE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch7),TRUE);
					if(IsDlgButtonChecked(hDlg, IDC_CMatch7))
			           EnableWindow(GetDlgItem(hDlg,IDC_ED_Match7),TRUE);
					else
   		               EnableWindow(GetDlgItem(hDlg,IDC_ED_Match7),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow7),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge7),TRUE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge7),TRUE);
					CheckDlgButton(hDlg, IDC_CTrigRedge7,TRUE);
					CheckDlgButton(hDlg, IDC_CTrigFedge7,FALSE);
    	            SetFocus(GetDlgItem(hDlg,IDC_EDPeValue7));}
		         else
				 {
                    EnableWindow(GetDlgItem(hDlg,IDC_EDPeValue7),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_CMatch7),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_ED_Match7),FALSE);
		            EnableWindow(GetDlgItem(hDlg,IDC_COverflow7),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigRedge7),FALSE);
			        EnableWindow(GetDlgItem(hDlg,IDC_CTrigFedge7),FALSE);
				 }
				 break;
            
			// set match value
			case IDC_CMatch0:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch0))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match0),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match0));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match0),FALSE);
				 break;
			case IDC_CMatch1:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch1))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match1),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match1));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match1),FALSE);
				 break;
			case IDC_CMatch2:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch2))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match2),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match2));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match2),FALSE);
				 break;
			case IDC_CMatch3:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch3))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match3),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match3));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match3),FALSE);
				 break;
			case IDC_CMatch4:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch4))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match4),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match4));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match4),FALSE);
				 break;
			case IDC_CMatch5:
                 if(IsDlgButtonChecked(hDlg, IDC_CMatch5))
				 {  EnableWindow(GetDlgItem(hDlg,IDC_ED_Match5),TRUE);
    	            SetFocus(GetDlgItem(hDlg,IDC_ED_Match5));}
		         else
                    EnableWindow(GetDlgItem(hDlg,IDC_ED_Match5),FALSE);
				 break;
			case IDC_CMatch6:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -