DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Mon, 2 Jul 2007 10:51:33 -0400,    posted on: microsoft.public.dotnet.framework.drawing        back       

Thread Index
  1    active


This code shows that Dotnet can't get a palette from the clipboard   
Below is a little but complete program that appears to show that Dotnet 
can't retrive a Palette from the clipboard.

This is true wether the palette is placed on the clipboard by Photoshop or 
by the below program

I'd appreciate comments



Imports System.Drawing.Imaging

Public Class Form1

Inherits System.Windows.Forms.Form

Private WithEvents button1 As System.Windows.Forms.Button

Private WithEvents button2 As System.Windows.Forms.Button

Private WithEvents button3 As System.Windows.Forms.Button

Private components As System.ComponentModel.IContainer

Private cp As ColorPalette

Friend WithEvents ToolTip1 As System.Windows.Forms.ToolTip

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

Friend WithEvents TextBox2 As System.Windows.Forms.TextBox

Friend WithEvents Timer1 As System.Windows.Forms.Timer

Public Sub New()

InitializeComponent()

End Sub 'New

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub 'Dispose

#Region "Windows Form Designer generated code"

Private Sub InitializeComponent()

Me.components = New System.ComponentModel.Container

Me.button1 = New System.Windows.Forms.Button

Me.button2 = New System.Windows.Forms.Button

Me.button3 = New System.Windows.Forms.Button

Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)

Me.TextBox1 = New System.Windows.Forms.TextBox

Me.TextBox2 = New System.Windows.Forms.TextBox

Me.Timer1 = New System.Windows.Forms.Timer(Me.components)

Me.SuspendLayout()

'

'button1

'

Me.button1.Location = New System.Drawing.Point(186, 124)

Me.button1.Name = "button1"

Me.button1.Size = New System.Drawing.Size(130, 24)

Me.button1.TabIndex = 2

Me.button1.Text = "Copy File Palette"

Me.ToolTip1.SetToolTip(Me.button1, "Copy Palette from a GIF file to the 
clipboard")

'

'button2

'

Me.button2.Location = New System.Drawing.Point(13, 124)

Me.button2.Name = "button2"

Me.button2.Size = New System.Drawing.Size(156, 24)

Me.button2.TabIndex = 2

Me.button2.Text = "Retrieve Clipboard Palette"

Me.ToolTip1.SetToolTip(Me.button2, "Retrieve a palette from the clipboard")

'

'button3

'

Me.button3.Location = New System.Drawing.Point(88, 167)

Me.button3.Name = "button3"

Me.button3.Size = New System.Drawing.Size(130, 24)

Me.button3.TabIndex = 2

Me.button3.Text = "Exit"

'

'TextBox1

'

Me.TextBox1.Location = New System.Drawing.Point(12, 24)

Me.TextBox1.Multiline = True

Me.TextBox1.Name = "TextBox1"

Me.TextBox1.Size = New System.Drawing.Size(304, 47)

Me.TextBox1.TabIndex = 3

Me.TextBox1.Text = "Palette can be placed on clipboard by using the 'Save 
Palette"" button or by some " & _

"external program such as Photoshop"

'

'TextBox2

'

Me.TextBox2.Location = New System.Drawing.Point(13, 85)

Me.TextBox2.Name = "TextBox2"

Me.TextBox2.Size = New System.Drawing.Size(302, 20)

Me.TextBox2.TabIndex = 4

'

'Timer1

'

Me.Timer1.Enabled = True

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)

Me.ClientSize = New System.Drawing.Size(328, 204)

Me.Controls.Add(Me.TextBox2)

Me.Controls.Add(Me.TextBox1)

Me.Controls.Add(Me.button1)

Me.Controls.Add(Me.button2)

Me.Controls.Add(Me.button3)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

Me.PerformLayout()

End Sub 'InitializeComponent

#End Region

<STAThread()> Shared Sub Main()

Application.Run(New Form1)

End Sub 'Main

Private Sub button1_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles button1.Click

Dim dlg As New OpenFileDialog

dlg.Filter = "GIF files|*.GIF"

If dlg.ShowDialog() = DialogResult.OK Then

Dim zz As Image = Image.FromFile(dlg.FileName)

Dim DataO As New DataObject

DataO.SetData(DataFormats.Bitmap, False, CType(zz, Bitmap))

DataO.SetData(DataFormats.Palette.ToString, False, zz.Palette)

Clipboard.SetDataObject(DataO, False)

End If

End Sub 'button1_Click

Private Sub button2_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles button2.Click

Dim DataO As DataObject = CType(Clipboard.GetDataObject(), DataObject)

If DataO.GetDataPresent(DataFormats.Palette, False) Then

cp = CType(DataO.GetData(DataFormats.Palette), ColorPalette)

If cp Is Nothing Then

MessageBox.Show("Contains palette that is Nothing")

Else

MessageBox.Show(cp.ToString)

End If

Else

MessageBox.Show("No Palette on Clipboard")

End If


End Sub 'button2_Click

Private Sub button3_Click(ByVal sender As Object, ByVal e As 
System.EventArgs) Handles button3.Click

Application.Exit()

End Sub 'button3_Click

Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) 
Handles Timer1.Tick

Dim DataO As DataObject = CType(Clipboard.GetDataObject(), DataObject)

If DataO.GetDataPresent(DataFormats.Palette, False) Then

Dim cp As ColorPalette = CType(DataO.GetData(DataFormats.Palette), 
ColorPalette)

TextBox2.Text = "There is a Palette on the Clipboard"

Else

TextBox2.Text = "The Clipboard does not contain a Palette"

End If

End Sub

End Class 'Form1
Date:Mon, 2 Jul 2007 10:51:33 -0400   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us