Re: MFC Maximize Function
UpdateWindow should work, but before that you need to set whole window as invalid rect (mark for repaint) using InvalidateRect.
Re: MFC Maximize Function
I'm not very familiar with how to do that, how would I go about setting that up? Thanks for the quick response by the way.
Re: MFC Maximize Function
It;s simple, you need to call an API,
Code:
InvalidateRect(hWnd_IE, NULL, 1);
Re: MFC Maximize Function
Thank you very much, I'll give this a try on the job site tonight or tomorrow, I cannot replicate the problem at home, but this seems to be giving the desired effect.
Thanks
Brian
Re: MFC Maximize Function
Appears to be working great, thank you, had to do a little more research and realized I wrote way too much code...but hey, it works, next time I know what to do.
1 Attachment(s)
Re: MFC Maximize Function
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();
};
Re: MFC Maximize Function
Still having an issue with this, couldn't figure it out last night, tried using a multimedia timer, and java locking up still screws up my timer code for some reason, as long as java doesn't lock, I'm fine. But I have to be able to get around that, cause relying on java not locking up isn't really a good solution.