📄 复件 boundary.cpp
字号:
{
sscanf(buffer + j + 1,"%d",&ofset);
break;
}
break;
}
}
tNum -= ofset;
}
strcat(targetstr,": ");
while(!feof(hfile))
{
ReadLine(hfile, buffer);
if(MatchWord(targetstr,buffer))
{
temp = strlen(buffer);
for(j=strlen(targetstr);j<temp;j++)
{
if(buffer[j] == '(')buffer[j] = ' ';
if(buffer[j] == ' ')continue;
if(tNum == 0)
{
sscanf(buffer+j,"%s,", tPin);
break;
}
if(buffer[j] == ',')tNum--;
}
temp = strlen(tPin);
for(j=0;j<temp;j++)if((tPin[j] == ',')||(tPin[j] == ')')||(tPin[j] == '"'))tPin[j] = 0;
strcpy(chip->Boundary.Register[i].Pin, tPin);
break;
}
}
}
fclose(hfile);
return TRUE;
};
void FreeDevice(Device * chip)
{
free(chip->ID.IdCode);
free(chip->Boundary.Register);
free(chip->Instruction.ExTest);
free(chip->Name);
free(chip);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_BOUNDARY, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_BOUNDARY);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_BOUNDARY);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = (LPCSTR)IDC_BOUNDARY;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
HWND hListFile,hListDevice,hListPin;
HWND hWait;
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
char path[255], path1[255];
FILE* htestfile;
int deviceNum, boundaryNum;
switch (message)
{
case WM_CREATE:
hListFile = CreateWindow("LISTBOX","",WS_CHILD|LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER,0,0,200,200,hWnd,(HMENU)20001,hInst,NULL);
hListDevice = CreateWindow("LISTBOX","",WS_CHILD|LBS_NOTIFY | WS_VSCROLL | WS_BORDER,200,0,200,200,hWnd,(HMENU)20002,hInst,NULL);
hListPin = CreateWindow("LISTBOX","",WS_CHILD|LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER,400,0,600,200,hWnd,(HMENU)20003,hInst,NULL);
GetCurrentDirectory(255, path);
GetCurrentDirectory(255, path1);
strcat(path,"\\*.BCL");
DlgDirList(hWnd, path, 20001, 0, 0);
ShowWindow(hListFile, SW_SHOW);
ShowWindow(hListDevice, SW_SHOW);
ShowWindow(hListPin, SW_SHOW);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case 20002:
switch(wmEvent)
{
case LBN_SELCHANGE:
SendMessage(hListPin, LB_RESETCONTENT, (WPARAM)0l, (LPARAM)0l);
CurrentDevice = FirstDevice;
deviceNum = SendMessage(hListDevice, LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0 );
while(deviceNum>0)
{
CurrentDevice = CurrentDevice->Next;
if(CurrentDevice == NULL)exit(0);
deviceNum--;
}
for(boundaryNum = 0;boundaryNum<CurrentDevice->Boundary.Length;boundaryNum++)
if((CurrentDevice->Boundary.Register[boundaryNum].Pin[0] != '*')&&
((CurrentDevice->Boundary.Register[boundaryNum].Type[0] == 'B')||
(CurrentDevice->Boundary.Register[boundaryNum].Type[0] == 'O')))
{
sprintf(path,"%-5d %-7s %5d %c %c %-7s %c %-20s %-9s%c", boundaryNum,
CurrentDevice->Boundary.Register[boundaryNum].Cell,
CurrentDevice->Boundary.Register[boundaryNum].ControlReg,
CurrentDevice->Boundary.Register[boundaryNum].ControlVal,
CurrentDevice->Boundary.Register[boundaryNum].DisableVal,
CurrentDevice->Boundary.Register[boundaryNum].Pin,
CurrentDevice->Boundary.Register[boundaryNum].SafeVal,
CurrentDevice->Boundary.Register[boundaryNum].Signal,
CurrentDevice->Boundary.Register[boundaryNum].Type,0);
SendMessage(hListPin, LB_ADDSTRING, (WPARAM)0l, (LPARAM)path);
}
break;
}
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
case 20001:
switch(wmEvent)
{
case LBN_SELCHANGE:
/*CurrentDevice = LastDevice;
while(CurrentDevice != NULL)
{
CurrentDevice = CurrentDevice->Prev;
FreeDevice(CurrentDevice->Next);
}*/
if(LastDevice != NULL)FreeDevice(LastDevice->Prev);
CurrentDevice = LastDevice = FirstDevice = NULL;
SendMessage(hListFile, LB_GETTEXT, (WPARAM)SendMessage(hListFile, LB_GETCURSEL, (WPARAM) 0, (LPARAM) 0 ), (LPARAM) path);
strcpy(path1,"\\TEST\\");
strcpy(path1,path);
htestfile = fopen(path1,"r");
SendMessage(hListDevice, LB_RESETCONTENT, (WPARAM)0l, (LPARAM)0l);
while(!feof(htestfile))
{
ReadLine(htestfile, path);
if((path[0] == 0)||(path[0] == ' '))continue;
SendMessage( hListDevice, LB_ADDSTRING, (WPARAM) 0l, (LPARAM) path);
LastDevice = (struct Device*)malloc(sizeof(Device));
if(!FillDevice(LastDevice,path))
{
MessageBox(hWnd,path,"BSD file not found!",MB_OK);//,"Error in Library"
exit(0);
}
if(FirstDevice == NULL)
CurrentDevice = FirstDevice = LastDevice;
else
{
CurrentDevice->Next = LastDevice;
LastDevice->Prev = CurrentDevice;
}
CurrentDevice = LastDevice;
}
fclose(htestfile);
break;
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
//DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_SIZE:
MoveWindow(hListFile,0,0,200,HIWORD(lParam),TRUE);
MoveWindow(hListDevice,200,0,200,HIWORD(lParam),TRUE);
MoveWindow(hListPin,400,0,(LOWORD(lParam)-400)/2,HIWORD(lParam),TRUE);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for about box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -