后装机-计划系统(BC45 编程注意、技巧、提示)

1.    ComboBox 中如何添加文字?  
ResourceID:IDQ_SOURCELEN
SendDlgItemMessage(hDlg,IDQ_SOURCEL,CB_ADDSTRING,
0 ,(LPARAM)((LPSTR) " 790 " ));
参照计划系统 wdproc.cpp   OutputLenDialogProc

2.    EditText 中如何添加文字?  
SetDlgItemText(hDlg,IDC_HOSPITALNAME,”hospital”);

3 .    Menu丢了怎么办?
只要重新再定义一下某个Menu的名字即可!

4 .    如何在BC里添加Dialog,并与它的回调函数相对应?
plan2.cpp
LRESULT FAR PASCAL _export SearchSourceActDialogProc( HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam)
{
    LPSTR  str;
    
switch(message)
    
{
        
case WM_INITDIALOG:        
//            CentreWindow(hDlg);    
            SetFocus(GetDlgItem(hDlg,IDC_SYEAR));
        
case WM_COMMAND:
            
switch (wParam)
            
{
                
case IDOK:
                    SearchSourceActive(hDlg);
                    str 
= ftoa(Scuractiv,4);                    
                    SetDlgItemText(hDlg,IDC_SVALUE,str);
                    
break;
                
case IDCANCEL:
                  EndDialog(hDlg,TRUE);
                  
break;
            }
            
    }

    
return FALSE;
}


void  SearchSourceActive(HWND hDlg)
{…}        


plan1.cpp
LRESULT FAR PASCAL _export SourceDialogProc( HWND hDlg, UINT message,     WPARAM wParam, LPARAM lParam)
{
… 
 
switch(message)
     
{
      
case WM_INITDIALOG:
             CentreWindow(hDlg);
             SetFocus(GetDlgItem(hDlg,IDC_YEAR));
             wsprintf(s,
"%u",(int)cfg[101]);
             SetDlgItemText(hDlg, IDC_YEAR,s);
             wsprintf(s,
"%u",(int)cfg[100]);
             SetDlgItemText(hDlg, IDC_MONTH,s);
             wsprintf(s,
"%u",(int)cfg[99]);
             SetDlgItemText(hDlg, IDC_DATE,s);
             wsprintf(s,
"%u.0",(int)cfg[102]);
             SetDlgItemText(hDlg, IDC_SOURCE,s);    
         
             
if(strncmp(master,DocId,6)!=0)
                 
{
                   HWND hWnd;
                  hWnd 
= GetDlgItem(hDlg,IDC_PASSWORD);
                  EnableWindow(hWnd,FALSE);
                 }
    
             
          
return FALSE;
      
case WM_COMMAND:
          
switch (wParam)
              
{
                
case IDC_SEARCH://IDC_SEARCH 是"查询"按钮的名字                 
                         FARPROC   lpfnModalDialog;     
                          lpfnModalDialog
=MakeProcInstance((FARPROC)SearchSourceActDialogProc,hInst);
                         DialogBox( hInst,
"SearchSA",    hDlg,    lpfnModalDialog);//"SearchSA" 是对话框的名字,此时对话框与它的回调函数(SearchSourceActDialogProc)关联了
                         FreeProcInstance( lpfnModalDialog);
                  
break;

}


}


5.    如何自动计算出源长度?
思路:判断每一个通道的驻留点,如果第一个点为实点,则退出判断;如果每一个点为空点,则继续向下判断,直到发现一个实点就停止判断,统计出停止前空点的数目,乘上步进长度,就是最终出源后要减去的长度。

plan1.cpp
case IDOK:
    
int i,j,k,m;
    
static int count[18];
    
for(k=0;k<18;k++)
    
{
    count[k]
=0;
    }

    
for(i=0;i<18;i++)
    
{
        
for(j=0;j<50;j++)
        
{
            
if(actpots[i][j]==65)//'A'的ASCII码:65
            {
                
break;
            }

            
else
            
{
                count[i]
++;
            }

        }

    }

    
for(m=0;m<18;m++)
    
{
        Outoffset[m]
=(count[m]-1)*interval;
    }


wdproc.cpp
LRESULT FAR PASCAL _export OutputLenDialogProc( HWND hDlg, UINT message,WPARAM wParam, LPARAM lParam)
{
    ...
    
if(getval>0)
    
{
        SourceLen[icurcath]
=atoi(s) - Outoffset[icurcath];
        
char temp[4];
        itoa(SourceLen[icurcath],temp,
10);
        strcat(text,temp);
        MessageBox(hDlg,text,
"出源长度提示",MB_OK);
        ...
    }
    
    ...                        
}


//actpots[19][50] 存储驻留点的数组,实点用’A’表示
//interval 步长
//cathnum 通道数

你可能感兴趣的:(编程,Date,command,search,dialog,menu)