|
Dave,
Appreciate your help...
i am able to create a new desktop and show a msgbox onto it, however i am unable to show a form in the new desktop, the form is displayed in the original desktop.
below is the code i am using ...
(this is working wonderfully....)
<DllImport("user32.dll")> _
Private Shared Function CreateDesktop(ByVal lpszDesktop As String, ByVal lpszDevice As IntPtr, ByVal pDevmode As IntPtr, ByVal dwFlags As Integer, ByVal dwDesiredAccess As Integer, ByVal lpsa As IntPtr) As IntPtr
End Function
<DllImport("user32.dll")> _
Public Shared Function SetThreadDesktop(ByVal hDesktop As IntPtr) As Boolean
End Function
<DllImport("user32.dll")> _
Public Shared Function GetThreadDesktop(ByVal dwThreadId As Integer) As IntPtr
End Function
<DllImport("kernel32.dll")> _
Public Shared Function GetCurrentThreadId() As Integer
End Function
<DllImport("user32.dll")> _
Public Shared Function SwitchDesktop(ByVal hDesktop As IntPtr) As Boolean
End Function
'desktop
Public Const DESKTOP_CREATEWINDOW As Integer = &H2
Public Const DESKTOP_ENUMERATE As Integer = &H40
Public Const DESKTOP_WRITEOBJECTS As Integer = &H80
Public Const DESKTOP_SWITCHDESKTOP As Integer = &H100
Public Const DESKTOP_CREATEMENU As Integer = &H4
Public Const DESKTOP_HOOKCONTROL As Integer = &H8
Public Const DESKTOP_READOBJECTS As Integer = &H1
Public Const DESKTOP_JOURNALRECORD As Integer = &H10
Public Const DESKTOP_JOURNALPLAYBACK As Integer = &H20
Public Const AccessRights As Integer = DESKTOP_CREATEWINDOW Or DESKTOP_SWITCHDESKTOP
Public Const MB_SERVICE_NOTIFICATION As UInteger = &H200000
Private Sub CreateNewDesktop()
'Get the current desktop
Dim _hOrigDesktop As IntPtr = GetThreadDesktop(GetCurrentThreadId())
'create our desktop
Dim _hNewDesktop As IntPtr = CreateDesktop("MyDesktop", IntPtr.Zero, IntPtr.Zero, 0, AccessRights, IntPtr.Zero)
' set the thread desktop
SetThreadDesktop(_hNewDesktop)
SwitchDesktop(_hNewDesktop)
'MessageBox.Show("test", "test", MessageBoxButtons.OK, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, MessageBoxOptions.ServiceNotification)
Form2.showdialog() 'this is not shown in the new desktop
SwitchDesktop(_hOrigDesktop)
SetThreadDesktop(_hOrigDesktop)
End Sub
is there something i am missing out...Also is there a way to get all the processes in the original desktop to the new desktop just to imitate the original one..
|
|
|
|
|
SwitchDesktop only shows the new Desktop. This does not put new windows you create on the new Desktop. For that to happen, you have to close ALL other windows your app created, call SetThreadDesktop (properly), then create the new window. When the window is dismissed, you can reverse this process to set the desktop back to the users normal desktop.
The call to SetThreadDesktop WILL FAIL if your app has ANY windows or hooks in place on the user desktop when you call it.
|
|
|
|
|
Hi Dave,
I am somewhat able to show the form properly on the new desktop.....i just used a different thread to execute the new desktop procedure....
However there are a few glitches...
1). i am unable to move/drag the form
2). the close button on the form is automatically disabled
|
|
|
|
|
dileep2009 wrote: .....i just used a different thread to execute the new desktop procedure....
Not a good idea. Creating forms off of the initial UI thread (start up thread of your app) will result is funky things happening to your form. At least, I'm assuming you're creating the form on a different thread.
|
|
|
|
|
Hi Dave,
Now i hv a different thought in my mind, can i create a form, take a snapshot of the desktop and set it as its background image, maximize it to the screen width, height(after hiding the caption bar), and then show a modal dialog on top of it....
Am i sounding weird or will this help to some extent....?
(or may be instead of the desktop image, can i make the parent form 100% transparent...?)
|
|
|
|
|
If you're talking about scrapping the alternate desktop concept, you could do what you descrbie, but it is easily defeatable. All the user has to do is hit Alt-Tab to get around your app and see whatever app they want, or they could just hit Ctrl-Shift-Esc to launch Task Manager and end your app without you being able to prevent it.
|
|
|
|
|
If you're 'securing' the computer, then I got some bad news - it's not actually securing anything. If your specs demand it, then take a look into a writing your own credential provider or your own gina-stub.
May I ask what it is that you are trying to achieve with this code? I'm not asking what you're trying to achieve technically, but rather the functionality that you're after.
I are still stuck @lvl 74
|
|
|
|
|
Hi Eddy,
its basically not to secure the system, but i just want the user to access the desktop only after entering some information (basically its an employee utilization tracker, so when the user has locked his system for a while, he/she needs to provide justification before accessing his/her usual applications).
|
|
|
|
|
Unless you replace the logon-logic, you'll find people bypassing the form. As for the justification, I'd go for "I work here, how about you?" every single time
I are Troll
|
|
|
|
|
Eddy,
i hope the user of my application doesnt read ur justification....
if i can create a transparent form, maximize it to the height and width of the screen and then show a modal dialog, will it serve my purpose....?
|
|
|
|
|
Nope. People can just get around it quite easily.
|
|
|
|
|
Dave,
Please suggest me a better way to track the user productivity.....
|
|
|
|
|
You'd need something that's called a "manager". I'm not talking about the kind of boss that thinks that he's running a jail.
I'm talking about a person who divides the work into pieces, assigns those pieces, who checks the progress regularly and who makes adjustments if needed be.
Alternatively, if the client does run a jail, you might want to point out that each computer logs the time and date that it's started. You can install a program that also counts the number of keys pressed (and do make sure that it's actual work, not just an application that sends keystrokes to simulate a user!), you can measure the lines of code that people produce (I love to be paid, just to type in comments) and the amount of bugs solved.
Those statistics might look as they give you a clue about what's going on in your company, but those stats are subject to interpretation. Someone can solve 30 bugs in a minute, or take 4 days for a single bug. In which case was he/she more productive?
I are Troll
|
|
|
|
|
By being a good manager??
There is no software-based way of tracking a users productivity on a computer. They can be sitting there mashing the keys and throwing the mouse around all day, but what have they really accomplished??
There is simply no way to tell if the user has been productive unless you go and check their work, get progress reports, make sure your actually getting the proper deliverables from each employee, ...
|
|
|
|
|
Nope, I'd press Ctrl-Alt-Del to open the taskmanager, kill the application and get on with my work. Worse, I'd be pissed too, because I'd get the feeling that someone is trying to micromanage me.
If you're trying to monitor productivity, then there's better ways to do so.
I are Troll
|
|
|
|
|
Please suggest me what do i do now....
|
|
|
|
|
Tell your client that there is no fool-proof way to do this. Find out why this
functionality is desired, and see if you can come up with an alternative.
There's an event-log, there's screensavers - lots of ways to measure the activity on a workstation. Then again, activity doesn't equal productivity.
The latter one is hard to measure. Again, the course of action depends on what it is that you're trying to achieve.
I are Troll
|
|
|
|
|
Hey,
I'm working on a .Net library for segmented downloads. I have a Download class and a Segment class. The download class creates a thread for each download, from which threads for each segment are spawned.
I've done this walk through[^], but am having troubles implementing the same pattern for my library.
I don't know how to work with the userStateToLifetime HybridDictionary with async operations in my case, since in contradiction to the example, there are two 'levels' of tasks in my case (Downloads and Segments).
Important to note is that the Download class is set up for ONE download, not multiple.
So what should I do, create one HybridDictionary that holds async operations for the segments, create one that holds both the segments and the download, or two; one holding the segments and one holding the download?
This is my first real implementation of this pattern, so if you think I'm missing some important understanding of it, please refer me to the relevant documentation
Cheers
Jeroen De Dauw
---
Forums ; Blog ; Wiki
---
70 72 6F 67 72 61 6D 6D 69 6E 67 20 34 20 6C 69 66 65!
|
|
|
|
|
I have a property that return bool value.
And the corresponding data type of field in table of this property is bit type.
When I want to save this bool type property it gives the error due to the data which i am going to save in database that's data type is bit type.
My question is how to convert the property into bit from bool?
with regards
tarak
|
|
|
|
|
You can use the system convert functions. I would assume 0 <-> false and 1 <-> true
|
|
|
|
|
While passing values to a bit parameter of an SQL Stored Procedure, use 0 for false and 1 for True.
|
|
|
|
|
If you have correctly defined your parameter objects they will translate bool to bit and bit to bool automaticaly.
What is the .net code you have used to make the database call?
|
|
|
|
|
I want to execute some code on a regular 25kHz interval. It needs to be fairly accurate to within 5%. Does anyone know how to do this. I don't care what language.
|
|
|
|
|
|
I am trying to make a stepper controller. Several Windows CNC controllers, logic analyzers and oscilloscope type program allow you to choose an update rate. They are in the 25kHz - 100kHz rate. I was wondering how they do this?
There is this article Stopwatch - a High-Resolution code timer class[^] but I don't know how you could use this to control the rate.
|
|
|
|