?? disrepairrecord.cpp
字號:
// DisrepairRecord.cpp : implementation file
//
#include "stdafx.h"
#include "CTSClient.h"
#include "DisrepairRecord.h"
#include "DisrepairInput.h"
#include "DestroyLoseTypeSelect.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern SOCKET clientSocket;
extern CString workDate;
extern CString workOrders;
/////////////////////////////////////////////////////////////////////////////
extern BOOL socketconnect;
/////////////////////////////////////////////////////////////////////////////
extern char recvbuf2[3072];
/////////////////////////////////////////////////////////////////////////////
// DisrepairRecord dialog
DisrepairRecord::DisrepairRecord(CWnd* pParent /*=NULL*/)
: CDialog(DisrepairRecord::IDD, pParent)
{
//{{AFX_DATA_INIT(DisrepairRecord)
m_containerNo = _T("");
m_sealNo = _T("");
m_damageCondition = _T("");
m_remark = _T("");
objectId = _T("");
tallyListItemObjId = _T("");
damageCode = _T("");
propertyObjId = _T("");
modify = false;
//}}AFX_DATA_INIT
}
void DisrepairRecord::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(DisrepairRecord)
DDX_Control(pDX, IDC_COMBO1, m_damageCodeULDR);
DDX_Text(pDX, IDC_EDIT1, m_containerNo);
DDX_Text(pDX, IDC_EDIT2, m_sealNo);
DDX_Text(pDX, IDC_EDIT4, m_damageCondition);
DDX_Text(pDX, IDC_EDIT3, m_remark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(DisrepairRecord, CDialog)
//{{AFX_MSG_MAP(DisrepairRecord)
ON_BN_CLICKED(front1, OnButton201)
ON_BN_CLICKED(front2, OnButton202)
ON_BN_CLICKED(front3, OnButton203)
ON_BN_CLICKED(front4, OnButton204)
ON_BN_CLICKED(left1, OnButton211)
ON_BN_CLICKED(left2, OnButton212)
ON_BN_CLICKED(left3, OnButton213)
ON_BN_CLICKED(left4, OnButton214)
ON_BN_CLICKED(bottom1, OnButton221)
ON_BN_CLICKED(bottom2, OnButton222)
ON_BN_CLICKED(bottom3, OnButton223)
ON_BN_CLICKED(bottom4, OnButton224)
ON_BN_CLICKED(top1, OnButton231)
ON_BN_CLICKED(top2, OnButton232)
ON_BN_CLICKED(top3, OnButton233)
ON_BN_CLICKED(top4, OnButton234)
ON_BN_CLICKED(right1, OnButton241)
ON_BN_CLICKED(right2, OnButton242)
ON_BN_CLICKED(right3, OnButton243)
ON_BN_CLICKED(right4, OnButton244)
ON_BN_CLICKED(back1, OnButton251)
ON_BN_CLICKED(back2, OnButton252)
ON_BN_CLICKED(back3, OnButton253)
ON_BN_CLICKED(back4, OnButton254)
ON_WM_CANCELMODE()
ON_BN_CLICKED(IDC_BUTTON2, OnSave)
ON_BN_CLICKED(IDC_BUTTON3, OnClean)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
ON_BN_CLICKED(IDC_BUTTON6, OnCancel)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// DisrepairRecord message handlers
HRGN DisrepairRecord::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;
}
BOOL DisrepairRecord::OnInitDialog()
{
CDialog::OnInitDialog();
m_damageCodeULDR.SetCurSel(0);
CBitmap bmp11,bmp12,bmp13,bmp14,bmp21,bmp22,bmp23,bmp24,bmp31,bmp32,bmp33,bmp34,bmp41,bmp42,bmp43,bmp44,bmp51,bmp52,bmp53,bmp54,bmp61,bmp62,bmp63,bmp64;
HRGN hRgn11,hRgn12,hRgn13,hRgn14,hRgn21,hRgn22,hRgn23,hRgn24,hRgn31,hRgn32,hRgn33,hRgn34,hRgn41,hRgn42,hRgn43,hRgn44,hRgn51,hRgn52,hRgn53,hRgn54,hRgn61,hRgn62,hRgn63,hRgn64;
bmp11.LoadBitmap(IDB_FRONT_1);
hRgn11 = BitmapToRegion((HBITMAP)bmp11, RGB(0, 0, 0));
m_front_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(5,30), hRgn11, this, front1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_front_1.SetWindowRgn(hRgn11, TRUE);
bmp12.LoadBitmap(IDB_FRONT_2);
hRgn12 = BitmapToRegion((HBITMAP)bmp12, RGB(0, 0, 0));
m_front_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(25,30), hRgn12, this, front2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_front_2.SetWindowRgn(hRgn12, TRUE);
bmp13.LoadBitmap(IDB_FRONT_3);
hRgn13 = BitmapToRegion((HBITMAP)bmp13, RGB(0, 0, 0));
m_front_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(5,50), hRgn13, this, front3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_front_3.SetWindowRgn(hRgn13, TRUE);
bmp14.LoadBitmap(IDB_FRONT_4);
hRgn14 = BitmapToRegion((HBITMAP)bmp14, RGB(0, 0, 0));
m_front_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(25,50), hRgn14, this, front4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_front_4.SetWindowRgn(hRgn14, TRUE);
bmp21.LoadBitmap(IDB_LEFT_1);
hRgn21 = BitmapToRegion((HBITMAP)bmp21, RGB(0, 0, 0));
m_left_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(45,30), hRgn21, this, left1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_left_1.SetWindowRgn(hRgn21, TRUE);
bmp22.LoadBitmap(IDB_LEFT_2);
hRgn22 = BitmapToRegion((HBITMAP)bmp22, RGB(0, 0, 0));
m_left_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(64,46), hRgn22, this, left2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_left_2.SetWindowRgn(hRgn22, TRUE);
bmp23.LoadBitmap(IDB_LEFT_3);
hRgn23 = BitmapToRegion((HBITMAP)bmp23, RGB(0, 0, 0));
m_left_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(45,50), hRgn23, this, left3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_left_3.SetWindowRgn(hRgn23, TRUE);
bmp24.LoadBitmap(IDB_LEFT_4);
hRgn24 = BitmapToRegion((HBITMAP)bmp24, RGB(0, 0, 0));
m_left_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(64,66), hRgn24, this, left4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_left_4.SetWindowRgn(hRgn24, TRUE);
bmp31.LoadBitmap(IDB_BOTTOM_1);
hRgn31 = BitmapToRegion((HBITMAP)bmp31, RGB(0, 0, 0));
m_bottom_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(5,70), hRgn31, this, bottom1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_bottom_1.SetWindowRgn(hRgn31, TRUE);
bmp32.LoadBitmap(IDB_BOTTOM_2);
hRgn32 = BitmapToRegion((HBITMAP)bmp32, RGB(0, 0, 0));
m_bottom_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(25,70), hRgn32, this, bottom2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_bottom_2.SetWindowRgn(hRgn32, TRUE);
bmp33.LoadBitmap(IDB_BOTTOM_3);
hRgn33 = BitmapToRegion((HBITMAP)bmp33, RGB(0, 0, 0));
m_bottom_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(25,88), hRgn33, this, bottom3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_bottom_3.SetWindowRgn(hRgn33, TRUE);
bmp34.LoadBitmap(IDB_BOTTOM_4);
hRgn34 = BitmapToRegion((HBITMAP)bmp34, RGB(0, 0, 0));
m_bottom_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(45,88), hRgn34, this, bottom4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_bottom_4.SetWindowRgn(hRgn34, TRUE);
bmp41.LoadBitmap(IDB_TOP_1);
hRgn41 = BitmapToRegion((HBITMAP)bmp41, RGB(0, 0, 0));
m_top_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(150,30), hRgn41, this, top1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_top_1.SetWindowRgn(hRgn41, TRUE);
bmp42.LoadBitmap(IDB_TOP_2);
hRgn42 = BitmapToRegion((HBITMAP)bmp42, RGB(0, 0, 0));
m_top_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(170,30), hRgn42, this, top2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_top_2.SetWindowRgn(hRgn42, TRUE);
bmp43.LoadBitmap(IDB_TOP_3);
hRgn43 = BitmapToRegion((HBITMAP)bmp43, RGB(0, 0, 0));
m_top_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(128,50), hRgn43, this, top3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_top_3.SetWindowRgn(hRgn43, TRUE);
bmp44.LoadBitmap(IDB_TOP_4);
hRgn44 = BitmapToRegion((HBITMAP)bmp44, RGB(0, 0, 0));
m_top_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(148,50), hRgn44, this, top4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_top_4.SetWindowRgn(hRgn44, TRUE);
bmp51.LoadBitmap(IDB_RIGHT_1);
hRgn51 = BitmapToRegion((HBITMAP)bmp51, RGB(0, 0, 0));
m_right_1.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(168,52), hRgn51, this, right1,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_right_1.SetWindowRgn(hRgn51, TRUE);
bmp52.LoadBitmap(IDB_RIGHT_2);
hRgn52 = BitmapToRegion((HBITMAP)bmp52, RGB(0, 0, 0));
m_right_2.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(189,33), hRgn52, this, right2,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_right_2.SetWindowRgn(hRgn52, TRUE);
bmp53.LoadBitmap(IDB_RIGHT_3);
hRgn53 = BitmapToRegion((HBITMAP)bmp53, RGB(0, 0, 0));
m_right_3.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(168,72), hRgn53, this, right3,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_right_3.SetWindowRgn(hRgn53, TRUE);
bmp54.LoadBitmap(IDB_RIGHT_4);
hRgn54 = BitmapToRegion((HBITMAP)bmp54, RGB(0, 0, 0));
m_right_4.Create(_T(""), WS_CHILD | WS_VISIBLE, CPoint(189,55), hRgn53, this, right4,2, RGB(212, 208, 200), RGB(204,122,68), RGB(174, 174, 174), GetSysColor(COLOR_BTNFACE));
m_right_4.SetWindowRgn(hRgn54, TRUE);
bmp61.LoadBitmap(IDB_BACK_1);
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 DisrepairRecord::OnCancelMode()
{
CDialog::OnCancelMode();
// TODO: Add your message handler code here
}
void DisrepairRecord::OnButton201()
{
if (m_remark == _T("")){
m_remark = _T("前左上");
}else{
m_remark = m_remark + _T(",前左上");
}
UpdateData(FALSE);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -