RECHERCHER :
COMMUNAUTE MP
Identifiez vous ...
Devenir Membre
J'ai oublié mon MDP
DOMAINE MP
Bavardages
Langages Généraux
Langages Web
Langages DotNet
Autres langages
Dev. Jeux Video
Sécurité
Sys. Exploitation
Graphismes
Logiciels
Réseaux
Bases de données
Méthodologies
Emplois High-tech
Aide juridique
FORUM
Index des forums
Ajouter un sujet
Rechercher sujet
Contact Responsable
Devenir modérateur
CHAT MP IRC
Votre pseudo ...
Serv: irc.irc-land.org
Chan: #MoteurProg
PARTICIPER
Plus de 3500 emplois.
Rechercher un job
Déposez votre CV
Emplois High-tech

Visiteur MP

 Intercepter les messages Windows...

Forum : CSHARP (C#)
Sous Catégorie : Aucune
Type du sujet : Sujet Normale
FAQ : FAQ CSHARP (C#)

SUIVI DES SUJETS PAR MAIL

SUIVI PAR MAIL INACTIF

RESOLUTION DU SUJET SUJET NON RESOLU
BLOQUAGE DU SUJET SUJET ACTIF
APPARTENANCE A LA FAQ N'APPARTIENT PAS A LA FAQ


PAGE : [1]

POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

FORUM CSHARP (C#)

PREMIERE PAGE

PAGE PRECEDENTE

Page précedente

Page suivante

PAGE SUIVANTE

DERNIERE PAGE
Jagxx
Nouveau membre
Inscrit : 15/05/2008
Messages : 2
Message
#153117
Posté le 15/05/08 à 14:38
Bonjour,

J'aimerais intercepter les message Windows type WM_NCHITTEST d'une application externe à ma Form afin de pouvoir le traiter dans WndProc (NativeWindow) et rendre l'appli externe indeplacable. Voici mon code :

public partial class Form1 : Form
{
IntPtr hwnd;
public Form1()
{
InitializeComponent();
Process[] procs = Process.GetProcessesByName("calc");
if (procs.Length != 0)
{
hwnd = procs[0].MainWindowHandle;
}
else
MessageBox.Show("Calculatrice is not running.");

MyNativeWindow mnw = new MyNativeWindow(hwnd);
}

public class MyNativeWindow : NativeWindow
{
public MyNativeWindow(IntPtr hParent)
{
AssignHandle(hParent);
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if (m.Result == (IntPtr)2) // 2 = barre de titre
m.Result = (IntPtr)0;
break;
default:
base.WndProc(ref m);
break;
}
}
}
}

Aucun message arrive dans la methode WndProc.
Par contre si j'assigne le Handle de ma Form pour un essai, WndProc intercepte tous les messages et ma Form devient indéplacable.

Comment intercepter les messages de l'appli externe ? Faut il rajouter un evenement quelque part ou est ce parce que ce n'est pas le même Thread ?

Merci d'avance.

Jag

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Publicité
Inscrit : X
Messages : X
Message
#Aucun

HAUT DE PAGE

  

vortex666
Modérateur :
- C & C++
- OpenGL
- Delphi
Chef de projet(s) :
- Vortez3DEngine

Avatar de vortex666
Inscrit : 20/09/2004
Messages : 479
Message
#153126
Posté le 15/05/08 à 18:29
Il te faut utiliser les hooks...

http://msdn.microsoft.com/en-us/library/ms997537.aspx

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 

Jagxx
Nouveau membre
Inscrit : 15/05/2008
Messages : 2
Message
#153132
Posté le 15/05/08 à 20:08
Ok merci, je vais lire cet article. Mais d'après ce que j'ai deja lu sur le Hook, je vais devoir utiliser un Hook global avec DLL externe, et la, ca se complique Smiley

Jag

HAUT DE PAGE

PROFIL MEMBRE LUI ECRIRE 
POSTER UN NOUVEAU SUJET REPONDRE A CE SUJET

PREMIERE PAGE

PAGE PRECEDENTE Page précédente

Page suivante

PAGE SUIVANTE DERNIERE PAGE

FORUM CSHARP (C#)



    PAGE : [1]



.: Site Web développé par Julien Pichot et l'équipe MPWG avec www.evolvia-web.com :.