 |
|
 |
For anyone trying to open and run this, you will have an error with iY not being defined. It is, but in the for loop just above it's first use outside of it. It's declared locally to the for loop; just initialize it right under iX. Is: //Create a region from a bitmap with transparency colour of Purple COLORREF crTransparent = TRANSPARENTCOLOR; int iX = 0; for (int iY = 0; iY < m_Bitmap.bmHeight; iY++) Fix: COLORREF crTransparent = TRANSPARENTCOLOR; int iX, iY; iX = 0; for (iY = 0; iY < m_Bitmap.bmHeight; iY++); iY < m_Bitmap.bmHeight; iY++) Joel Brockman Software Engineer Marine Sonic Technology, LTD.
|
|
|
|
 |
|
 |
how to place buttons ? when i place a new button on dilog it does not appears
|
|
|
|
 |
|
 |
this is a very nice way to implement transparency! Thanks for the code.
I just have a question about the way you auto close the application. You used PostQuitMessage(0). AFAIK, PostQuitMessage will post WM_Quit and terminate application.However, I read somewhere that using PostQuitMessage only may leave memory leak.
Someone recommend using PostMessage(WM_Close) on main window. It will call DestroyWindow(). The DestroyWindow will destroy all windows and then call PostQuitMessage.
Do you think PostQuitMessage(0) is the better way to auto close a window? TIA.
|
|
|
|
 |
|
 |
hi,
i was unaware of that issue. It needs to be tested i suppose to prove the leak. but the way you suggest is fine I suppose.
nicw
|
|
|
|
 |
|
 |
its wonderful sir...i m new to development.and i m very much interested in MFC.can u give me any links or articles...i'll be thankful to u sir....
|
|
|
|
 |
|
 |
There are many good books on MFC the eaisest to follow would be the "Osborne" "The Complete Reference" series they have some books on Visual C++ which have some good MFC examples. I use the MSDN library articles quite a lot, just looking at each MFC class and them implementing the ones I want or need.
nicw
MSN nicwilson@hotmail.com
|
|
|
|
 |
|
 |
Thanks.
I'm looking for a splash implementation that is similar to that of Photoshop.
The main function I need is to change the text on the splash is changeable at runtime.
After a while, I realized that a correct way to this is an implementation based on a dialog.
It's what I need.
One question here:
I'm using it in a Doc/View program instead of a dialog program, so I don't want the program
to exit, as the demo program, on the timer message, but just close the transparent dialog,
I change the code in CTransparentDialogDlg::OnTimer(UINT nIDEvent) from
KillTimer(1);
PostQuitMessage(0);
CDialog::OnTimer(nIDEvent);
to
KillTimer(1);
OnClose();
CDialog::OnTimer(nIDEvent);
but the splash just don't close as anticipated. Why?
Thanks again.
max
|
|
|
|
 |
|
 |
Ok, I solved this by replacing
OnClose();
with
PostMessage(WM_CLOSE);
Max
|
|
|
|
 |
|
 |
As a step further, how can I keep showing the splash and, meanwhile, do the
data initializing and updating a progress bar on the splash dialog?
Thanks for any hints from anybody.
Max
|
|
|
|
 |
|
 |
Hi,
while I am running the application I am getting a message box "Error loading Bitmap".
what shd I do to solve this..???
|
|
|
|
 |
|
 |
The app looks in the same directory (folder) that the .exe file is started in. The author put the image.bmp file in the Release dir, so if you set run the project in release mode, it will find it. If you want to run in debug mode, copy image.bmp into the Debug dir.
|
|
|
|
 |
|
 |
I tried to use it with ws_child, but it didn't work, is it possible? can u give me a simple sample code? thanks,
give a hand,have a heart
|
|
|
|
 |
|
 |
I have a problem like this.i have hooked
WM_CREATE message and whenewer application window is created
i just takes it HWND and passes user Defined message to another application that application handles userdefined message(This application is also my application).In that message handlers i have kept delay of 100 ms and capture the image and then hide it.
That is work but when i hide window in WM_CREATE hook procedure then pass Userdefined message to my application then it can`t be captured insted it capures only active window`s GUI of Size of my hiden application window.
I think that to capture any window it is requred to be visible.
but is it possible that by copying memory content of Windows Gui we can also capture the image of window ?
|
|
|
|
 |
|
 |
I tried to move my transparent window modifying iX e iY values in the demo, but the window is always centered, why?
//iX = (GetSystemMetrics(SM_CXSCREEN)) / 2 - (m_Bitmap.bmWidth / 2);
//iY = (GetSystemMetrics(SM_CYSCREEN)) / 2 - (m_Bitmap.bmHeight / 2);
iX=800;
iY=400;
SetWindowPos(&wndTopMost,iX, iY, m_Bitmap.bmWidth, m_Bitmap.bmHeight, NULL);
PS: i was able to move the window using:
SetWindowPos(&wndTopMost,iX,iY,m_Bitmap.bmWidth,m_Bitmap.bmHeight, SWP_SHOWWINDOW) ;
but, in this way, i lose my bitmap, and i have only a gray mask of the window
|
|
|
|
 |
|
 |
Not transparent, but i like it...
void CMyDialogClass::OnPaint()
{
CPaintDC dc(this); // device context for painting
PaintDesktop(dc); // Desktop wallpaper background
}
|
|
|
|
 |
|
|
 |
|
 |
I'm learning VC++ so, I might sound lil stupid but is it possible to have a bmp file with single color and then make it transparent so the dialog box not at all appears on the screen and you see the desktop through dialog?
|
|
|
|
 |
|
 |
Can you add the image.bmp to the zip?
|
|
|
|
 |
|
 |
It is provided look again. After unzipping you will find it in the "Release" directory.
Nic
|
|
|
|
 |
|
 |
It's a nice way to easily generate resource files for transparent dialog applications! Here is some code to perform serialization: void Serialize(CArchive& ar, CRgn* pRgn) { if( ar.IsStoring() ) { // store window region int nCount = pRgn->GetRegionData(NULL, 1); if( nCount>0 ) { LPBYTE pbuffer = new BYTE[nCount]; memset(pbuffer, 0, nCount); int nRet = pRgn->GetRegionData((LPRGNDATA)pbuffer, nCount); ar << nCount; ar.Write(pbuffer, nCount); delete[] pbuffer; } } else { // load and create window region int nCount = 0; ar >> nCount; LPBYTE pbuffer = new BYTE[nCount]; memset(pbuffer, 0, nCount); ar.Read(pbuffer, nCount); if( pRgn->m_hObject ) pRgn->DeleteObject(); pRgn->CreateFromData(NULL, nCount, (LPRGNDATA)pbuffer); delete[] pbuffer; } }
--- Manolis from Crete ---
|
|
|
|
 |
|
 |
can you please post the complete code?
How can i serialize this RGN to a file?
|
|
|
|
 |
|
 |
Add the following functions in the header file of the dialog:
void SaveData(CRgn* pRgn);
BOOL LoadData(CRgn* pRgn);
void Serialize(CArchive& ar, CRgn* pRgn);
The implementation is:
void CTransparentDialogDlg::Serialize(CArchive& ar, CRgn* pRgn)
{
if( ar.IsStoring() )
{
// storing code
int nCount = pRgn->GetRegionData(NULL, 1);
if( nCount>0 )
{
LPBYTE pbuffer = new BYTE[nCount];
memset(pbuffer, 0, nCount);
int nRet = pRgn->GetRegionData((LPRGNDATA)pbuffer, nCount);
switch( nRet )
{
case COMPLEXREGION:
TRACE("New region has overlapping borders.\n");
break;
case ERROR:
TRACE("No new region created.\n");
break;
case NULLREGION:
TRACE("New region is empty.\n");
break;
case SIMPLEREGION:
TRACE("New region has no overlapping borders.\n");
break;
}
ar << nCount;
ar.Write(pbuffer, nCount);
delete[] pbuffer;
}
}
else
{
// loading code
int nCount = 0;
ar >> nCount;
LPBYTE pbuffer = new BYTE[nCount];
memset(pbuffer, 0, nCount);
ar.Read(pbuffer, nCount);
if( pRgn->m_hObject )
pRgn->DeleteObject();
pRgn->CreateFromData(NULL, nCount, (LPRGNDATA)pbuffer);
delete[] pbuffer;
}
}
void CTransparentDialogDlg::SaveData(CRgn* pRgn)
{
CFile ff;
CFileException e;
if( ff.Open("MyRgn.set", CFile::modeCreate | CFile::modeWrite | CFile::shareExclusive, &e) )
{
CArchive ar(&ff, CArchive::store, 4096, NULL);
try
{
Serialize( ar, pRgn );
}
catch(CFileException* e)
{
e->ReportError();
e->Delete();
}
ar.Close();
ff.Close();
}
}
BOOL CTransparentDialogDlg::LoadData(CRgn* pRgn)
{
CFile ff;
CFileException e;
if( ff.Open("MyRgn.set", CFile::modeRead, &e) )
{
CArchive ar(&ff, CArchive::load, 4096, NULL);
try
{
Serialize( ar, pRgn );
}
catch(CFileException* e)
{
e->ReportError();
e->Delete();
}
ar.Close();
ff.Close();
return TRUE;
}
return FALSE;
}
Call LoadData inside the OnInitDialog and SaveData before you close the dialog.
good luck.
Manolis from Crete
|
|
|
|
 |
|
 |
can you do it without MFC (say, Win32 API). Anyways well done.
RJS
|
|
|
|
 |