thank u for ur fast reply
this works if the dialog is based on CDialog
but if the dialog is based on CBitmapDialog...it wont work(show)PROPERly...
what do u think i should do about it
????
it is reealy frustrating
so pleease can u help me with this?
here is the situation:
i have a dialog based application where the main dialog is not based on CDialog class ....it is based on a class called CBitmapDialog.
it works fine ....
now i inserted a new dialog (also based on CBitmapDialog)..
when i try to call the second dialog from the first (using a button)
the second dialog doesnt appear properly (alittile of the bitmap +alittle graybackgound)... it appears in a really BAD way and shape...
i tried to use the OnModal()....and showwindow()....but they led me to the same result....disfigured dialog
i hope u understand my problem
now
what can i do about that??
A dialog displayed with DoModal( ) shouldn't care what kind of parent dialog or window has displayed it.
So to determine if the problem is in the child dialog, try to start up the dialog from somewhare else. As good as place as any is CWinApp::InitInstance method. The code below is testing the dialog from a dialog app, but the app type doesn't matter. You can do the same from an SDI or MDI app.
Code:
BOOL CTestMFCApp::InitInstance()
{
CWinApp::InitInstance();
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
//
// Test your dialog here
//
CMyDialog dlg;
dlg.DoModal( );
// End of test
// Original code
CTestMFCDlg dlg;
m_pMainWnd = &dlg;
return FALSE;
}
If the dialog doesn't appear correctly, you know something is wrong with the dialog; if it does appear correctly, something is happening elsewhere.
ok
i tried ur way and the dialog appeared the same Bad shape ...although i did the same thing to the first but it works ...
what could be the difference between the two dialogs?
i initialize them in the same way..!!!
what do u think its wrong??
thank u
ok..thanks
first i had aproblem when inserting a new dialog and then create a new class for it ..espically in choosing the base class( i couldnot find the CBitmapDialog)...where in the first time i did create adialog based on it...
i dont know what goes wrong ... my head will explode soon
please could u show me the right way to do it ...and what might cause this..
and howcome the first one i created (a couple of days ago) could choose the base class but not now
what am i missing??
I downloaded the archive, unzipped it, compiled and:
I had have the same "error": The SecondDlg did appear with the bitmap
at a wrong place.
Then I tried to find out the difference(s) between the working first dlg
and the "wrong" second.
It seems to me that you did not make any error.
[b]But[(b]:
There seems to be an error in the MakeWindowRgn() function of the CBitmapDialog class. The implementation works only if the dialog is the main
app window and not a child dialog of another window.
I changed the implementation as follows (and it worked fine afterwards):
Code:
void CBitmapDialog :: MakeWindowRgn ()
{
if (!m_bTransparent)
{
// Set the window region to the full window
CRect rc;
GetWindowRect (rc);
CRgn rgn;
rgn.CreateRectRgn (0, 0, rc.Width(), rc.Height());
SetWindowRgn (rgn, TRUE);
}
else
{
// Set the region to the window rect minus the client rect
/*
CRect rcWnd;
GetWindowRect (rcWnd);
CRgn rgn;
rgn.CreateRectRgn (rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom);
CRect rcClient;
GetClientRect (rcClient);
ClientToScreen (rcClient);
CRgn rgnClient;
rgnClient.CreateRectRgn (rcClient.left, rcClient.top, rcClient.right,
rcClient.bottom);
// Subtract rgnClient from rgn
rgn.CombineRgn (&rgn, &rgnClient, RGN_XOR);
*/
CRect rcWnd;
GetClientRect (rcWnd);
CRect rcClient(rcWnd);
CRgn rgn,rgnClient;
rgn.CreateRectRgn (rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom);
rgnClient.CreateRectRgn (rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom);
rgn.CombineRgn (&rgn, &rgnClient, RGN_XOR);
// Get a DC for the bitmap
CDC dcImage;
dcImage.CreateCompatibleDC (NULL);
CBitmap *pOldBitmap = dcImage.SelectObject (m_bmBitmap);
// Get the bitmap for width and height information
BITMAP bm;
m_bmBitmap->GetBitmap (&bm);
// Get window width and height
CRect rc;
GetClientRect (rc);
// Use the minimum width and height
int width = min (bm.bmWidth, rc.Width());
int height = min (bm.bmHeight, rc.Height());
// Use RLE (run-length) style because it goes faster.
// 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;
// Go through all rows
for (int y=0; y<height; y++)
{
// Start looking at the beginning
row_start = 0;
// Go through all columns
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 line. 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 the last pixel is still opaque, make a region.
if (row_start != x)
{
CRgn rgnAdd;
rgnAdd.CreateRectRgn (rcClient.left+row_start, rcClient.top+y,
rcClient.left+x, rcClient.top+y+1);
rgn.CombineRgn (&rgn, &rgnAdd, RGN_OR);
}
}
SetWindowRgn (rgn, TRUE);
}
}
hi
thank u ProgramArtist ..... u were very helpful...the problem solved..
but i still have what i believe is my last problem:
now if insert a new dialog...and create a class for it ....when i come to the point where i choose the base class...i could not find CBitmapDialog among them....why?
I am certain that when i inserted the second dialog (a week ago)i chose CBitmapDialog...
howcome its different this time ....ohh what am i missing?
pleease help me with this ...its driving me crazy.
thank u for all ur help
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.