c# - How to show Windows forms continuously in extended monitor even if primary is locked -



c# - How to show Windows forms continuously in extended monitor even if primary is locked -

in our project have requirement display dashboards (windows forms) in extended displays connected cpu.

currently able display dashboards in extended display, extended display not show 1 time scheme (primary) got locked.

we not allowed changes respect workstation locking.

we have show dashboards on extended displays if primary locked. , there remove dependency on primary, 1 time dashboards sent extended displays?

we using vs2013 , c#.

thanks, srikk

"we not allowed changes respect work station locking."

pretty sure windows thing , there's no way around without "making changes work station locking." expand on this, windows locks displays when lock computer - obvious reasons. wouldn't create sense lock computer , still display desktop/files. unless don't "lock" computer, secondary display locked windows (assuming operating scheme you're using).

to expand on this, it's possible not lock computer, create global key/mouse hook (don't forget need go lengths lock ctrl+alt+delete if want right) ignore key presses/mouse movements.

i don't have code written in c# on me, here autoit code wrote locks keyboard , mouse , displays flying nyan cats on screen. if presses key, locks computer (the real way) through windows api.

;/////////////////////////////// ;// lock code created dt // ;/////////////////////////////// #include <winapi.au3> #include <guiconstantsex.au3> #include <windowsconstants.au3> sleep(5000); ;/////////////////////////////////////////////////////////////// ;// hook user32.dll block mouse/keyboard input , monitor // ;/////////////////////////////////////////////////////////////// global $stub_keyproc = dllcallbackregister("_keyproc", "int", "int;ptr;ptr") global $stub_mouseproc = dllcallbackregister("_mouseproc", "int", "int;ptr;ptr") global $keyboardhook = _winapi_setwindowshookex($wh_keyboard_ll, dllcallbackgetptr($stub_keyproc), _winapi_getmodulehandle(0), 0) global $mousehook = _winapi_setwindowshookex($wh_mouse_ll, dllcallbackgetptr($stub_mouseproc), _winapi_getmodulehandle(0), 0) ;////////////////////// ;// global variables // ;////////////////////// global $lock = false ;if key pressed, set true , handle in our while loop (gets messy otherwise) global $desktopsize = wingetpos("program manager") ;get desktop size programme manager global $maxx = $desktopsize[2]; - 600 ;set max x position using width of our image , width of desktop global $maxy = $desktopsize[3]; - 255 ;set max y position using height of our image , height of desktop global $splashx = int(random(1, $maxx-1)) ;display our splash randomly in acceptable space global $splashy = int(random(1, $maxy-1)) ;display our splash randomly in acceptable space global $splashxvel = int(random(10,20)) ;setup random velocity our image global $splashyvel = 0;int(random(-5,5)) ;setup random velocity our image (no need y velocity anymore) ;//////////////////////////// ;// create , display gui // ;//////////////////////////// $form1 = guicreate("locked",400,280,$splashx, $splashy, $ws_popup, $ws_ex_layered) ;create gui window (layered transparency) $giftest = objcreate("shell.explorer.2") ;create shell.explorer object display gif $giftest_ctrol = guictrlcreateobj($giftest,-5,-5,410,290) ;push out of our gui bounds hide border ; ;create variable hold simple html code displays gif $url = "about:<html><body bgcolor='#dedede' scroll='no'><img src='c:\users\dt\pictures\nyan-cat.gif'></img></body></html>" $giftest.navigate($url) ;point our shell explorer our html code _winapi_setlayeredwindowattributes($form1, 0xdedede, 255) ;set our transparency color our html background create transparent guisetstate(@sw_show) ;and finally, display our gui ;/////////////////////////////////////////////////////// ;// function called whenever key pressed // ;/////////////////////////////////////////////////////// func _keyproc($ncode, $wparam, $lparam) ;grab parameters our dll hook if $ncode < 0 homecoming _winapi_callnexthookex($keyboardhook, $ncode, $wparam, $lparam) ;if it's not key beingness pressed phone call next hook $lock = true ;otherwise, it's time lock computer homecoming 1 ;don't phone call next hook (supress key press) endfunc ;/////////////////////////////////////////////////////// ;// function called whenever mouse moves // ;/////////////////////////////////////////////////////// func _mouseproc($ncode, $wparam, $lparam) ;grab parameters our dll hook randomizevelocity() ;randomize our splash velocity randomizeposition() ;and randomize position homecoming 1 ;then supress mouse motion endfunc ;/////////////////////////////////////////////////////////////////////// ;// simple randomize functions reuse code , ease of reading // ;/////////////////////////////////////////////////////////////////////// func randomizevelocity() $splashxvel = int(random(10,20)) ;$splashyvel = int(random(-3,3)) endfunc func randomizeposition() $splashx = int(random(1, $maxx-1)) $splashy = int(random(1, $maxy-1)) endfunc ;///////////////////////////////////////////////// ;// our programme loop (main function basically) // ;///////////////////////////////////////////////// hidetaskbar(); while 1 ;loop indefinitely (until exit :)) $splashx = $splashx + $splashxvel ;modify splash x position velocity $splashy = $splashy + $splashyvel ;modify splash y position velocity winmove($form1,"" , $splashx, $splashy) ;and move window ;if $splashx >= $maxx or $splashx <= 0 $splashxvel *= -1 ;if our splash image hits border ;if $splashy >= $maxy or $splashy <= 0 $splashyvel *= -1 ;reverse velocity (can buggy! ;)) if $splashx >= $maxx $splashy = int(random(1,$maxy-400)) $splashx = -400; endif if $lock ;if have message lock computer dllcallbackfree($stub_keyproc) ;release our hooks dllcallbackfree($stub_mouseproc) _winapi_unhookwindowshookex($keyboardhook) _winapi_unhookwindowshookex($mousehook) showtaskbar(); run("rundll32.exe user32.dll,lockworkstation") ;and lock computer exit ;then exit programme :) endif sleep(40) wend ;///////////////////////////////////////////////// func hidetaskbar() winsettrans("[class:shell_traywnd]", "", 0) controlhide('','', wingethandle("[class:button]")) endfunc func showtaskbar() winsettrans("[class:shell_traywnd]", "", 255) controlshow('','', wingethandle("[class:button]")) endfunc

edit:

in regards ctrl+alt+del key combination (or other windows key combinations), checkout link info on how disable those:

http://tamas.io/c-disable-ctrl-alt-del-alt-tab-alt-f4-start-menu-and-so-on/

c# windows visual-studio-2013 dashboard dual-monitor

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -