GregR wrote:The code looks right, but I'm not sure that the math is correct. Perhaps there is something else going on before or afterwards that is not working properly. For example, I do not know what m_Image is, as well as Please send me a simple working project that is causing this problem for you so I can look at it in context.
You can attach screenshots as well, but you can only post a .zip file to our forum, and that is why you have been getting errors. When I have these I'll understand better what is going on elsewhere in your code and what you are hoping to acheive.
================================================
Hi, Greg!
I send a snippet with full function description. And description of class CUserBitmapWin . Because I use the variable of this type in function void CRegionDlg::OnSetTwoReg().
class CRegionDlg : public CDialog
{
// Construction
public:
CUserBitmapWin m_Image;
}
void CRegionDlg::OnSetTwoReg()
{
RECT rClnA;
GetDlgItem(IDC_RGNFRM)->GetClientRect(&rClnA);
POINT points1[3];
POINT *pPoints1 = points1;
points1[0].x = rClnA.left;
points1[0].y = rClnA.bottom;
points1[1].x = rClnA.right;
points1[1].y = (rClnA.bottom + rClnA.top)/2;
points1[2].x = rClnA.left;
points1[2].y = rClnA.top;
//create array of points for a square region
POINT points2[4];
POINT L_FAR *pPoints2 = points2;
points2[0].x = rClnA.right;
points2[0].y = rClnA.bottom;
points2[1].x = (rClnA.right - rClnA.left)/3 +rClnA.left;
points2[1].y = rClnA.bottom;
points2[2].x = (rClnA.right - rClnA.left)/3+rClnA.left;
points2[2].y = rClnA.top;
points2[3].x = rClnA.right;
points2[3].y = rClnA.top;
//Set the combine mode and create the regions
// m_Image.Region()->SetRgnCombineMode(L_RGN_SET);
m_Image.Region()->SetRgnCombineMode(L_RGN_AND);
m_Image.Region()->SetRgnPolygon(pPoints1,3,L_POLY_WINDING);
m_Image.Region()->SetRgnPolygon(pPoints2,4,L_POLY_WINDING);
}
================================================
class CUserBitmapWin : public LBitmapWindow
{
public:
CProgressCtrl* Progress;
HWND hWinWnd;
CMsgData m_msd;
int StatusCallBack (int nPercentComplete);
LRESULT MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
CUserBitmapWin();
virtual ~CUserBitmapWin();
};
================================================
#include "stdafx.h"
#include "UserBitmapWin.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CUserBitmapWin::CUserBitmapWin()
{
Progress = NULL;
hWinWnd = NULL;
}
CUserBitmapWin::~CUserBitmapWin()
{
}
int CUserBitmapWin::StatusCallBack (int nPercentComplete)
{
if (!Progress) return FAILURE;
Progress->SetPos(nPercentComplete);
return SUCCESS;
}
LRESULT CUserBitmapWin::MsgProcCallBack(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
COPYDATASTRUCT cd;
m_msd.Msg = uMsg;
m_msd.LParam = lParam;
m_msd.WParam = wParam;
cd.lpData = &m_msd;
cd.cbData = sizeof(m_msd);
if (!hWinWnd) return NULL;
if ( uMsg == WM_LBUTTONUP || uMsg == WM_LBUTTONDOWN || uMsg == WM_MOUSEMOVE)
SendMessage(hWinWnd,WM_COPYDATA,0, (LPARAM) &cd);
return LBitmapWindow::MsgProcCallBack(hWnd,uMsg, wParam ,lParam);
}
Sincerely, Vadim