• 0

C# Screen saver?


Question

Recommended Posts

  • 0
The name that appears in the combo-box in the display properties window.

Also, i think exe files can have functions exported, i think i can remember doing it with a linker override thing in vb6

Ok, the screensaver's name is less important to me. If any one else konw a better way to do it please tell me.

  • 0

hijack time. anyone know how to change the context menu links so that when you right click on the desktop and select properties. instead of it pointing to the control panel program it would launch another executable or cpl (but i think cpl is just arenamed exe)

  • 0
hijack time. anyone know how to change the context menu links so that when you right click on the desktop and select properties. instead of it pointing to the control panel program it would launch another executable or cpl (but i think cpl is just arenamed exe)

a cpl file is a dll file with a function called cpl exported. it takes care of telling windows it's name, description and icon, and launching it when it's double-clicked.

  • 0

This is quite stupid... a screen saver should support the /p <hwnd> command line. I've tried everything I could think of to get this to work, including the C-dll to no avail. Maybe there is some obscure/unknown issue with .NET interop and screensavers, though I wouldn't think so.

  • 0

Hello everyone

I am a chinese and I slept away my english lessons for all time that i can't understand English sentence exactly

But could that code can helps you?

using System.Drawing;
.
.
.

IDataObject d=Clipboard.GetDataObject();
if(d.GetDataPresent(DataFormats.Bitmap))
{
Bitmap B=(Bitmap)d.GetData(DataFormats.Bitmap);
}

Now you get a bitmap-type object " B" which contains a picture, namely,The Sreansaver.

  • 0
But how does it get the screen saver ?

Use Print Screen Button!

That's easy.But you must know API Program.

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Then you can press that button "Print Screen Sys Rq"

Call keybd_event(VK_SNAPSHOT, 1, 0, 0)
DoEvents//Must do this or Windows will do nothing on Runtime

Then that button will be pressed really!

This is VB.net style.

You can write it in C# like:

using System.Runtime.InteropServices;
.
.
.
.
[DllImport("user32.dll")]
public static extern void keybd_event (Byte bVk, Byte bScan , Long dwFlags ?, Long dwExtraInfo )

then use that method to press any Keys like "Print Sreen"

Oh!

I forgot it!

VK_SNAPSHOT is a Byte '&H2C'

It's the number of the Key(Print Screen)

Edited by nkorls
  • 0

Oh my Muh!!

I am wrong in the begining..

it looks as I had better study English hard

you can use this

PostMessage(WM_SYSCOMMAND,SC_SCREENSAVE,0);

to act current ScreenSaver

I think you want to get current Screen picture at the begining.

faint~

this is the code;

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Int32, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Int32
 ? ?Private Const HWND_BROADCAST = &amp;HFFFF&amp;
 ? ?Private Const WM_SYSCOMMAND = &amp;H112
 ? ?Private Const SC_SCREENSAVE = &amp;HF140&amp;

 ? ?Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 ? ? ? ?SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_SCREENSAVE, 0)
 ? ?End Sub

I use VB more than C#.

So this code is in VB style.

Edited by nkorls
  • 0

But this just activates the screensaver. I want to show it as a preview. Like in the screenshot. I don't want to show the screen saver on the full screen but just in a picture box. I want to show the screensaver in preview mode inside the picture box. How can I do it? Please try to write in c#. Otherwise I have to use a special program to conver it to c# :no:

  • 0
But this just activates the screensaver. I want to show it as a preview. Like in the screenshot. I don't want to show the screen saver on the full screen but just in a picture box. I want to show the screensaver in preview mode inside the picture box. How can I do it? Please try to write in c#. Otherwise I have to use a special program to conver it to c#  :no:

So you can use Command Line to run the ScreenSaveer file like this

c:\winnt\system32\mysc.msc /p <HWND>

<HWND> is the window to display the Preview

How to get the HWND?

You can Use this API:

?[DllImport("user32.dll")]
 ?public static extern int FindWindow(String lpClassName,String lpWindowName);

lpClassName is the name of the class

lpWindowName is the name of the title bar

and run it like

System.Diagnostics.Process.Start(@"C:\winnt\system32\ss3dfo.scr /p "+FindWindow(classname,windownname).toString());

Edited by nkorls
  • 0
If I want to show the screensaver in a picturebox, can't I use pictureBox1.Handle.ToString() to find the HWND ?

HWND Must be a handle of a Window

