?? loaddisrepairrecord.cpp
字號:
hRgn61 = BitmapToRegion((HBITMAP)bmp61, RGB(0, 0, 0));
m_back_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(128,66), hRgn61, this, back1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_back_1.SetWindowRgn(hRgn61, TRUE);
bmp62.LoadBitmap(IDB_BACK_2);
hRgn62 = BitmapToRegion((HBITMAP)bmp62, RGB(0, 0, 0));
m_back_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(148,66), hRgn62, this, back2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_back_2.SetWindowRgn(hRgn62, TRUE);
bmp63.LoadBitmap(IDB_BACK_3);
hRgn63 = BitmapToRegion((HBITMAP)bmp63, RGB(0, 0, 0));
m_back_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(128,86), hRgn63, this, back3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_back_3.SetWindowRgn(hRgn63, TRUE);
bmp64.LoadBitmap(IDB_BACK_4);
hRgn64 = BitmapToRegion((HBITMAP)bmp64, RGB(0, 0, 0));
m_back_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(148,86), hRgn64, this, back4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_back_4.SetWindowRgn(hRgn64, TRUE);
bmp11.DeleteObject();
bmp12.DeleteObject();
bmp13.DeleteObject();
bmp14.DeleteObject();
bmp21.DeleteObject();
bmp22.DeleteObject();
bmp23.DeleteObject();
bmp24.DeleteObject();
bmp31.DeleteObject();
bmp32.DeleteObject();
bmp33.DeleteObject();
bmp34.DeleteObject();
bmp41.DeleteObject();
bmp42.DeleteObject();
bmp43.DeleteObject();
bmp44.DeleteObject();
bmp51.DeleteObject();
bmp52.DeleteObject();
bmp53.DeleteObject();
bmp54.DeleteObject();
bmp61.DeleteObject();
bmp62.DeleteObject();
bmp63.DeleteObject();
bmp64.DeleteObject();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void LoadDisrepairRecord::OnCancelMode()
{
CDialog::OnCancelMode();
// TODO: Add your message handler code here
}
void LoadDisrepairRecord::OnSave()
{
// TODO: Add your control notification handler code here
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("與服務器連接中斷,請檢查網絡后重新登錄該系統!"),_T("出錯提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
modify = true;
UpdateData(true);
CString LLDRSQL;
int selectIndex = 0;
CString selectText = "";
selectIndex = m_damageCodeLDR.GetCurSel();
m_damageCodeLDR.GetLBText(selectIndex,selectText);
/////////////////////////////////////////////////////////////
if (selectText != _T("滅失")){
if (m_remark == VT_EMPTY){
MessageBox(_T("請先選擇殘損面!"),_T("出錯提示"));
return;
}
}
/////////////////////////////////////////////////////////////
if (selectText == _T("破損")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65a}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65a}";
}
if (selectText == _T("變形")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65c}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65c}";
}
if (selectText == _T("滅失")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65j}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65j}";
}
if (selectText == _T("洞")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65e}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65e}";
}
if (selectText == _T("凹損")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65f}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65f}";
}
if (selectText == _T("凸損")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65g}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65g}";
}
if (selectText == _T("刮傷")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65h}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65h}";
}
if (selectText == _T("其他")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65i}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65i}";
}
if (selectText == _T("空白")){
damageCode = "{19AFE800-FAFC-441D-AAEB-909F7C26E65k}";
propertyObjId = "{19AFE800-FAFC-441D-AAEB-909F7C26E65k}";
}
LLDRSQL = _T("");
LLDRSQL = "insert into tallyexceptioninfo values('"+objectId+"','"+tallyListItemObjId+"','"+propertyObjId+"','','"+m_remark+"','"+m_damageCondition+"','"+damageCode+"','','','','','')";
LLDRSQL=" "+LLDRSQL+'\0';
int iSize,retint;
char* pszMultiByte;
iSize = WideCharToMultiByte(CP_ACP, 0, LLDRSQL, -1, NULL, 0, NULL, NULL);
pszMultiByte = (char*)malloc((iSize+1)*sizeof(char));
WideCharToMultiByte(CP_ACP, 0, LLDRSQL, -1, pszMultiByte, iSize, NULL, NULL);
*pszMultiByte=1;
pszMultiByte++;
*pszMultiByte=iSize/256;
pszMultiByte++;
*pszMultiByte=iSize%256;
pszMultiByte=pszMultiByte-2;
send(clientSocket,pszMultiByte,iSize,0);
free(pszMultiByte);
delete pszMultiByte;
retint=recv(clientSocket,recvbuf2,sizeof(recvbuf2), 0);
if (recvbuf2[0]==8 && retint==1)
{
MessageBox(_T("網絡傳輸出錯,請重新點擊按鈕再試一次!!!"),_T("提示"));
return;
}
//CString UDRUTLISQL;
//UDRUTLISQL = "update tallylistitem set checkedFlag = '1',workDate = '"+workDate+"',workOrders = '"+workOrders+"' where objectId = '"+tallyListItemObjId+"'";
//UDRUTLISQL=" "+UDRUTLISQL+'\0';
//iSize = WideCharToMultiByte(CP_ACP, 0, UDRUTLISQL, -1, NULL, 0, NULL, NULL);
//pszMultiByte = (char*)malloc((iSize+1)*sizeof(char));
//WideCharToMultiByte(CP_ACP, 0, UDRUTLISQL, -1, pszMultiByte, iSize, NULL, NULL);
//*pszMultiByte=1;
//pszMultiByte++;
//*pszMultiByte=iSize/256;
//pszMultiByte++;
//*pszMultiByte=iSize%256;
//pszMultiByte=pszMultiByte-2;
//send(clientSocket,pszMultiByte,iSize,0);
//free(pszMultiByte);
//delete pszMultiByte;
//retint=recv(clientSocket,sBuf,2, 0);
//if (sBuf[0]==3)
//{
// MessageBox(_T("該條記錄已經成功保存!"));
//}
CDialog::OnOK();
}
void LoadDisrepairRecord::OnCancel()
{
// TODO: Add your control notification handler code here
modify = false;
CDialog::OnCancel();
}
HRGN LoadDisrepairRecord::BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance)
{
HRGN hRgn = NULL;
if (hBmp)
{
// Create a memory DC inside which we will scan the bitmap content
HDC hMemDC = CreateCompatibleDC(NULL);
if (hMemDC)
{
// Get bitmap size
BITMAP bm;
GetObject(hBmp, sizeof(bm), &bm);
// Create a 32 bits depth bitmap and select it into the memory DC
BITMAPINFOHEADER RGB32BITSBITMAPINFO = {
sizeof(BITMAPINFOHEADER), // biSize
bm.bmWidth, // biWidth;
bm.bmHeight, // biHeight;
1, // biPlanes;
16, // biBitCount
BI_RGB, // biCompression;
0, // biSizeImage;
0, // biXPelsPerMeter;
0, // biYPelsPerMeter;
0, // biClrUsed;
0 // biClrImportant;
};
VOID * pbits32;
HBITMAP hbm32 = CreateDIBSection(hMemDC,
(BITMAPINFO *)&RGB32BITSBITMAPINFO, DIB_RGB_COLORS, &pbits32, NULL, 0);
if (hbm32)
{
HBITMAP holdBmp = (HBITMAP)SelectObject(hMemDC, hbm32);
// Create a DC just to copy the bitmap into the memory DC
HDC hDC = CreateCompatibleDC(hMemDC);
if (hDC)
{
// Get how many bytes per row we have for the bitmap bits (rounded up to 32 bits)
BITMAP bm32;
GetObject(hbm32, sizeof(bm32), &bm32);
while (bm32.bmWidthBytes % 2)
bm32.bmWidthBytes++;
// Copy the bitmap into the memory DC
HBITMAP holdBmp = (HBITMAP)SelectObject(hDC, hBmp);
BitBlt(hMemDC, 0, 0, bm.bmWidth, bm.bmHeight, hDC, 0, 0, SRCCOPY);
// For better performances, we will use the ExtCreateRegion() function to create the
// region. This function take a RGNDATA structure on entry. We will add rectangles by
// amount of ALLOC_UNIT number in this structure.
#define ALLOC_UNIT 100
DWORD maxRects = ALLOC_UNIT;
HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects));
RGNDATA *pData = (RGNDATA *)GlobalLock(hData);
pData->rdh.dwSize = sizeof(RGNDATAHEADER);
pData->rdh.iType = RDH_RECTANGLES;
pData->rdh.nCount = pData->rdh.nRgnSize = 0;
SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);
// Keep on hand highest and lowest values for the "transparent" pixels
BYTE lr = GetRValue(cTransparentColor);
BYTE lg = GetGValue(cTransparentColor);
BYTE lb = GetBValue(cTransparentColor);
BYTE hr = min(0xff, lr + GetRValue(cTolerance));
BYTE hg = min(0xff, lg + GetGValue(cTolerance));
BYTE hb = min(0xff, lb + GetBValue(cTolerance));
// Scan each bitmap row from bottom to top (the bitmap is inverted vertically)
BYTE *p32 = (BYTE *)bm32.bmBits + (bm32.bmHeight - 1) * bm32.bmWidthBytes;
for (int y = 0; y < bm.bmHeight; y++)
{
// Scan each bitmap pixel from left to right
for (int x = 0; x < bm.bmWidth; x++)
{
// Search for a continuous range of "non transparent pixels"
int x0 = x;
short *p = (short *)p32 + x;
while (x < bm.bmWidth)
{
BYTE b = GetRValue(*p);
if (b >= lr && b <= hr)
{
b = GetGValue(*p);
if (b >= lg && b <= hg)
{
b = GetBValue(*p);
if (b >= lb && b <= hb)
// This pixel is "transparent"
break;
}
}
p++;
x++;
}
if (x > x0)
{
// Add the pixels (x0, y) to (x, y+1) as a new rectangle in the region
if (pData->rdh.nCount >= maxRects)
{
GlobalUnlock(hData);
maxRects += ALLOC_UNIT;
hData = GlobalReAlloc(hData, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), GMEM_MOVEABLE);
pData = (RGNDATA *)GlobalLock(hData);
}
RECT *pr = (RECT *)&pData->Buffer;
SetRect(&pr[pData->rdh.nCount], x0, y, x, y+1);
if (x0 < pData->rdh.rcBound.left)
pData->rdh.rcBound.left = x0;
if (y < pData->rdh.rcBound.top)
pData->rdh.rcBound.top = y;
if (x > pData->rdh.rcBound.right)
pData->rdh.rcBound.right = x;
if (y+1 > pData->rdh.rcBound.bottom)
pData->rdh.rcBound.bottom = y+1;
pData->rdh.nCount++;
// On Windows98, ExtCreateRegion() may fail if the number of rectangles is too
// large (ie: > 4000). Therefore, we have to create the region by multiple steps.
if (pData->rdh.nCount == 2000)
{
HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData);
if (hRgn)
{
CombineRgn(hRgn, hRgn, h, RGN_OR);
DeleteObject(h);
}
else
hRgn = h;
pData->rdh.nCount = 0;
SetRect(&pData->rdh.rcBound, MAXLONG, MAXLONG, 0, 0);
}
}
}
// Go to next row (remember, the bitmap is inverted vertically)
p32 -= bm32.bmWidthBytes;
}
// Create or extend the region with the remaining rectangles
HRGN h = ExtCreateRegion(NULL, sizeof(RGNDATAHEADER) + (sizeof(RECT) * maxRects), pData);
if (hRgn)
{
CombineRgn(hRgn, hRgn, h, RGN_OR);
DeleteObject(h);
}
else
hRgn = h;
// Clean up
GlobalFree(hData);
SelectObject(hDC, holdBmp);
DeleteDC(hDC);
}
DeleteObject(SelectObject(hMemDC, holdBmp));
}
DeleteDC(hMemDC);
}
}
return hRgn;
}
void LoadDisrepairRecord::OnClean()
{
// TODO: Add your control notification handler code here
m_remark = _T("");
UpdateData(FALSE);
}
void LoadDisrepairRecord::OnButton7()
{
// TODO: Add your control notification handler code here
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("與服務器連接中斷,請檢查網絡后重新登錄該系統!"),_T("出錯提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
int selectIndex = 0;
CString selectText = _T("");
selectIndex = m_damageCodeLDR.GetCurSel();
m_damageCodeLDR.GetLBText(selectIndex,selectText);
if (selectText == _T("滅失")){
MessageBox(_T("殘損情況輸入時殘損類型不能選擇為滅失!"),_T("出錯提示"));
return;
}else{
DisrepairInput disrepairInputDlg;
disrepairInputDlg.DoModal();
if (disrepairInputDlg.modify == true){
if (m_damageCondition == _T("")){
m_damageCondition = disrepairInputDlg.disrepairInputString;
}else{
m_damageCondition = m_damageCondition + ";" + disrepairInputDlg.disrepairInputString;
}
}
}
UpdateData(FALSE);
}
void LoadDisrepairRecord::OnButton8()
{
// TODO: Add your control notification handler code here
m_damageCondition = _T("");
UpdateData(FALSE);
}
void LoadDisrepairRecord::OnButton9()
{
// TODO: Add your control notification handler code here
/////////////////////////////////////////////////////////////////////////////////////
if (!socketconnect)
{
MessageBox(_T("與服務器連接中斷,請檢查網絡后重新登錄該系統!"),_T("出錯提示"));
return;
}
/////////////////////////////////////////////////////////////////////////////////////
int selectIndex = 0;
CString selectText = _T("");
selectIndex = m_damageCodeLDR.GetCurSel();
m_damageCodeLDR.GetLBText(selectIndex,selectText);
if (selectText == _T("滅失")){
DestroyLoseTypeSelect destroyLoseTypeSelectDlg;
destroyLoseTypeSelectDlg.DoModal();
if (destroyLoseTypeSelectDlg.modify == true){
m_damageCondition = destroyLoseTypeSelectDlg.destroyLoseTypeString;
}
}else{
MessageBox(_T("殘損情況選擇時殘損類型只能選擇為滅失!"),_T("出錯提示"));
return;
}
UpdateData(FALSE);
}
void LoadDisrepairRecord::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
UpdateData(true);
int selectIndex = 0;
CString selectText = _T("");
selectIndex = m_damageCodeLDR.GetCurSel();
m_damageCodeLDR.GetLBText(selectIndex,selectText);
if (selectText == _T("滅失")){
m_remark = _T("");
}
m_damageCondition = _T("");
UpdateData(false);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -