Click here to Skip to main content
15,392,679 members
Articles / Desktop Programming / Win32
Alternative
Tip/Trick
Posted 18 Dec 2014

Stats

13.7K views
139 downloads
8 bookmarked

Security Blackout Window (In C#)

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
18 Dec 2014CPOL
This is an alternative for "Security Blackout Window"

Introduction

This is a port of Richard MacCutchan's Security Blackout Window to C#.

The sources are on Github.

Background

I did this as I wanted to see if it would work.

Using the Code

There are two methods that show the blackout window:

C#
public static void Blackout(IntPtr hWnd, Action action);

public static T Blackout<T>(IntPtr hParentWnd, Func<T> func);

The second version (the generic one) is for doing something like:

C#
BlackoutWindow.Blackout(SomeHandle, () => {
    return MessageBox.Show("A Test", "A Test", MessageBoxButtons.YesNo);
});

Points of Interest

I was having the <Sarcasm> greatest </Sarcasm> time getting one of the structures (the WNDCLASSEX one) to marshal correctly in the RegisterClassEx method (damn those AccessViolationExceptions!) I finally ended up using an IntPtr as the argument to the method and using the Marshal class to marshal the structure to memory, which worked.

P/Invoke is useful, but can be a pain in the posterior sometimes.

History

  • V 1.0 - 2014-12-19 - Initial version
  • V 1.1 - 2014-12-19 - Added WPF Example

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Brisingr Aerowing
Founder GryphonSoft Technologies
United States United States
I am a student at Ivy Tech Community College in Lafayette, Indiana, majoring in Computer Information Systems. My hobbies are programming computers, playing video games, and sleeping.

My real name is Zachary Greve.

I am also a furry (e.g. a person who likes to believe they are some kind of creature), and my fursona (my creature 'form') is a Gryphon. Sadly, I cannot draw worth a flip.

I like Gryphons.

Comments and Discussions

 
QuestionQuestion Pin
Richard MacCutchan19-Dec-14 0:05
mveRichard MacCutchan19-Dec-14 0:05 
AnswerRe: Question Pin
Brisingr Aerowing19-Dec-14 5:47
professionalBrisingr Aerowing19-Dec-14 5:47 
AnswerRe: Question Pin
Brisingr Aerowing19-Dec-14 6:05
professionalBrisingr Aerowing19-Dec-14 6:05 
Bugcode sample formatting Pin
Tomas Takac18-Dec-14 23:19
MemberTomas Takac18-Dec-14 23:19 
GeneralRe: code sample formatting Pin
Brisingr Aerowing19-Dec-14 6:08
professionalBrisingr Aerowing19-Dec-14 6:08 
GeneralRe: code sample formatting Pin
Tomas Takac19-Dec-14 8:32
MemberTomas Takac19-Dec-14 8:32 
QuestionFormatting Pin
Richard MacCutchan18-Dec-14 22:18
mveRichard MacCutchan18-Dec-14 22:18 
AnswerRe: Formatting Pin
Brisingr Aerowing19-Dec-14 5:44
professionalBrisingr Aerowing19-Dec-14 5:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.