private void btnMakProgram_Click(object sender, System.EventArgs e) { Boolean bRet = false; IntPtr hObj = CP5200.CP5200_Program_Create(Convert.ToInt32(m_txtWidth.Text), Convert.ToInt32(m_txtHeight.Text), 0x77); if (hObj != IntPtr.Zero) { //分左右兩個窗口, int[] nWndRect = new int[8]; GetSplitWnd(nWndRect); if (CP5200.CP5200_Program_SetProperty(hObj, 0xFFFF, 1) > 0) { int nItemCnt = 0; //0號窗口放文字, int nWndNo = CP5200.CP5200_Program_AddPlayWindow(hObj, nWndRect[0], nWndRect[1], nWndRect[2] - nWndRect[0], nWndRect[3] - nWndRect[1]); if (nWndNo >= 0) { CP5200.CP5200_Program_SetWindowProperty(hObj, nWndNo, 0x30, 1); //設置窗口邊框 //添加文本節目 if (CP5200.CP5200_Program_AddText(hObj, nWndNo, Marshal.StringToHGlobalAnsi(m_txtText.Text), 16, 0xFF, 0xFFFF, 100, 3) >= 0) { nItemCnt++; } } //1號窗口放圖片 nWndNo = CP5200.CP5200_Program_AddPlayWindow(hObj, nWndRect[4], nWndRect[5], nWndRect[6] - nWndRect[4], nWndRect[7] - nWndRect[5]); if (nWndNo >= 0) { //添加圖片節目 if (CP5200.CP5200_Program_AddPicture(hObj, nWndNo, Marshal.StringToHGlobalAnsi(m_txtPict.Text), 2, 0xFFFF, 100, 3, 0) >= 0) { nItemCnt++; } } if (nItemCnt > 0 && CP5200.CP5200_Program_SaveToFile(hObj, GetProgramFileName()) >= 0) { bRet = true; } } CP5200.CP5200_Program_Destroy(hObj); } if (bRet) { MessageBox.Show("Successful"); } else { MessageBox.Show("Fail"); } }