- CVI 정보나눔(www.cvi.kr)
- 스터디
- 질문답변
질문,답변
글 수 1,629
이번에 작업을 하다가 판넬에 그림을 보여줄 필요가 있어서 작업한 내용을 올립니다. 필요한 분들에게 도움이 되었으면 합니다.
만드는 방법은 먼저 판넬을 만들고 picture control을 만든다음 picture control의 Label과 Frame을 지우고 아래의 함수를 수행하면 됩니다.
BOOL CVIANSI SetBackgroundPicture (int panel, int control, char *lpBmpFile)
{
int bmpID = 0;
int w, h;
if (lpBmpFile[0]==' ') // 파일명이 없을경우에는 현재그림을 지움.
SetCtrlBitmap (panel, control, 0, bmpID);
else if (!GetBitmapFromFile (lpBmpFile, &bmpID)) {
GetPanelAttribute (panel, ATTR_WIDTH, &w);
GetPanelAttribute (panel, ATTR_HEIGHT, &h);
// 판넬에 메뉴가 있는경우, 없을경우에는 22 대신 0을 사용하면 됨.
SetCtrlAttribute (panel, control, ATTR_TOP, 22);
SetCtrlAttribute (panel, control, ATTR_LEFT, 0);
SetCtrlAttribute (panel, control, ATTR_WIDTH, w);
SetCtrlAttribute (panel, control, ATTR_HEIGHT, h-22);
SetCtrlAttribute (panel, control, ATTR_FRAME_VISIBLE, false);
// control 의 크기에 그림을 맞춤
SetCtrlAttribute (panel, control, ATTR_FIT_MODE, VAL_SIZE_TO_PICTURE);
// picture control 이 다른 control의 밑으로 가게함.
// control의 갯수 값이나 큰값을 사용하면됨.
SetCtrlAttribute (panel, control, ATTR_ZPLANE_POSITION, 100);
SetCtrlBitmap (panel, control, 0, bmpID);
bmpID = 0;
return true;
}
return false;
}
그럼 이만.
만드는 방법은 먼저 판넬을 만들고 picture control을 만든다음 picture control의 Label과 Frame을 지우고 아래의 함수를 수행하면 됩니다.
BOOL CVIANSI SetBackgroundPicture (int panel, int control, char *lpBmpFile)
{
int bmpID = 0;
int w, h;
if (lpBmpFile[0]==' ') // 파일명이 없을경우에는 현재그림을 지움.
SetCtrlBitmap (panel, control, 0, bmpID);
else if (!GetBitmapFromFile (lpBmpFile, &bmpID)) {
GetPanelAttribute (panel, ATTR_WIDTH, &w);
GetPanelAttribute (panel, ATTR_HEIGHT, &h);
// 판넬에 메뉴가 있는경우, 없을경우에는 22 대신 0을 사용하면 됨.
SetCtrlAttribute (panel, control, ATTR_TOP, 22);
SetCtrlAttribute (panel, control, ATTR_LEFT, 0);
SetCtrlAttribute (panel, control, ATTR_WIDTH, w);
SetCtrlAttribute (panel, control, ATTR_HEIGHT, h-22);
SetCtrlAttribute (panel, control, ATTR_FRAME_VISIBLE, false);
// control 의 크기에 그림을 맞춤
SetCtrlAttribute (panel, control, ATTR_FIT_MODE, VAL_SIZE_TO_PICTURE);
// picture control 이 다른 control의 밑으로 가게함.
// control의 갯수 값이나 큰값을 사용하면됨.
SetCtrlAttribute (panel, control, ATTR_ZPLANE_POSITION, 100);
SetCtrlBitmap (panel, control, 0, bmpID);
bmpID = 0;
return true;
}
return false;
}
그럼 이만.
허창원
강좌, 팁 난에 올리셔도 좋겠습니다. 좋은 팁, 감사합니다.