Click here to Skip to main content
15,898,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do i open a program from a button Pin
Ravi Bhavnani27-Nov-07 5:58
professionalRavi Bhavnani27-Nov-07 5:58 
QuestionHow can I get the URL address for a TCP Packet? Pin
Khoramdin26-Nov-07 13:46
Khoramdin26-Nov-07 13:46 
AnswerRe: How can I get the URL address for a TCP Packet? Pin
macerenn26-Nov-07 15:19
macerenn26-Nov-07 15:19 
GeneralRe: typedef enum c header to C# Pin
schoetbi26-Nov-07 11:04
schoetbi26-Nov-07 11:04 
GeneralRe: typedef enum c header to C# Pin
Luc Pattyn26-Nov-07 11:29
sitebuilderLuc Pattyn26-Nov-07 11:29 
QuestionPossible to get the location of the launching Shortcut? Pin
Sautin.net26-Nov-07 10:56
Sautin.net26-Nov-07 10:56 
AnswerRe: Possible to get the location of the launching Shortcut? Pin
Anthony Mushrow26-Nov-07 11:02
professionalAnthony Mushrow26-Nov-07 11:02 
QuestionProblem with setting Wallpaper Pin
Y@rpen26-Nov-07 10:43
Y@rpen26-Nov-07 10:43 
Hello.

I've wrote recently program which swiches desktop wallpaper every eg. 5 minutes. Everything works well, but I've got one hard problem.

In my program options i can choose style of wallpaper (Tiled, Centred, Stretched).

And now when I'm setting wallpaper Centred and user click RMB on Desktop and choose option "Hide Icons On Desktop". Icons disappear and wallpaper that I have set is chanding from Centered to Tiled. It doesn't happen with stretched or tiled (of course) option.

I checked and when I choose style of wallpeper in Desktop Properties (not in my program) and then hide icons, everything is ok.

I'm totally confused.

I use class below which I've found at CP.com and modified a bit:


public sealed class Wallpaper<br />
    {<br />
        public Wallpaper() { }<br />
<br />
        const int SPI_SETDESKWALLPAPER = 20;<br />
        const int SPIF_UPDATEINIFILE = 0x01;<br />
        const int SPIF_SENDWININICHANGE = 0x02;<br />
<br />
        [DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
        static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);<br />
<br />
        public enum Style : int<br />
        {<br />
            Tiled,<br />
            Centered,<br />
            Stretched<br />
        }<br />
<br />
        public static void Set(Uri uri, Style style)<br />
        {<br />
            System.IO.Stream s = new WebClient().OpenRead(uri.ToString());<br />
<br />
            System.Drawing.Image img = System.Drawing.Image.FromStream(s);<br />
            string tempPath = Path.Combine(Path.GetTempPath(), "wallpaper.bmp");<br />
            img.Save(tempPath, System.Drawing.Imaging.ImageFormat.Bmp);<br />
<br />
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop", true);<br />
            if (style == Style.Stretched)<br />
            {<br />
                key.SetValue(@"WallpaperStyle", 2.ToString());<br />
                key.SetValue(@"TileWallpaper", 0.ToString());<br />
            }<br />
<br />
            if (style == Style.Centered)<br />
            {<br />
                key.SetValue(@"WallpaperStyle", 1.ToString());<br />
                key.SetValue(@"TileWallpaper", 0.ToString());<br />
            }<br />
<br />
            if (style == Style.Tiled)<br />
            {<br />
                key.SetValue(@"WallpaperStyle", 1.ToString());<br />
                key.SetValue(@"TileWallpaper", 1.ToString());<br />
            }<br />
<br />
            SystemParametersInfo(SPI_SETDESKWALLPAPER,<br />
                0,<br />
                tempPath,<br />
                SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);<br />
        }<br />
    }


and I use such instruction:

Wallpaper.Set(new System.Uri("c:\\tap.jpg"), Wallpaper.Style.Centered);

thanks for all responses.
QuestionAuthentication and Authorization Pin
kingletas26-Nov-07 10:41
kingletas26-Nov-07 10:41 
AnswerRe: Authentication and Authorization Pin
Skippums26-Nov-07 11:11
Skippums26-Nov-07 11:11 
Questiontypedef enum c header to C# Pin
schoetbi26-Nov-07 10:11
schoetbi26-Nov-07 10:11 
AnswerRe: typedef enum c header to C# Pin
Luc Pattyn26-Nov-07 10:57
sitebuilderLuc Pattyn26-Nov-07 10:57 
GeneralRe: typedef enum c header to C# Pin
schoetbi26-Nov-07 10:59
schoetbi26-Nov-07 10:59 
GeneralRe: typedef enum c header to C# Pin
Pete O'Hanlon26-Nov-07 11:01
mvePete O'Hanlon26-Nov-07 11:01 
AnswerRe: typedef enum c header to C# Pin
PIEBALDconsult26-Nov-07 11:27
mvePIEBALDconsult26-Nov-07 11:27 
AnswerRe: typedef enum c header to C# Pin
m026-Nov-07 13:05
m026-Nov-07 13:05 
Questionasp.net subdomain Pin
Eli Nurman26-Nov-07 10:07
Eli Nurman26-Nov-07 10:07 
AnswerRe: asp.net subdomain Pin
Paul Conrad26-Nov-07 16:01
professionalPaul Conrad26-Nov-07 16:01 
Questioncopy and paste Pin
netJP12L26-Nov-07 9:46
netJP12L26-Nov-07 9:46 
AnswerRe: copy and paste Pin
Skippums26-Nov-07 10:03
Skippums26-Nov-07 10:03 
GeneralRe: copy and paste Pin
netJP12L26-Nov-07 10:10
netJP12L26-Nov-07 10:10 
GeneralRe: copy and paste Pin
Skippums26-Nov-07 10:48
Skippums26-Nov-07 10:48 
QuestionCollecting code-snippets Pin
Johan Martensson26-Nov-07 9:41
Johan Martensson26-Nov-07 9:41 
AnswerRe: Collecting code-snippets Pin
Pete O'Hanlon26-Nov-07 9:56
mvePete O'Hanlon26-Nov-07 9:56 
AnswerRe: Collecting code-snippets Pin
schoetbi26-Nov-07 10:19
schoetbi26-Nov-07 10:19 

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.