C++11. Not .net. Not VC++.
I can create a region with the following and pick parts of it to use as a custom shaped region for a DIALOG.
I am using a large graphic bmp that takes the following a long time to convert to a custom shaped region that I use for a custom shaped DIALOG.
My question is for the following
void createSomeRegion(HWND hwndDlg) {
hdcDestDC = GetDC(hwndDlg);
hdcMem_001 = CreateCompatibleDC(nullptr);
GetObject(hBitmap__001, sizeof(bmpInfo_001), &bmpInfo_001);
SelectObject(hdcMem_001, hBitmap__001);
hRgn_001 = CreateRectRgn(0,0,0,0);
COLORREF crTransparent = RGB(255, 255, 255);
int iX = 0;
int iY = 0;
int iRet = 0;
for ( iY = 0; iY < bmpInfo_001.bmHeight; iY++)
{
do
{
while (iX < bmpInfo_001.bmWidth && GetPixel(hdcMem_001, iX, iY) == crTransparent)
{
iX++;
}
int iLeftX = iX;
while (iX < bmpInfo_001.bmWidth && GetPixel(hdcMem_001, iX, iY) != crTransparent)
{
++iX;
}
HRGN hRgnTemp = CreateRectRgn(iLeftX, iY, iX, iY+1);
iRet = CombineRgn(hRgn_001, hRgn_001, hRgnTemp, RGN_OR);
if(iRet == ERROR)
{
return;
}
DeleteObject(hRgnTemp);
}
while(iX < bmpInfo_001.bmWidth);
iX = 0;
}
int x = 0;
int y = 4;
int i = OffsetRgn(hReusableRectangularRegion, (x*47)-x,(y*47)-y);
iRet = CombineRgn(hRgn_001, hRgn_001, hReusableRectangularRegion, RGN_AND);
iRet = SetWindowRgn(hwndDlg, hRgn_001, TRUE);
if(!iRet)
{
return;
}
iRet = SetWindowPos(hwndDlg, HWND_TOPMOST, 300, 300, bmpInfo_001.bmWidth, bmpInfo_001.bmHeight, 0);
paintRegion_001();
DeleteObject(hBitmap__001);
}
What I have tried:
C++11. Not .net. Not VC++.
I tried searching for a faster custom region creation but did not find that.
I tried testing the time that it takes for the large bitmap to be converted to a custom region and to be used for the modeless dialog, and it looks like about 10 to 15 seconds. That is too long.
I tried to figure out how to pre-process the custom region, but I am not clear how to do this.
I tried #void createSomeRegion(HWND hwndDlg), but that did not work.
I want to be able to process a large graphic (bmp) into a custom region, and have that already-processed region included in my final stand-alone executable, which I can use without having to go pixel by pixel when the exe runs.
I wandered through various wastelands of .net and VC++ starving for real C++ code.
Thanks for your help with C or up to C++11 answers.