- CVI 정보나눔(www.cvi.kr)
- 스터디
- 개발메모
개발메모(형식에 매이지 않는 짤막한 개발 낙서)
글 수 174
컨트롤에 드래그앤드롭할 때의 처리를 위한 메모(아직은 허창원에게만 해당됩니다. 다른 분들에게는 KDManip.dll 라이브러리에 대한 소개가 된 후에 설명이 제대로 될 내용입니다.)
...common.h 파일에서 ------------------------------------------
extern KD_ControlPosition ContPosition;
...common.c 파일에서 ------------------------------------------
KD_ControlPosition ContPosition;
Initialize_DEFPROG_Before_DisplayPanel() 함수에서 -------------
// Control Position 초기화
KD_ControlPosition_Initialize(&ContPosition, 1);
KD_ControlPosition_AddControl(&ContPosition, panelHandle, PANEL_deco_inputfile);
// KD_ControlPosition_AddControl(&ContPosition, panelHandle, PANEL_deco2);
// 드래그앤 드롭 인에이블
EnableDragAndDrop (panelHandle);
PanelCB()에서--------------------------------------------------
int CVICALLBACK PanelCB (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
switch (event)
{
case EVENT_GOT_FOCUS:
break;
case EVENT_LOST_FOCUS:
break;
case EVENT_CLOSE:
QuitUserInterface (0);
break;
// 드래그앤드롭 처리-시작
//This event occurs when files are dragged and dropped on the panel
case EVENT_FILESDROPPED:
{
char** files;
char* firstFile;
int index;
int xcord, ycord;
// 마우스의 위치값을 구함
GetRelativeMouseState (panelHandle, 0, &xcord, &ycord, NULL, NULL, NULL);
files = (char**)eventData1;
//firstFile = files[0];
index=0;
while(files[index]) // 파일명을 저장하는 문자열 공간이 NULL이 아니라면...
{
if(files[index][0]) /// 파일명이 NULL로 시작하지 않는다면...
{
int retval;
// 파일명만 뽑아냄
KD_Extract_Filename_only(files[index], g_KDBuffer);
/*
retval = KD_ControlPosition_FindControlIndex(&ContPosition, panelHandle, xcord, ycord);
if(retval == 0) /// index가 0이면 PANEL_deco1 이므로 PANEL_strFilepath_Cont1에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont1, ATTR_CTRL_VAL, g_KDBuffer);
}
else if(retval == 1) /// index가 1이면 PANEL_deco2 이므로 PANEL_strFilepath_Cont2에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont2, ATTR_CTRL_VAL, g_KDBuffer);
}
else // 둘다 아니면 panel 바탕에 떨어짐
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath, ATTR_CTRL_VAL, g_KDBuffer);
}
*/
retval = KD_ControlPosition_FindControl(&ContPosition, panelHandle, xcord, ycord);
if(retval == PANEL_deco1) /// PANEL_deco1 이므로 PANEL_strFilepath_Cont1에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont1, ATTR_CTRL_VAL, g_KDBuffer);
}
else if(retval == PANEL_deco2) /// PANEL_deco2 이므로 PANEL_strFilepath_Cont2에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont2, ATTR_CTRL_VAL, g_KDBuffer);
}
else // 둘다 아니면 panel 바탕에 떨어짐
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath, ATTR_CTRL_VAL, g_KDBuffer);
}
//static char Tmp_Buff[30];
// 파일의 확장자를 뽑아내서, ".WMV" 혹은 ".wmv"일 때만 리스트 박스에 추가함
//KD_Get_FileExtension(files[index], Tmp_Buff);
//if(!stricmp(Tmp_Buff, ".wmv"))
//{
// // 전체 경로명에서 파일명만 g_KDBuffer로 뽑아냄
// KD_Extract_Filename_only(files[index], g_KDBuffer);
//
// // Listbox에 Label과 value를 추가함.
// InsertListItem (panelHandle, PANEL_listboxFileList, -1, g_KDBuffer, files[index]);
//}
}
index++;
}
}
break;
// 드래그앤드롭 처리-마침
}
return 0;
}
...common.h 파일에서 ------------------------------------------
extern KD_ControlPosition ContPosition;
...common.c 파일에서 ------------------------------------------
KD_ControlPosition ContPosition;
Initialize_DEFPROG_Before_DisplayPanel() 함수에서 -------------
// Control Position 초기화
KD_ControlPosition_Initialize(&ContPosition, 1);
KD_ControlPosition_AddControl(&ContPosition, panelHandle, PANEL_deco_inputfile);
// KD_ControlPosition_AddControl(&ContPosition, panelHandle, PANEL_deco2);
// 드래그앤 드롭 인에이블
EnableDragAndDrop (panelHandle);
PanelCB()에서--------------------------------------------------
int CVICALLBACK PanelCB (int panel, int event, void *callbackData,
int eventData1, int eventData2)
{
switch (event)
{
case EVENT_GOT_FOCUS:
break;
case EVENT_LOST_FOCUS:
break;
case EVENT_CLOSE:
QuitUserInterface (0);
break;
// 드래그앤드롭 처리-시작
//This event occurs when files are dragged and dropped on the panel
case EVENT_FILESDROPPED:
{
char** files;
char* firstFile;
int index;
int xcord, ycord;
// 마우스의 위치값을 구함
GetRelativeMouseState (panelHandle, 0, &xcord, &ycord, NULL, NULL, NULL);
files = (char**)eventData1;
//firstFile = files[0];
index=0;
while(files[index]) // 파일명을 저장하는 문자열 공간이 NULL이 아니라면...
{
if(files[index][0]) /// 파일명이 NULL로 시작하지 않는다면...
{
int retval;
// 파일명만 뽑아냄
KD_Extract_Filename_only(files[index], g_KDBuffer);
/*
retval = KD_ControlPosition_FindControlIndex(&ContPosition, panelHandle, xcord, ycord);
if(retval == 0) /// index가 0이면 PANEL_deco1 이므로 PANEL_strFilepath_Cont1에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont1, ATTR_CTRL_VAL, g_KDBuffer);
}
else if(retval == 1) /// index가 1이면 PANEL_deco2 이므로 PANEL_strFilepath_Cont2에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont2, ATTR_CTRL_VAL, g_KDBuffer);
}
else // 둘다 아니면 panel 바탕에 떨어짐
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath, ATTR_CTRL_VAL, g_KDBuffer);
}
*/
retval = KD_ControlPosition_FindControl(&ContPosition, panelHandle, xcord, ycord);
if(retval == PANEL_deco1) /// PANEL_deco1 이므로 PANEL_strFilepath_Cont1에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont1, ATTR_CTRL_VAL, g_KDBuffer);
}
else if(retval == PANEL_deco2) /// PANEL_deco2 이므로 PANEL_strFilepath_Cont2에 출력
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath_Cont2, ATTR_CTRL_VAL, g_KDBuffer);
}
else // 둘다 아니면 panel 바탕에 떨어짐
{
SetCtrlAttribute(panelHandle, PANEL_strFilepath, ATTR_CTRL_VAL, g_KDBuffer);
}
//static char Tmp_Buff[30];
// 파일의 확장자를 뽑아내서, ".WMV" 혹은 ".wmv"일 때만 리스트 박스에 추가함
//KD_Get_FileExtension(files[index], Tmp_Buff);
//if(!stricmp(Tmp_Buff, ".wmv"))
//{
// // 전체 경로명에서 파일명만 g_KDBuffer로 뽑아냄
// KD_Extract_Filename_only(files[index], g_KDBuffer);
//
// // Listbox에 Label과 value를 추가함.
// InsertListItem (panelHandle, PANEL_listboxFileList, -1, g_KDBuffer, files[index]);
//}
}
index++;
}
}
break;
// 드래그앤드롭 처리-마침
}
return 0;
}