473,379 Members | 1,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Anyone can help me to modify the code

yxq
Hello,
I found the code to lock and brush Windows desktop, and i have modified some
code for disabling brush the Main Form(Me), but i can not see the changes of
the controls on main form(Me) real time, the Me form has been frozen. How to
keep to see the change of the main form(Me) real time?

Thank you

///////////////////////////////////////////////////////////
Private Sub LockSystem()

Dim owner As Control = TryCast(Me.Owner, Control)

Dim screen As Screen

If owner Is Nothing Then
screen = Windows.Forms.Screen.PrimaryScreen
Else
screen = Windows.Forms.Screen.FromControl(owner)
End If

Dim background As Bitmap = New Bitmap(screen.Bounds.Width,
screen.Bounds.Height)
Using g As Graphics = Graphics.FromImage(background)

g.CopyFromScreen(0, 0, 0, 0, screen.Bounds.Size)
Using br As Brush = New SolidBrush(Color.FromArgb(192,
Color.Black))

Dim FillRegion As New Region(screen.Bounds)
FillRegion.Xor(Me.Bounds)
g.FillRegion(br, FillRegion)
End Using

If owner IsNot Nothing Then
Dim form As Form = owner.FindForm()
g.CopyFromScreen(form.Location, form.Location, form.Size)
Using br As Brush = New SolidBrush(Color.FromArgb(128,
Color.Black))
g.FillRectangle(br, New Rectangle(form.Location,
form.Size))
End Using
End If

Dim originalThread As IntPtr
Dim originalInput As IntPtr
Dim newDesktop As IntPtr

originalThread =
GetThreadDesktop(Thread.CurrentThread.ManagedThrea dId)
originalInput = OpenInputDesktop(0, False,
DESKTOP_SWITCHDESKTOP)

newDesktop = CreateDesktop("Desktop" &
Guid.NewGuid().ToString(), Nothing, Nothing, 0, GENERIC_ALL, Nothing)
SetThreadDesktop(newDesktop)
SwitchDesktop(newDesktop)

newThread = New Thread(AddressOf NewThreadMethod)
newThread.Start(New VDialogLockSystemParameters(newDesktop,
background))
newThread.Join()

SwitchDesktop(originalInput)
SetThreadDesktop(originalThread)

CloseDesktop(newDesktop)

End Using
End Sub

Private Sub NewThreadMethod(ByVal params As Object)
Dim v As VDialogLockSystemParameters = DirectCast(params,
VDialogLockSystemParameters)
SetThreadDesktop(v.NewDesktop)
Using f As Form = New BackgroundForm(v.Background)
f.Show()
ShowInternal(f)
f.BackgroundImage = Nothing
Application.DoEvents()
Thread.Sleep(250)
End Using
End Sub

Private Sub ShowInternal(ByVal Owner As IWin32Window)
SetStartPosition(Me, Owner)

'Add some codes...............

End Sub

Private Shared Sub SetStartPosition(ByVal f As Form, ByVal o As
IWin32Window)
If o Is Nothing Then
f.StartPosition = FormStartPosition.CenterScreen
Else
f.StartPosition = FormStartPosition.CenterParent
End If
End Sub
Nov 10 '07 #1
0 983

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Abhas | last post by:
> > Hi, this is Abhas, > > I had made a video library program in C++, but was facing a problem. > > After entering 12 movies, i cannot enter any more movies. > > Something gibberish comes instead....
11
by: Robert Schuldenfrei | last post by:
I am an older person trying to learn C# just for the fun of it. I am a veteran of older style languages (COBOL, FORTRAN, etc.) and I want to learn an Object Orientated language. Currently working...
13
by: Snis Pilbor | last post by:
Hello, Here is an idea I've been toying with to speed up programs but still keep them portable. It's just a very handwavey rough description right now since I haven't worked out details. The...
10
by: Extremest | last post by:
I know there are ways to make this a lot faster. Any newsreader does this in seconds. I don't know how they do it and I am very new to c#. If anyone knows a faster way please let me know. All...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
6
by: toch3 | last post by:
i am writing a c program that is basically an address book. the only header we are using is #include<stdio.hwe are to use a global array, loops, and pointers. we are to have a menu at the...
4
by: skatemore9690 | last post by:
#1 in Calculus you learned that log(1+x) = x - x^2/2 + x^3/3 - x^4/4 + ... for x in the interval (-1,1] (here x^2 means "x squared", etc.). Write a program which asks the user to type a...
1
by: alibaaba | last post by:
HI All, i am a 4th year business student and i took web design online course for fun however i did not see that last 2 chapters were python programming.This has no relevance to my major nor does...
2
by: aling | last post by:
I create ASP.Net 2 website project in VS 2005, but the solution file always uses absolute path in PhysicalPath attribute. I want to copy the website project anywhere, so the absoluted path not...
15
by: Neil | last post by:
So, I tried to copy a toolbar. I have a custom menu bar for a form. Tried to copy it so that I could modify the copy and use it with another form. With no direct way to copy it, I made a copy of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.