查看完整版本: uuprog开发教程:芯片支持库维护4

liyf 发表于 2014-12-27 07:54:53

uuprog开发教程:芯片支持库维护4

上次讲了下快速搜索型号实现的功能,看视解说简单,其实功能实现讲究了技巧。这节我们来讲一下如何实现选择芯片型号,然后填充左边的相关参数。
下图就是点选型号的效果。

点选操作要实现填充窗口左边的相关参数,方便用户查看与修改,这些参数基本就是实现该型号的各种编程操作必须的值,非常重要,不可以出差错。例如编程电压,把这个设高了最后的结果就是编程时直接把芯片烧了。这就是编程器厂家最不愿用户遇到的,同时也是用户不想的。
要实现这个功能主要要处理列表框的单击消息lbn_selchange,我们这里对应的处理函数就是OnSelchangeDeviceList()。下面就是实现代码:
void CProgDeviceManage::OnSelchangeDeviceList()
{
        // TODO: Add your control notification handler code here
        CString temp;
        int iDeviceSel;
        m_cDeviceList.GetText(m_cDeviceList.GetCurSel(),temp);
        for (int i=0; i<parent->m_arDeviceList.GetSize(); i++)
        {
                if(temp == parent->m_arDeviceList.GetAt(i).DeviceName)
                        iDeviceSel = i;
        }
        m_sDeviceName = parent->m_arDeviceList.GetAt(iDeviceSel).DeviceName;
        temp.Format("%04x",parent->m_arDeviceList.GetAt(iDeviceSel).DeviceManuID);
        m_sDeviceManuID = temp;
        temp.Format("%04x",parent->m_arDeviceList.GetAt(iDeviceSel).DeviceID);
        m_sDeviceID = temp;
        m_sDeviceManuName = parent->m_arDeviceList.GetAt(iDeviceSel).DeviceManuName;
        temp.Format("%04x",parent->m_arDeviceList.GetAt(iDeviceSel).DeviceCheckCRC);
        m_sDeviceCheckCRC = temp;
        m_sDeviceManuICO = parent->m_arDeviceList.GetAt(iDeviceSel).DeviceManuICO;
        m_sDeviceICICO = parent->m_arDeviceList.GetAt(iDeviceSel).DeviceICICO;
        m_sDeviceDatasheet = parent->m_arDeviceList.GetAt(iDeviceSel).Datasheet;
        m_sDeviceNote = parent->m_arDeviceList.GetAt(iDeviceSel).DeviceNote;
        for (i=0; i<parent->m_arAdapterList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceAdapter == parent->m_arAdapterList.GetAt(i).TypeVal)
                m_cDeviceAdapter.SetCurSel(i);
        }
        for (i=0; i<parent->m_arPackageList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DevicePackage == parent->m_arPackageList.GetAt(i).TypeVal)
                m_cDevicePackage.SetCurSel(i);
        }
        for (i=0; i<parent->m_arTypeList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceType == parent->m_arTypeList.GetAt(i).TypeVal)
                m_cDeviceType.SetCurSel(i);
        }

        for (i=0; i<parent->m_arSizeList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceSize == parent->m_arSizeList.GetAt(i).TypeVal)
                m_cDeviceSize.SetCurSel(i);
        }
        for (i=0; i<parent->m_arVCCList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceVCC == parent->m_arVCCList.GetAt(i).TypeVal)
                m_cDeviceVCC.SetCurSel(i);
        }
        for (i=0; i<parent->m_arVPPList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceVPP == parent->m_arVPPList.GetAt(i).TypeVal)
                m_cDeviceVPP.SetCurSel(i);
        }
        for (i=0; i<parent->m_arOperationList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).OperationID == parent->m_arOperationList.GetAt(i).TypeVal)
                m_cOperationID.SetCurSel(i);
        }
        for (i=0; i<parent->m_arPinList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DevicePinCount == parent->m_arPinList.GetAt(i).TypeVal)
                m_cDevicePinCount.SetCurSel(i);
        }
        for (i=0; i<parent->m_arDataWidthList.GetSize(); i++)
        {
                if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceDataWidth == parent->m_arDataWidthList.GetAt(i).TypeVal)
                m_cDeviceDataWidth.SetCurSel(i);
        }
HBITMAP bmp =(HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
                                                                   parent->m_sAppPath+"brand\\"+m_sDeviceManuICO/*或者相对路径*/,
                                                                   IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);

m_cDeviceManuICO.SetBitmap(bmp);
HBITMAP bmp1 =(HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
                                                                   parent->m_sAppPath+"brand\\ic\\"+m_sDeviceICICO/*或者相对路径*/,
                                                                   IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);

m_cDeviceICICO.SetBitmap(bmp1);

        UpdateData(false);
}
这个函数首先查找到数组中对应的项后获取相关的参数,然后格式化填充到参数窗口里,这里有些需要转换成对应的值,很有技巧的,希望多多研究。
今天先讲到这里,下次就是添加修改操作了,建议大家还是下份源代码先看下。



wlecust06 发表于 2021-1-24 13:55:52

这个可以的 不错
页: [1]
查看完整版本: uuprog开发教程:芯片支持库维护4