#include #include #include #include #include #include #include "ldmicro.h" #include "naminglist.h" #include "components\components.h" #include "advanceddialog.h" LVITEM lvi; void ShowNameListDialog(); double SaveNameListDialog(int PinId, int Index); static BOOL DlgDone, DlgCancel; static LRESULT CALLBACK SmplDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); int NameList_AddName(LPCTSTR Name, int PinId, int Index) { lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; lvi.state = lvi.stateMask = 0; lvi.iItem = Index; lvi.iSubItem = 0; lvi.pszText = (LPSTR)Name; lvi.lParam = PinId; return ListView_InsertItem(NamingList, &lvi); } int NameList_AddVolt(LPCTSTR Name, int Index) { ListView_SetItemText(NamingList, Index, 1 , (LPSTR)Name); return 0; } void PopulateNamingList() { int ItmCount = Prog.io.count; int i; // ListView_DeleteAllItems(NamingList); for(i=0; i=0) { if(McuPin[index].InternalPullup) { NameList_AddVolt((LPCTSTR)"Pullup", NameIndex); NameId[i].PinData.Volt = VOLT_5; } else { NameList_AddVolt((LPCTSTR)"V_OPEN", NameIndex); NameId[i].PinData.Volt = V_OPEN; } // MessageBox(NULL, (LPCTSTR)NameId[i].Name,"Test", MB_OK | MB_ICONWARNING); } else { char Voltage[15]; sprintf((char*)Voltage,"%f", NameId[i].PinData.Volt); NameList_AddVolt(LPCTSTR(Voltage), NameIndex); /*char Debug[256]; sprintf_s(Debug, "Nameid[%d].PinData.Volt = %f \t Index= %d\n", i,NameId[i].PinData.Volt, NameIndex); OutputDebugString(Debug);*/ } NameId[i].PinData.ProgVolt = NameId[i].PinData.Volt; } } void NamingListProc(NMHDR *h) { switch(h->code) { case LVN_ITEMACTIVATE: { if(!SimulationStarted) { int PinId; // NMITEMACTIVATE *i = (NMITEMACTIVATE *)h; LVITEM lvi; lvi.mask = LVIF_PARAM; lvi.iItem = ListView_GetNextItem(NamingList, -1, LVNI_SELECTED); ListView_GetItem(NamingList, &lvi); PinId = (int) lvi.lParam; int index = IsMCUPin(PinId); if(index >= 0) { ToggleInternalPullup(PinId); McuPin[index].InternalPullup ? NameList_AddVolt((LPCTSTR)"Pullup", lvi.iItem): NameList_AddVolt((LPCTSTR)"V_OPEN", lvi.iItem); // MessageBox(NULL, "Pullup","NamingListProc" , MB_OK | MB_ICONWARNING): // MessageBox(NULL, "V_OPEN", "NamingListProc", MB_OK | MB_ICONWARNING); /*char vx[3],vy[3]; _itoa(PinId,vy,10); _itoa(index,vx,10); MessageBox(NULL, "Selected", _(vx), MB_OK | MB_ICONWARNING);*/ } else SaveNameListDialog(PinId,lvi.iItem); // Set voltage for PinId if it is not mcupin /*char vx[3],vy[3]; _itoa(10,vy,10); _itoa(PinId,vx,10); MessageBox(NULL, "Selected", _(vx), MB_OK | MB_ICONWARNING);*/ } break; } default: break; } } void MakeSmplDialogClass(void) { WNDCLASSEX wc; memset(&wc, 0, sizeof(wc)); wc.cbSize = sizeof(wc); wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | CS_DBLCLKS; wc.lpfnWndProc = (WNDPROC)SmplDlgProc; wc.hInstance = Instance; wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; wc.lpszClassName = "SmplDialog"; wc.lpszMenuName = NULL; wc.hCursor = LoadCursor(NULL, IDC_SIZEWE); wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), IMAGE_ICON, 32, 32, 0); wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), IMAGE_ICON, 16, 16, 0); RegisterClassEx(&wc); AdvNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Tahoma"); if(!AdvNiceFont) AdvNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); AdvFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_DONTCARE, "Lucida Console"); if(!AdvFixedFont) AdvFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); } static LRESULT CALLBACK SmplDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_NOTIFY: break; case WM_COMMAND: { HWND h = (HWND)lParam; if(h == OkButton && wParam == BN_CLICKED) { DlgDone = TRUE; } else if(h == CancelButton && wParam == BN_CLICKED) { DlgDone = TRUE; DlgCancel = TRUE; } break; } case WM_CLOSE: case WM_DESTROY: DlgDone = TRUE; DlgCancel = TRUE; break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 1; } double SaveNameListDialog(int PinId, int Index) { double volt; for(UINT i=0;i