IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

drop file hors service


Sujet :

C#

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2011
    Messages
    900
    Détails du profil
    Informations personnelles :
    Localisation : France, Vienne (Poitou Charente)

    Informations forums :
    Inscription : Mai 2011
    Messages : 900
    Points : 85
    Points
    85
    Par défaut drop file hors service
    Bonjour
    Pouvez-vous me dépanner le code source qui ne fonctionne pas.
    Le drop file ne fonctionne pas du tout !!! sur le listbox .

    J'appelle une modal d'une dll c# depuis le code non manager ! et ca ne marche pas, aucun evenement Ondrop onenter .... n'est appeller !

    Merci.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
     
     public partial class ftestfile : Form
        {
     
            internal const string nameC = "listm";
            public ftestfile()
            {
                InitializeComponent();
     
     
     
            }
     
     
            private void mdp_button__lingue_15_Click(object sender, EventArgs e)
            {
     
                Close();
            }
     
            private void ftestfile_Load(object sender, EventArgs e)
            {
               mdp_lstbox_out.AllowDrop = true;
            }
     
            private void ftestfile_MouseMove(object sender, MouseEventArgs e)
            {
                int x = e.X; //ca passe dedans
            }
     
            private void edrop(object sender, DragEventArgs e) //n'est pas appeller du tout !
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                int nb = 1;
                foreach (string file in files)
                {
                    mdp_lstbox_out.Items.Add(file);
                }
            }
     
            private void eenter(object sender, DragEventArgs e) //n'est pas appeller du tout !
            {
                e.Effect = DragDropEffects.Copy;
     
            }
        }
    Designer :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
     
    namespace Test3
    {
        partial class ftestfile
        {
            /// <summary>
            /// Required designer variable.
            /// </summary>
            private System.ComponentModel.IContainer components = null;
     
            /// <summary>
            /// Clean up any resources being used.
            /// </summary>
            /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
            protected override void Dispose(bool disposing)
            {
                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
     
            #region Windows Form Designer generated code
     
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {
                this.mdp_lstbox_out = new System.Windows.Forms.ListBox();
                this.mdp_button__lingue_16 = new System.Windows.Forms.Button();
                this.mdp_button__lingue_15 = new System.Windows.Forms.Button();
                this.SuspendLayout();
                // 
                // mdp_lstbox_out
                // 
                this.mdp_lstbox_out.AllowDrop = true;
                this.mdp_lstbox_out.FormattingEnabled = true;
                this.mdp_lstbox_out.Location = new System.Drawing.Point(38, 31);
                this.mdp_lstbox_out.Name = "mdp_lstbox_out";
                this.mdp_lstbox_out.Size = new System.Drawing.Size(220, 225);
                this.mdp_lstbox_out.TabIndex = 0;
                this.mdp_lstbox_out.DragDrop += new System.Windows.Forms.DragEventHandler(this.edrop);
                this.mdp_lstbox_out.DragEnter += new System.Windows.Forms.DragEventHandler(this.eenter);
                // 
                // mdp_button__lingue_16
                // 
                this.mdp_button__lingue_16.Location = new System.Drawing.Point(107, 399);
                this.mdp_button__lingue_16.Name = "mdp_button__lingue_16";
                this.mdp_button__lingue_16.Size = new System.Drawing.Size(78, 23);
                this.mdp_button__lingue_16.TabIndex = 12;
                this.mdp_button__lingue_16.Text = "button2";
                this.mdp_button__lingue_16.UseVisualStyleBackColor = true;
                // 
                // mdp_button__lingue_15
                // 
                this.mdp_button__lingue_15.Location = new System.Drawing.Point(107, 369);
                this.mdp_button__lingue_15.Name = "mdp_button__lingue_15";
                this.mdp_button__lingue_15.Size = new System.Drawing.Size(78, 24);
                this.mdp_button__lingue_15.TabIndex = 11;
                this.mdp_button__lingue_15.Text = "button2";
                this.mdp_button__lingue_15.UseVisualStyleBackColor = true;
                this.mdp_button__lingue_15.Click += new System.EventHandler(this.mdp_button__lingue_15_Click);
                // 
                // ftestfile
                // 
                this.AllowDrop = true;
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(346, 450);
                this.Controls.Add(this.mdp_button__lingue_16);
                this.Controls.Add(this.mdp_button__lingue_15);
                this.Controls.Add(this.mdp_lstbox_out);
                this.Name = "ftestfile";
                this.Text = "ftestfile";
                this.Load += new System.EventHandler(this.ftestfile_Load);
                this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ftestfile_MouseMove);
                this.ResumeLayout(false);
     
            }
     
            #endregion
     
            private System.Windows.Forms.ListBox mdp_lstbox_out;
            private System.Windows.Forms.Button mdp_button__lingue_16;
            private System.Windows.Forms.Button mdp_button__lingue_15;
        }
    }
    Les méthodes eenter et edrag ne sont pas appeller du tout !

    J'appelle depuis le code non manager un dll c# qui contient un winformet le drop file ne fonctionne pas !

    J'ai essayer sur un nouveau projet winform c# ,ca marche ! je ne comprend pas !

    Existe t'il des utilitaires de diagnostiques pour ce genre de probléme ?

    J'ai essayer d'executer ShowDialog sur un autre thread , ça fonctionne mais dans le thread principale.

    Merci


    merci de me dépanner !

  2. #2
    Membre régulier
    Profil pro
    Inscrit en
    Mai 2011
    Messages
    900
    Détails du profil
    Informations personnelles :
    Localisation : France, Vienne (Poitou Charente)

    Informations forums :
    Inscription : Mai 2011
    Messages : 900
    Points : 85
    Points
    85
    Par défaut
    J'ai essayer avec ceux ci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    const uint WM_DROPFILES = 0x0233;
            [System.Runtime.InteropServices.DllImport("shell32.dll")]
            static extern void DragAcceptFiles(IntPtr hwnd, bool fAccept);
     
     protected override void WndProc(ref Message m)
     
            {
     
                if (m.Msg == WM_DROPFILES)
                {
                    m = m;
                    uint StrSize = 4096;  // StrSize is an Cardinal variable
                    int count= (int)DragQueryFileW(m.WParam, uint.MaxValue, IntPtr.Zero, StrSize);
                    IntPtr hh = Marshal.AllocHGlobal((int)((StrSize + 8) << 1));
                    for (int i = 0; i < count; i++)
                    {
                        //StringBuilder s;
                        int ss = (int)DragQueryFileW(m.WParam,(uint)i, hh, StrSize);
                        string s = Marshal.PtrToStringUni(hh, ss);
     
                        cllistboxtest cl = new cllistboxtest(s, cn);
                        mdp_lstbox_out.Items.Add(cl);
                        cn++;
                    }
     
                    Marshal.FreeHGlobal(hh);
                    DragFinish(m.WParam);
                }
                base.WndProc(ref m);
            }
     
            }
    Et la il passe bien dans WM_DROPFILES , ET CA MARCHE AVEC LES FONCTIONS NATIVES !
    Pourquoi ca ne marche pas avec les fonctions c# !!!?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Discussions similaires

  1. Graveur capricieux : est-il hors service ?
    Par screamtime dans le forum Périphériques
    Réponses: 2
    Dernier message: 10/04/2007, 18h03
  2. Détection imprimante hors service
    Par Droïde Système7 dans le forum Langage
    Réponses: 12
    Dernier message: 04/02/2006, 20h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo