A InfoWiki wikiből
(Változatok közti eltérés)
(Új oldal, tartalma: „<page a="EBooks|Jegyzetek" b="cs:Blog|C# programok">Wallpaper beállítása dual monitoron</page> Amennyiben pl. van egy normál monitorunk 1600x1200, és egy wide monito...”) |
|||
11. sor: | 11. sor: | ||
public const int SPI_SETDESKWALLPAPER = 20; | public const int SPI_SETDESKWALLPAPER = 20; | ||
[DllImport("User32.dll", CharSet = CharSet.Auto)] | [DllImport("User32.dll", CharSet = CharSet.Auto)] | ||
- | private static extern int SystemParametersInfo(int uiAction, int uiParam, string pvParam, int fWinIni); | + | private static extern int SystemParametersInfo( |
+ | int uiAction, | ||
+ | int uiParam, | ||
+ | string pvParam, | ||
+ | int fWinIni | ||
+ | ); | ||
//................................................................................................. | //................................................................................................. | ||
static void Main(string[] args) | static void Main(string[] args) | ||
25. sor: | 30. sor: | ||
g.DrawImage(right, 1600.0f, 0.0f); | g.DrawImage(right, 1600.0f, 0.0f); | ||
g.Dispose(); | g.Dispose(); | ||
- | theImage.Save(@"c:\kepek\choosen_as_actual.bmp", System.Drawing.Imaging.ImageFormat.Bmp); | + | theImage.Save(@"c:\kepek\choosen_as_actual.bmp", |
- | SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @"c:\kepek\choosen_as_actual.bmp", 0x01|0x02); | + | System.Drawing.Imaging.ImageFormat.Bmp); |
+ | SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, | ||
+ | @"c:\kepek\choosen_as_actual.bmp", 0x01|0x02); | ||
} | } | ||
//................................................................................................. | //................................................................................................. |
A lap 2009. január 16., 08:30-kori változata
Wallpaper beállítása dual monitoron
Amennyiben pl. van egy normál monitorunk 1600x1200, és egy wide monitorunk 1680x1050 felbontással, akkor készíthetünk egy 3280x1200-as méretű képet. Ez a kép pontosan a két monitor szélességének (1600+1680) összege szélességű, magassága a két magasság közül a nagyobb érték. Egy ekkora méretű képet amennyiben beállítunk háttérkép (wallpaper)-nek a Windows-ban, úgy ezen kép bal része fog a bal oldali normál, jobb része fog a jobb oldali wide monitorunkon megjelenni. E módon tudunk különböző háttérképet állítani be a bal és jobb monitorunkon.
Feltételezzük, hogy vannak pontosan 1600x1200-as képeink valamely c:\kepek\normal alkönyvtárban, hasonlóan vannak pontosan 1680x1050 méretű képeink a c:\kepek\wide alkönyvtárban.
class Program { static Random rnd = new Random(); public const int SPI_SETDESKWALLPAPER = 20; [DllImport("User32.dll", CharSet = CharSet.Auto)] private static extern int SystemParametersInfo( int uiAction, int uiParam, string pvParam, int fWinIni ); //................................................................................................. static void Main(string[] args) { string leftName = pickupOne(@"c:\kepek\normal", "*.jpg"); string rightName = pickupOne(@"c:\kepek\wide", "*.jpg"); Bitmap theImage = new Bitmap(3280,1200); Image left = Bitmap.FromFile(leftName); Image right = Bitmap.FromFile(rightName); Graphics g = Graphics.FromImage(theImage); g.DrawImage(left, 0.0f, 0.0f); g.DrawImage(right, 1600.0f, 0.0f); g.Dispose(); theImage.Save(@"c:\kepek\choosen_as_actual.bmp", System.Drawing.Imaging.ImageFormat.Bmp); SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, @"c:\kepek\choosen_as_actual.bmp", 0x01|0x02); } //................................................................................................. static string pickupOne(string dirName, string filter) { string[] files = System.IO.Directory.GetFiles(dirName, filter); int i = rnd.Next(0, files.Length); return files[i]; } //................................................................................................. }