Originally posted by: MartinS
Look down the posts at:
Solution for Child Dialogs..
It worked for me.
Good luck,
Martin
Reply
Originally posted by: JC
SetTransparent(true);
in my OnInitDialog method the entire dialog is not shown. Its invisible. If I don't set transparent then the entire bitmap is shown. Which is the what's supposed to happen if SetTransparent is false;
The funny thing is if I build a new project in Visual 6 and then translate it up to visual 7 it works fine. Its only when I create my derived class in visual 7 I get the above problem. I know its probably something very small and trivial... Like having a wrong property set... If anyone has some insight to this I'd most obliged.
Thanks all,
Hi,
I've been trying to get this class to work in visual 7. When I do
JC
Originally posted by: Eibi
Please advise
ReplyOriginally posted by: RAJAN
Thanks
ReplyOriginally posted by: Kevin Smith
This is great! but it's too SLOW, it takes like 2 secs for the dialog to load, then is too long for my users.
ReplyOriginally posted by: Jun Yang
Where are my ICON and SysMenu when minimum?
If anyone have ideas about those,tell me please!Thanks
ReplyOriginally posted by: Peter
Thanks In Advance.
Can somebody tell me if i can use the CBitmapDialog Class
in my project?I am not trying to publish the code.I am just
trying to make use of the code in the project which I am
working right now?
Originally posted by: Jeune Prime Origines
Pls. see the inserted codes in the CBitmapDialog ::MakeWindowRgn () function:
// The client Rect
// Since the coordinates are with respect to the screen
//================================
rcClient.bottom -= rcWnd.top;
//================================
rcWnd.bottom -= rcWnd.top;
CRgn rgn;
CRgn rgnClient;
// Subtract rgnClient from rgn
// Get a DC for the bitmap
// Get the bitmap for width and height information
// Get window width and height
// Use the minimum width and height
// Use RLE (run-length) style because it goes faster.
// Go through all rows
// Go through all columns
// If the last pixel is still opaque, make a region.
rgn.CombineRgn (&rgn, &rgnAdd, RGN_OR);
dcImage.SelectObject(pOldBitmap);
//Set the region
I found a solution to make the CBitmapDialog class work even in child dialog.
void CBitmapDialog ::MakeWindowRgn ()
{
if (!m_bTransparent || m_bmBitmap == NULL)
{
// Set the window region to the full window
CRect rcWnd;
GetWindowRect (rcWnd);
CRgn rgn;
rgn.CreateRectRgn (0, 0, rcWnd.Width(), rcWnd.Height());
SetWindowRgn (rgn, TRUE);
}
else
{
//The whole window rect
CRect rcWnd;
GetWindowRect (rcWnd);
CRect rcClient;
GetClientRect (rcClient);
ClientToScreen (rcClient);
// Let's make the upper-left of the whole window to (0,0)
// This is the solution to the problem of the of the orig code
// By: Prime :)
//Adjust the Client Rect
//================================
rcClient.right -= rcWnd.left;
rcClient.left -= rcWnd.left;
rcClient.top -= rcWnd.top;
//Adjust the Whole Window Rect
//================================
rcWnd.right -= rcWnd.left;
rcWnd.left -= rcWnd.left;
rcWnd.top -= rcWnd.top;
//==============================
rgn.CreateRectRgn (rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom);
rgnClient.CreateRectRgn (rcClient.left, rcClient.top, rcClient.right,rcClient.bottom);
rgn.CombineRgn (&rgn, &rgnClient, RGN_XOR);
CDC dcImage;
dcImage.CreateCompatibleDC (NULL);
CBitmap *pOldBitmap = dcImage.SelectObject (m_bmBitmap);
BITMAP bm;
m_bmBitmap->GetBitmap (&bm);
int width = min (bm.bmWidth, rcClient.Width());
int height = min (bm.bmHeight, rcClient.Height());
// Row start is where the first opaque pixel is found. Once
// a transparent pixel is found, a line region is created.
// Then row_start becomes the next opaque pixel.
int row_start;
for (int y=0; y<height; y++)
{
// Start looking at the beginning
row_start = 0;
for (int x=0; x<width; x++)
{
// If this pixel is transparent
if (dcImage.GetPixel(x, y) == m_colTrans)
{
// If we haven't found an opaque pixel yet, keep searching
if (row_start == x) row_start ++;
else
{
// We have found the start (row_start) and end (x) of
// an opaque strip. Add it to the region.
CRgn rgnAdd;
rgnAdd.CreateRectRgn (rcClient.left+row_start,
rcClient.top+y, rcClient.left+x, rcClient.top+y+1);
rgn.CombineRgn (&rgn, &rgnAdd, RGN_OR);
row_start = x+1;
}
}
}
if (row_start != x)
{
//Create a region of the remaining strip. (if any)
CRgn rgnAdd;
rgnAdd.CreateRectRgn (rcClient.left+row_start, rcClient.top+y,
rcClient.left+x, rcClient.top+y+1);
}
}
dcImage.DeleteDC();
SetWindowRgn (rgn, TRUE);
}
}
Originally posted by: Vali
Really nice work. I wanted to know what the strategy would be if you have a bitmap that you want to use as an outershell (irregular shape) for a dialog and allow the dialog to be resized. for example, consider how Windows Media Player uses an irregular shape window (in skin mode) but still allows the user to resize the window?
Thanks,
Vali
Originally posted by: Phil M.
Hi,
I've tried this class on the main dialog and it works perfectly. However, as a rookie to VC++, I am not sure how to make it work with the About Dialog Box as well? I've tried but it just did not work! All help and tips are appreciated. Thanks in advance!