Actually, as an update to this, I'm having some slight issues now after slightly over a week.
First, I'm using a series of timers to decide when to redraw the window, I only target IE windows opened with a specific name, once one is open, I issue an invalidate and update once, and then again 2 seconds later. Then I go into another timer waiting for that window to close, when it closes, it triggers a timer waiting for another one to open again, thus, essentially, every time a window loads with that title, I get two screen refreshes which fixes my problem.
Unfortunately, there's a few issues, the InvalidateRect and UpdateWindow cause the screen to briefly flicker, and that was undesirable, hence going from constantly doing it on one timer, to my multiple timers. If I could find a way to redraw the window without the flicker that'd be great, but that's not the largest issue.
The largest issue is Java, for some reason, when Java locks up, it locks my timers, and my program refuses to work from that point onward, and the windows go back to displaying their normal graphical glitch. I'm using WM_Timer messages, and was wondering if that may be causing the problem, and if so, what alternatives I should consider.
Here's a copy of my code for those interested in helping.
And here's a code tag with the related sections
Code:
BOOL CMarineFixDlg::OnInitDialog(){
SetTimer(1,200, NULL); // Set Timer for IE window to open
return TRUE;
}
void CMarineFixDlg::OnTimer(UINT nIDEvent){
if((nIDEvent==1) && bd_CheckMarine()){ // Timer to for IE window to open
SetTimer(2,3000, NULL);
KillTimer(nIDEvent);
}
if(nIDEvent==2) { // Timer to redraw IE window
if(bd_CheckMarine())
SetTimer(4,2000,NULL);
else
SetTimer(1,200,NULL); // Timer to wait for window to open
::InvalidateRect(NULL,NULL,FALSE);
::UpdateWindow(NULL);
KillTimer(nIDEvent);
}
if((nIDEvent==3) && !bd_CheckMarine()){ // Timer to wait for IE window to close
SetTimer(1,200,NULL); // Timer to wait for window to open
KillTimer(nIDEvent);
}
if(nIDEvent==4) { // Timer to redraw IE window a second time
if(bd_CheckMarine())
SetTimer(3,200,NULL);
else
SetTimer(1,200,NULL); // Timer to wait for window to open
::InvalidateRect(NULL,NULL,FALSE);
::UpdateWindow(NULL);
KillTimer(nIDEvent);
}
}
bool CMarineFixDlg::bd_CheckMarine(){
HWND hIE = ::FindWindow(0,"US Marine Corps Museum - Windows Internet Explorer");
HWND hIE2 = ::FindWindow(0,"US Marine Corps Museum - Mozilla Firefox");
if(hIE || hIE2)
return true;
else
return false;
}
Code:
// MarineFixDlg.h : header file
#pragma once
class CMarineFixDlg : public CDialog{
// Construction
public:
CMarineFixDlg(CWnd* pParent = NULL); // standard constructor
afx_msg void OnTimer(UINT nIDEvent);
afx_msg void OnPaint();
enum { IDD = IDD_MARINEFIX_DIALOG };
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual BOOL OnInitDialog();
HICON m_hIcon;
DECLARE_MESSAGE_MAP()
private:
bool bd_CheckMarine();
};
* 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.