DrawPicture is drawing picture
Do the project of remote monitoring of the service side
bool CMainDlg: : CreatPicture (const int ip_array_subscript, const int iphone, const int iptwo, const int ipthree, const int ipfour, const char * buf)
{
//using namespace STD.
STD: : string ip_address;
Char c1 [20], [20] serie c2 and c3 [20], c4 [20].
The RECT rec.
Int return1 return2;
_itoa (iphone, c1, 10);
_itoa (iptwo, c2, 10);
_itoa (ipthree, c3, 10);
_itoa (ipfour, c4, 10);
Ip_address +=c1;
Ip_address +=". ";
Ip_address +=c2.
Ip_address +=". ";
Ip_address +=c3;
Ip_address +=". ";
Ip_address +=c4.
Rec=GetPictureCoordinate (ip_array_subscript);
//GlobalAlloc is a Windows API function, the function from the global heap allocated in a certain number of bytes
//if the function call is successful, it returns a handle to the newly allocated memory object,
HGLOBAL HGLOBAL=GlobalAlloc (GMEM_MOVEABLE, 4096);
//lock memory specified memory block, and return a address values, make it points to the memory block at beginning
Void * pData=https://bbs.csdn.net/topics/GlobalLock (hGlobal);
//memory copy
Memcpy (pData, buf, 4096);
GlobalUnlock (hGlobal);
Cost * pStream=NULL;
//CreateStreamOnHGlobal function from the specified memory to create stream objects,
If (CreateStreamOnHGlobal (hGlobal, TRUE, & amp; PStream)==S_OK)
{
CImage image;
If (SUCCEEDED (image. The Load (pStream)))
{
//to avoid to read for the object's memory
If (pPictureControl [ip_array_subscript] m_hWnd==0)
{
//if failed to create a picture box, it returns 0
Return1=pPictureControl [ip_array_subscript]. The Create (_T (" "), WS_CHILD | WS_VISIBLE | SS_BITMAP, rec, this, ip_array_subscript);
If (return1==0)
{
Array [ip_array_subscript]=iphone;
Array [ip_array_subscript + 1]=iptwo;
Array [ip_array_subscript + 2]=ipthree;
Array [ip_array_subscript + 3]=ipfour;
PStream - & gt; Release ();
GlobalFree (hGlobal);
Image. Detach ();
return 0;
}
}
The else
{
Return2=(int) (pPictureControl [ip_array_subscript] SetBitmap (image));
}
//CStatic * PIC=(CStatic *) GetDlgItem (IDC_PIC);
//PIC - & gt; SetBitmap (image);
}
PStream - & gt; Release ();
Image. Detach ();
}
GlobalFree (hGlobal);
If (return1!=0 & amp; & Return2!=NULL)
{
return 1;
}
}
Bool CMainDlg: : DrawPicture (const int ip_array_subscript, const int iphone, const int iptwo, const int ipthree, const int ipfour, const char * buf)
{
//using namespace STD.
STD: : string ip_address;
Int return1;
Char c1 [20], [20] serie c2 and c3 [20], c4 [20].
The RECT rec.
_itoa (iphone, c1, 10);
_itoa (iptwo, c2, 10);
_itoa (ipthree, c3, 10);
_itoa (ipfour, c4, 10);
Ip_address +=c1;
Ip_address +=". ";
Ip_address +=c2.
Ip_address +=". ";
Ip_address +=c3;
Ip_address +=". ";
Ip_address +=c4.
Rec=GetPictureCoordinate (ip_array_subscript);
//GlobalAlloc is a Windows API function, the function from the global heap allocated in a certain number of bytes
//if the function call is successful, it returns a handle to the newly allocated memory object,
HGLOBAL HGLOBAL=GlobalAlloc (GMEM_MOVEABLE, 4096);
//lock memory specified memory block, and return a address values, make it points to the memory block at beginning
Void * pData=https://bbs.csdn.net/topics/GlobalLock (hGlobal);
//memory copy
Memcpy (pData, buf, 4096);
GlobalUnlock (hGlobal);
Cost * pStream=NULL;
//CreateStreamOnHGlobal function from the specified memory to create stream objects,
If (CreateStreamOnHGlobal (hGlobal, TRUE, & amp; PStream)==S_OK)
{
CImage image;
If (SUCCEEDED (image. The Load (pStream)))
{
If (pPictureControl [ip_array_subscript] m_hWnd!=0)
{
Return1=(int) (pPictureControl [ip_array_subscript] SetBitmap (image));
}
}
PStream - & gt; Release ();
Image. Detach ();
}
GlobalFree (hGlobal);
If (return1!=NULL)
{
return 1;
}
return 0;
}
CodePudding user response:
return 0; Can lead to resource leaksCodePudding user response:
Comments part of the code, the best way to increase tip text output TRACE, see which part is stuck,CodePudding user response: