|
I have been trying to use FlashWindow and FlashWindowEx in an attempt to mimic the flash that occurs in SPY++ when you right click on a window and choose "highlight". Specifically, I'm trying to do this with the MainFrame for an MFC Doc/View app.
Windows 2000
Platform SDK installed and paths set
Visual C++ 6.0 and Visual C++ 2003
No compile or link errors
When I run FlashWindowEx from a CMainFrame method it works (flashes the child view) when using a child window handle but when I use the main frame handle it only blinks the task manager button. The application is not minimized or iconic during testing.
CWnd* pWnd=GetWindow(GW_CHILD);
if (pWnd) {
FLASHWINFO flashInfo={0};
flashInfo.cbSize=sizeof(FLASHWINFO);
flashInfo.hwnd=pWnd->m_hWnd;
flashInfo.uCount=3;
flashInfo.dwTimeout=75;
flashInfo.dwFlags=FLASHW_ALL;
::FlashWindowEx(&flashInfo); // Flashes the child fine
}
//*****************************
FLASHWINFO flashInfo={0};
flashInfo.cbSize=sizeof(FLASHWINFO);
flashInfo.hwnd=this->m_hWnd;
flashInfo.uCount=3;
flashInfo.dwTimeout=75;
flashInfo.dwFlags=FLASHW_ALL;
::FlashWindowEx(&flashInfo); // Only flashes the task manager button
//*****************************
Any ideas on what I'm missing or doing wrong?
-- modified at 17:01 Wednesday 15th August, 2007
|
|
|
|
|
Have you tried to get your MainWindow with:
AfxGetApp()->m_pMainWnd;
and then do the same as you were doing?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
|
|
|
|
|
I was running it from CMainFrame.
I may be wrong, but aren't those two the same?
Just for grins, I tried m_pMainWnd but it just flashes the button in the task manager.
Did you get it to work on your machine or are you taking a shot in the dark? If you got it to work on your box, I'll keep at as I'm probably missing something right under my nose (again).
Either way, thanks for the suggestion.
|
|
|
|
|
I am trying to get a bitmap to load into a static picture control.
The class definition contains the following variables:
class CGraphTestDlg : public CDialog
...........
CBitmap ONELogo;
CStatic m_onelogo; //this is attached to a picture control
CGraphTestDlg::OnInitDialog() does the following:
.....
ONELogo.LoadBitmap(IDB_BITMAP1);
m_onelogo.SetBitmap(ONELogo);
This is pretty much right out of a microsoft example of how load a bitmap but the picture is never displayed. What am I doing wrong?
Wayne King
|
|
|
|
|
WayneK100 wrote: What am I doing wrong?
Have you seen this or this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I got the bitmap to load shortly after I posted the question (of course) but the image is way to big for the area that I want to put it in. Is there a way to resize it (at run time) to fit within the control's defined area?
Wayne
|
|
|
|
|
WayneK100 wrote: Is there a way to resize it (at run time) to fit within the control's defined area?
Something like this should work...
CBitmap SrcBmp;
SrcBmp.LoadBitmap(IDB_BITMAP1);
BITMAP BmpInfo;
SrcBmp.GetBitmap(&BmpInfo);
CRect DestRect;
m_onelogo.GetClientRect(&DestRect);
double XScale = (double)DestRect.Width() / (double)BmpInfo.bmWidth;
double YScale = (double)DestRect.Height() / (double)(BmpInfo.bmHeight;
double ScaleFactor = XScale < YScale ? XScale : YScale;
int nNewBMWidth = (int)((double)BmpInfo.bmWidth * ScaleFactor);
int nNewBMHeight = (int)((double)BmpInfo.bmHeight * ScaleFactor);
CDC SrcDC;
SrcDC.CreateCompatibleDC(NULL);
CBitmap *pOldBmp1 = SrcDC.SelectObject(&SrcBmp);
ONELogo.CreateCompatibleBitmap(&SrcDC, nNewBMWidth, nNewBMHeight);
CDC DestDC;
DestDC.CreateCompatibleDC(NULL);
CBitmap *pOldBmp2 = DestDC.SelectObject(&ONELogo);
DestDC.StretchBlt(0, 0, nNewBMWidth, nNewBMHeight, &SrcDC, 0, 0, BmpInfo.bmWidth, BmpInfo.bmHeight, SRCCOPY);
SrcDC.SelectObject(pOldBmp1);
DestDC.SelectObject(pOldBmp2);
m_onelogo.SetBitmap(ONELogo); Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks once again. All the help got us through the hard-to-find details and get this project finished.
Thanks
Wayne
|
|
|
|
|
Which is the best and sure way to detect that the DLL file is a COM DLL file or it is a regular DLL file?
-- modified at 13:42 Wednesday 15th August, 2007
|
|
|
|
|
Try and register the dll using Regsvr32. If it is a com dll you would get a success message saying the dll is registered successfully. If it is not a com dll it would give you and error message saying that the entry point DllRegisterServer was not found, which means that the dll is not a com dll.
"What's on your mind, if you will allow the overstatement?"
|
|
|
|
|
Thanks,
I suppose that I could use GetProcAddress for DllRegisterServer and DllUnregisterServer
|
|
|
|
|
Hi all,
I am working on a dialog-based MFC application, which consists of multiple property pages. From one of the property pages, I am trying to launch a dialog box which contains an ActiveX control.
This is currently not working and the application exits with an access violation error when I call DoModal for the dialog. On debugging, I see this is due to AfxGetThread() returning NULL in AfxOleInit(). This does not happen if I launch the dialog-box from the application's InitInstance() function instead of a property page or if I add the control to the property page itself. I have made sure that the control is registered and that I call AfxEnableControlContainer() from the application's InitInstance() function.
I am using Visual Studio C++ .NET.
Is there something else that I have missed? Any help is greatly appreciated.
Thanks,
Priya
-- modified at 6:46 Thursday 16th August, 2007
|
|
|
|
|
Is OLE as applicable as of now in terms of its support and are there others technologies that do an exact override of the functionality in OLE.
|
|
|
|
|
tom groezer wrote: Is OLE as applicable as of now in terms of its support
Huh? You mean COM? COM is heavily used in Windows systems.
tom groezer wrote: an exact override
You mean different but with "similar" features. What would be the point of being different but exactly the same?
|
|
|
|
|
I've seen some codes using delete[] blah; and someone else delete blah; .
I didn't read in any book how to use them and what's difference. It's a couple of years that I'm programming and using just delete. Does any one know what is the difference and when we need to use those brackets?
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: delete[] blah; delete blah; .
what's difference
Simple: If the memory was new ed with [] , use delete[] , otherwise normal delete.
delete[] calls the destructors of the elements of the array before freeig the memory, whereas delete does not.
You might get away with using the wrong one, until you are really under pressure. Then the whole sh*t will explode in your face.
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
What a big memory leak in some of my applications.
Thank you.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: What a big memory leak in some of my applications.
Not necessarily[^] if you were using VC++, at least according to Stan Lippman.
But in general, this leads to undefined behavior and should be avoided.
|
|
|
|
|
I was wondering why I didn't notice this type of memory leak reports already. I'm mostly very careful about it. I used vld dll for a while.
So it is possible that this does not result in a memory leak in VC++, but worse than that, it might lead to an unknown behavior. Why VC++ compiler doesn't generate a warning? or perhaps it does in level4?(I often use the default level3)
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Hamed Mosavi wrote: but worse than that, it might lead to an unknown behavior
No, my understanding is that with VC++ it works fine either way (haven't tried it though ). However, the C++ Standard says that such a case leads to undefined behavior which means that with other compilers (or a new version of VC++) you may see just about anything at all: leaks, crashes, destructors not being called - you name it.
|
|
|
|
|
Thanks.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
Wow - four letter words get automagically beeped here.
I did write a 'i' instead of a '*" in the post above.
-- modified at 11:46 Wednesday 15th August, 2007
Being too soapboxy
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Hamed Mosavi wrote: I didn't read in any book how to use them and what's difference.
Why not?[^]
|
|
|
|
|
Thanks.
// "Life is very short and is very fragile also." Yanni while (I'm_alive) { cout<<"I love programming."; }
|
|
|
|
|
you must call delete [] if you have an array of objects.
if you leave out the [] the destructor only is called for the first object of the list.
So, to be sure not to get resource/memory leak you have to use [] for arrays.
|
|
|
|