c# - How can i refresh one specific hWnd window every X minutes? -
what i'm doing capturing screenshot of windows in background. in listbox have items of windows i'm taking screenshots. idea windows in background don't need move windows foreground each time.
in form1 constructor:
this.listboxsnap.items.addrange(windowsnap.getallwindows(true, true).toarray());
then in form1 have refreshwindowslist method:
private void refreshwindowslist() { graphics g; g = graphics.fromimage(img); g.clear(color.transparent); buttonsnap.enabled = true; this.listboxsnap.items.clear(); this.listboxsnap.items.addrange(windowsnap.getallwindows(true, true).toarray()); (int = listboxsnap.items.count - 1; >= 0; i--) { string tt = listboxsnap.items[i].tostring(); if (tt.contains(" ,")) { listboxsnap.items.removeat(i); } } string[] mylist = new string[listboxsnap.items.count]; (int = 0; < listboxsnap.items.count; i++) { string tt = listboxsnap.items[i].tostring(); int index = tt.lastindexof(","); mylist[i] = tt.substring(0, index); } textboxindex.text = listboxsnap.items.count.tostring(); if (this.listboxsnap.items.count > 0) { this.listboxsnap.setselected(0, true); } listboxsnap.select(); }
the problem if make refresh if call method every x seconds/minutes listbox blink. wondering if there way refresh specific window form windowsnap.getallwindows collection , not refresh listbox.
so if refresh specific hwnd window , save window image screenshot on hard disk not see changes on listbox have collection of images saved on hard disk.
the class windowsnap bit long give link don't want add here:
and it's using class windowsnapcollection.cs
the idea again somehow refresh specific hwnd window frol collection , refresh listbox.
to disable flicker while clearing , reloading items of listbox
, can use beginupdate()
, endupdate()
methods of listbox
control, example in timer interval 1000 wrote code , there no flicker in listbox
:
private void timer1_tick(object sender, eventargs e) { this.listbox1.beginupdate(); this.listbox1.items.clear(); (int = 0; < 100; i++) { this.listbox1.items.add(i); } this.listbox1.endupdate(); }
also can put new items in list , then, add them using :
listbox1.items.addrange(youritemslist.cast<object>().toarray());
Comments
Post a Comment