CombineRgn - CreateRectRgn - SetWindowRgn
bonjour tout le monde,
j'aimerai que la forme de ma dialog prendre la forme de la photo qui se trouve dans picture control
voici mon code :
//declaration en haut :
// HRGN LineRegion,FullRegion;
// int x,y;
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| RECT rect1,rect2;
BOOL InFirstRegion = TRUE, InLine = FALSE;
m_picture.GetWindowRect(&rect1);
AfxGetMainWnd()->GetWindowRect(&rect2);
rect2.left = rect1.left;
rect2.top = rect1.top;
HDC hdc = m_picture.GetDC()->GetSafeHdc();
int StartLineX = 0;
//////////////////////////////
/////////////////////////////
//partie de faire transparence
////////////////////////////
///////////////////////////
for(y=0;y<rect1.bottom;y++)// for 1
{
for(x=0;x<rect1.right;x++) // for 2
{
if(GetPixel(hdc,x,y) == RGB(255,0,255))
{
if(InLine)
{
InLine = FALSE;
LineRegion = CreateRectRgn(StartLineX,y,x,y+1);
if(InFirstRegion)
{
FullRegion = LineRegion;
InFirstRegion = FALSE;
}
else
{
CombineRgn(FullRegion,FullRegion,LineRegion,RGN_OR);
DeleteObject(LineRegion);
}
}
}
else
{
if(!InLine)
{
InLine = TRUE;
StartLineX = x;
}
}
}//fin for 2
}//fin for 1
SetWindowRgn(FullRegion,TRUE); |
//m_picture est le nom variable de picture control;
bizzarement il se passe rien !!
sous VB6 ce code marche tres bien, je pense que j'ai rate quelque chose, quelqu'un a une idée ?
j'ai trouve cette source :
http://www.codeproject.com/KB/dialog...?display=Print
mais le code est long tres tres long 8O , 60000 classes pour faire un truc simple qui marche facilement sous VB :/