Someone told me that in MSDN.

and the preview window is the Child-Window of the HWND-window.

That is a Chinese article,I am not a translator,I hope you can understand those word

Edited by nkorls
  • 0
OK, so if I have a picture box called picturebox1 - How do I find its HWND?

And what do I have to write in classname and windownname?

Write it like : FindWindow(null, "Form1")

That is.

I don't remember how to find the handle of a control,I am in my Friend's home and there is No .net Framework on her computer now,So you can search the result on google.com or MSDN yourself.

Time to bed now,bye-bye

By the way: how about my English expression?

I Join this English forum is for studing English mostly.

  • 0

Im working on it now, if i can work out what format windows sends the command arguments in i might be able to make it work

Edit: I wrote a program a while ago that only shows the command line arguments passed to it (to work out i problem i was having with Microangelo Studio, fixed now) it says that windows is passing "/p 4720014" (on my system anyway) for the preview window

Edit 2: i told my test program to load my test app (or scr) it told me i was passing /S to it, but this is my code

Process.Start("C:\Windows\system32\Thingy.scr", "/p " &amp; Me.Handle.ToString)

Edited by The_Decryptor
  • 0

The problem with your approach to the window handle is that .net controls are separate, hidden windows, so you can't use this.Handle. I had the same problem trying to use shell_notifyicon. Use this to get the window handle of your picturebox:

Type t = yourPictureBox.GetType();

IntPtr window = ((NativeWindow)t.GetField("window",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(yourPictureBox)).Handle;

That should get you your handle.

  • 0

I tried this:

Type t = pictureBox1.GetType();
 IntPtr window = ((NativeWindow)t.GetField("window",System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(pictureBox1)).Handle;


 System.Diagnostics.Process.Start(sc , "/p " + window.ToString());

sc is the path to the screen saver.

But it still shows it in full mode.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Marshall Major V Bluetooth headphones are now up to 47% off on Amazon by Ivan Jenic The Marshall Major V in Midnight Blue is currently $89.99 on Amazon, down from $169.99. That's 47% off and $80 saved on a pair of wireless on-ear headphones from one of the most recognizable names in audio. The Major V is Marshall's take on a long-lasting everyday headphone. The headphones deliver 100+ hours of wireless playtime, which puts them in a completely different category from most Bluetooth headphones that hover around 30-40 hours. You’re charging this thing once a week at most, and with wireless charging supported, you don’t have to worry about additional cables. Marshall promises its signature sound profile, with strong bass, smooth mids, and clear highs. There’s a customizable M-button, which you can set to quickly access Spotify Tap, your EQ settings, or a voice assistant. The design is foldable and lightweight at 186 grams, so it’s easy to pack for travel. And finally, the faux leather finish gives the Major V a sleek, premium look. At $89.99, the Major V Midnight Blue is a genuinely strong buy for anyone who wants a reliable daily headphone without paying premium prices. It’s also worth mentioning that the Cream and Brown variants are also discounted to $89.99, though from a lower original price of $99.99. Marshall Major V Midnight Blue - $89.99 | 47% off on Amazon This Amazon deal is US-specific and not available in other regions unless specified. This is a first-party seller link (at the time of article publishing); ensure that you also purchase from a first-party seller link only. If you don't like it or want to look at more options, check out the previous deals that we have covered, OR you can also visit Amazon US deals page. Get Prime (SNAP), Prime Video, Audible Plus or Kindle / Music Unlimited. Free for 30 days. As an Amazon Associate, we earn from qualifying purchases.
    • +1 on XVI. I still use it. 
    • Age 16, old enough to get a full-time job, your own bank account, a passport, get married, even join the military and go to war. But talking to your friends on the internet? Oh hell no!
    • I remember when all games had demos; it was a normal thing, not a limited time promotion.
  • Recent Achievements

    • Reacting Well
      Almohandis earned a badge
      Reacting Well
    • First Post
      Cosminus earned a badge
      First Post
    • One Year In
      ThatGuyOnline earned a badge
      One Year In
    • Week One Done
      Jeroen Wilms earned a badge
      Week One Done
    • Week One Done
      rolfus earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      483
    2. 2
      +Edouard
      185
    3. 3
      PsYcHoKiLLa
      122
    4. 4
      Steven P.
      84
    5. 5
      neufuse
      73
  • Tell a friend

    Love Neowin? Tell a friend!