DIY编程器网

标题: uuprog开发教程:芯片支持库维护4 [打印本页]

作者: liyf    时间: 2014-12-27 07:54
标题: uuprog开发教程:芯片支持库维护4
上次讲了下快速搜索型号实现的功能,看视解说简单,其实功能实现讲究了技巧。这节我们来讲一下如何实现选择芯片型号,然后填充左边的相关参数。
下图就是点选型号的效果。

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

  39.         for (i=0; i<parent->m_arSizeList.GetSize(); i++)
  40.         {
  41.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceSize == parent->m_arSizeList.GetAt(i).TypeVal)
  42.                 m_cDeviceSize.SetCurSel(i);
  43.         }
  44.         for (i=0; i<parent->m_arVCCList.GetSize(); i++)
  45.         {
  46.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceVCC == parent->m_arVCCList.GetAt(i).TypeVal)
  47.                 m_cDeviceVCC.SetCurSel(i);
  48.         }
  49.         for (i=0; i<parent->m_arVPPList.GetSize(); i++)
  50.         {
  51.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceVPP == parent->m_arVPPList.GetAt(i).TypeVal)
  52.                 m_cDeviceVPP.SetCurSel(i);
  53.         }
  54.         for (i=0; i<parent->m_arOperationList.GetSize(); i++)
  55.         {
  56.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).OperationID == parent->m_arOperationList.GetAt(i).TypeVal)
  57.                 m_cOperationID.SetCurSel(i);
  58.         }
  59.         for (i=0; i<parent->m_arPinList.GetSize(); i++)
  60.         {
  61.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).DevicePinCount == parent->m_arPinList.GetAt(i).TypeVal)
  62.                 m_cDevicePinCount.SetCurSel(i);
  63.         }
  64.         for (i=0; i<parent->m_arDataWidthList.GetSize(); i++)
  65.         {
  66.                 if (parent->m_arDeviceList.GetAt(iDeviceSel).DeviceDataWidth == parent->m_arDataWidthList.GetAt(i).TypeVal)
  67.                 m_cDeviceDataWidth.SetCurSel(i);
  68.         }
  69. HBITMAP bmp =(HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
  70.                                                                    parent->m_sAppPath+"brand\\"+m_sDeviceManuICO/*或者相对路径*/,
  71.                                                                    IMAGE_BITMAP,0,0,LR_CREATEDIBSECTION|LR_LOADFROMFILE);

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

  76. m_cDeviceICICO.SetBitmap(bmp1);

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




作者: wlecust06    时间: 2021-1-24 13:55
这个可以的 不错




欢迎光临 DIY编程器网 (http://www.diybcq.com/) Powered by Discuz! X3.2