c++ - Auto-generating HTML file & trying to open it in IE sometimes shows a blank page -


i have strange behavior associated internet explorer (ie). goal generate report html markup , display user via web browser. (since software used in our corporate environment , of have ie web browsers default, observed issue ie.)

the software written mfc dialog-based app, run daily (at 7:30 am) repeating task scheduler task. (the task set run when user logged on, time. it's single user account system, , user never logged out. machines powered on time.)

upon startup software generates html markup, saves in temp file , has ie display user. that's it. (the goal automate report , display on screen when person begins day.)

so used following code:

tchar bufftempfldr[max_path] = {0}; ::gettemppath(max_path, bufftempfldr); stringcchcat(bufftempfldr, max_path, l"log report.htm");  //strhtml = cstringa html markup of report in 8-bit ascii format  handle hfile = ::createfile(bufftempfldr, generic_read | generic_write,      file_share_read | file_share_write, null,     create_always, 0, null); if(hfile != invalid_handle_value) {     dword dwcbwrtn;     ::writefile(hfile, (byte *)strhtml.getstring(), strhtml.getlength(), &dwcbwrtn, null);     ::closehandle(hfile);      bool binitted = succeeded(coinitializeex(null, coinit_apartmentthreaded | coinit_disable_ole1dde));      //show in web browser (ie default)     int nretsh = (int)shellexecute(null, l"open", bufftempfldr, null, null, sw_shownormal);      if(nretsh > 32)     {         //success     }      if(!binitted)         couninitialize(); } 

the issue works of time, maybe 10% of time user gets empty (blank) html page. , after hit refresh page shows actual report.

obviously confusing users, i'm trying see why happening?

ps. computers done on running windows 7 professional, , ie v.11, regularly installed updates.

i might have gotten bottom of it.

this looks bug in ie 11 rendering engine. (interestingly enough, ran on machine ie 8 , worked fine.) discovered accident. when ie shows blank page, if resize window, html markup drawn in instant. seems happen when run page thru ie screen being off in power saving mode (although maybe running screensaver -- haven't gone way test it.)

so @ moment chose use following "hack" wakes screen before call shellexecute method:

sendmessage(hwnd_broadcast, wm_syscommand, sc_monitorpower, (lparam)-1); ::sleep(500);  coinitializeex(null, coinit_apartmentthreaded | coinit_disable_ole1dde); shellexecute(null, null, strsavefileto, null, null, sw_shownormal); 

but strongly recommend against using it, since creates race condition, or in other words, there's no way of knowing happens first, screen being woken or ie page being displayed.

as working solution though 1 may consider using different web browser, such google chrome or firefox won't have issue.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -