[ATTACH=CONFIG]3450[/ATTACH]
الكود كامل بالسي شارب
فيجوال بيسك
النص راح يطلع في الزاوية اليمنى العليا للديسكتوب
الكود مكتوب باسي شارب
لذلك ممكن تكون هناك بعض الاخطاء في الترجمة
الكود كامل بالسي شارب
PHP كود :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
const int SPI_SETDESKWALLPAPER = 20;
const int SPIF_UPDATEINIFILE = 0x01;
const int SPIF_SENDWININICHANGE = 0x02;
public Form1()
{
InitializeComponent();
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Trim() == "") { MessageBox.Show("write something"); return; }
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Control Panel\Desktop",true);
string wallPaperPath = (string)key.GetValue("Wallpaper", "");
Image im = Image.FromFile(wallPaperPath);
using (Graphics gr = Graphics.FromImage(im))
{
gr.DrawString(textBox1.Text, new Font("Arial", 50, FontStyle.Bold), Brushes.White, im.Width - textBox1.Text.Length * 30 , 5);
}
string FolderPath = "c://New Wallpapers";
string imgPath = "c://New Wallpapers/img.jpg";
if (!System.IO.Directory.Exists (FolderPath))
{
System.IO.Directory.CreateDirectory(FolderPath);
}
im.Save(imgPath);
key.SetValue("Wallpaper", imgPath);
key.SetValue("WallpaperStyle", 2.ToString());
key.SetValue("TileWallpaper", 0.ToString());
SystemParametersInfo(SPI_SETDESKWALLPAPER,
0,
imgPath,
SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
}
}
}
فيجوال بيسك
PHP كود :
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Namespace WindowsFormsApplication2
Public Partial Class Form1
Inherits Form
Const SPI_SETDESKWALLPAPER As Integer = 20
Const SPIF_UPDATEINIFILE As Integer = &H1
Const SPIF_SENDWININICHANGE As Integer = &H2
Public Sub New()
InitializeComponent()
End Sub
<DllImport("user32.dll", CharSet := CharSet.Auto)> _
Private Shared Function SystemParametersInfo(uAction As Integer, uParam As Integer, lpvParam As String, fuWinIni As Integer) As Integer
End Function
Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.click
If textBox1.Text.Trim() = "" Then
MessageBox.Show("write something")
Return
End If
Dim key As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Control Panel\Desktop", True)
Dim wallPaperPath As String = DirectCast(key.GetValue("Wallpaper", ""), String)
Dim im As Image = Image.FromFile(wallPaperPath)
Using gr As Graphics = Graphics.FromImage(im)
gr.DrawString(textBox1.Text, New Font("Arial", 50, FontStyle.Bold), Brushes.White, im.Width - textBox1.Text.Length * 30, 5)
End Using
Dim FolderPath As String = "c://New Wallpapers"
Dim imgPath As String = "c://New Wallpapers/img.jpg"
If Not System.IO.Directory.Exists(FolderPath) Then
System.IO.Directory.CreateDirectory(FolderPath)
End If
im.Save(imgPath)
key.SetValue("Wallpaper", imgPath)
key.SetValue("WallpaperStyle", 2.ToString())
key.SetValue("TileWallpaper", 0.ToString())
SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, imgPath, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub
End Class
End Namespace
النص راح يطلع في الزاوية اليمنى العليا للديسكتوب
الكود مكتوب باسي شارب
لذلك ممكن تكون هناك بعض الاخطاء في الترجمة

