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++Builder Discussion :

basculez sur une appli ! [Débutant]


Sujet :

C++Builder

  1. #1
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut basculez sur une appli !
    Bonsoir,

    je souhaiterais avoir l'application "notepad" basculer au premier plan !

    notepad est déjà lancé et après l'appui sur un bouton de ma Form afficher notepad en premier plan !

    est ce possible ?

    merci

  2. #2
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Salut microbe83
    Dans un premier temps il faut recuperer le Handle de Notepad, puis appeler la fonction de mise au premier plan
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    HWND hWnd = FindWindow("Notepad",NULL);
    SetForegroundWindow(hWnd);
    }
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  3. #3
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Une autre facon plus complete, je te laisse consulter la doc pour plus de renseignements
    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
     
    //---------------------------------------------------------------------------
    #include <vcl.h>
    #pragma hdrstop
    #include "Unit1.h"
    //---------------------------------------------------------------------------
    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;
    HWND hWnd;
    //---------------------------------------------------------------------------
    __fastcall TForm1::TForm1(TComponent* Owner)
         : TForm(Owner)
    {
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button1Click(TObject *Sender)
    {
    // toujours au premier plan
    hWnd = FindWindow("Notepad",NULL);
    //SetForegroundWindow(hWnd);
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button2Click(TObject *Sender)
    {
    // normal
    SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button3Click(TObject *Sender)
    {
    // affichage efface ainsi que l'icone
    SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_HIDEWINDOW);
    }
    //---------------------------------------------------------------------------
    void __fastcall TForm1::Button4Click(TObject *Sender)
    {
    // affichage et icone retablis
    SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
    }
    //---------------------------------------------------------------------------
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  4. #4
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    bonsoir,
    je viens d'essayé ton code mais il marche si notepad est lancé et fenetre non réduite, si par contre notepad et dans la barre des taches (fenêtre réduite) cela ne fonctionne pas

  5. #5
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Je n'avais pas essaye, mais il suffit d'ajouter le code d'ouverture
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    ShowWindow(hWnd, SW_SHOW);
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  6. #6
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    merci ça fonctionne !! par contre on peut faire appel a tous les programmes qui sont lancé ?
    style reprendre un jeux a qui on aurais fait ALT-TAB ?

  7. #7
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Cela fonctionne avec tous les programmes du moment que l'on recupere le Handle d'une facon quelconque
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  8. #8
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    pour récupéré le Handle comment on s'y prend ? peut on lire cette infos dans le gestionnaire de tache ?
    encore merci !

  9. #9
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Déjà dans ton code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    HWND hWnd = FindWindow("Notepad",NULL);
    hWnd est le handle de Notepad (qui change a chaque ouverture)

    Pour verifier si ce que l'on recupere est correcte on utilise un utilitaire comme Spy++ de Visual C, il y a un programme equivalent pour BCB je ne sais plus le nom
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  10. #10
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    ok, merci pour tout, je faire des essaies encore merci

  11. #11
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    bonjour,

    Pour verifier si ce que l'on recupere est correcte on utilise un utilitaire comme Spy++ de Visual C, il y a un programme equivalent pour BCB je ne sais plus le nom
    je viens de récupéré l'application en fait les deux Spy++ et WinID .
    en faisant les essaies pour notepad sa fonctionne mais pour un jeux qui tourne en mode fenêtré ou plein écran cela ne fonctionne pas pourtant je récupère bien le non de la fenêtre comme pour notepad

    code pour notepad : ça fonctionne
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Sleep(200);
    HWND hWnd = FindWindow("notepad",NULL);
    Sleep(200);
    ShowWindow(hWnd, SW_SHOW);
    Sleep(200);
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    code pour un jeux : ça fonctionne pas
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Sleep(200);
    HWND hWnd = FindWindow("Client W.o.T.",NULL);
    Sleep(200);
    ShowWindow(hWnd, SW_SHOW);
    Sleep(200);
    SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
    voici ce que me donne WinID pour le jeux :
    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
     
    Client W.o.T.
    Time: 07/15/2013 10:05:25.503
    HWND: 0x90924
    ID: 0x0
    Wnd Pos: X = 160; Y = 13; W = 1600; H = 1024
    Client Pos: X = 168; Y = 43; W = 1584; H = 986
    Wnd Brds: CX = 8; CY = 8
    Wnd Ver: 0x0500
    Wnd Stat: Enabled = 1; Visible = 1; Unicode = 1
    Class: App
    Class C++: 
    Class Desc: ""
    HMODULE: 0x400000
    Atom: 0xC2E6
    WndProc Class: 0x510190
    WndProc Window: 0x510190
    Menu: 0x0
    Window DC: 0x5601186B
    Client DC: 0x5901182A
    HICON: 0x7180437
    HICON(sm): 0x83408EB
    HCURSOR: 0x70908D9
    Brush: 0x0
    Xtra [Cls, Wnd]: 0x0, 0x0
    Class Styles: 0x3 = CS_HREDRAW | CS_VREDRAW
    Proc ID: 0x798
    Proc Open Lvl: 0
    Proc Ver: 5.0; Wow64 = 1
    Priorty Class: 0x20 = NORMAL_PRIORITY_CLASS
    Proc Crtd: 07/15 10:05:04
    Proc Krnl Time: 00:01.29
    Proc Usr Time: 00:07.768
    Proc Affty Msk: 0xFF
    Proc Hndls: 587
    Proc GDI Hndls: 40
    Proc USER Hndls: 18
    Mod Alloc Base: 0x400000
    Mod Entry Pnt: 0xD28CBB
    Mod Sz: 0x14CA000
    Proc WrkSet Sz: 0x1176D000
    Proc Min WrkSet Sz: 0x32000
    Proc Max WrkSet Sz: 0x159000
    Proc Pg Flts: 0x525DA
    Proc Pk WrkSet Sz: 0x1E599000
    Proc Qt Pk PgdPl Usg: 0x65D28
    Proc Qt PgdPl Usg: 0x64448
    Proc Qt Pk NPgdPl Usg: 0x13CA8
    Proc Qt NPgdPl Usg: 0x12B48
    Proc Pgfl Usg: 0x18893000
    Proc Pk Pgfl Usg: 0x2291F000
    Proc I/O Rd Nm: 6924
    Proc I/O Wt Nm: 1878
    Proc I/O Oth Nm: 139578
    Proc I/O Rd: 0x125F36C3
    Proc I/O Wt: 0x5B0305
    Proc I/O Oth: 0xDA1674
    Proc Prvlgs: {
     {SeChangeNotifyPrivilege: 0x3 = SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT},
     {SeImpersonatePrivilege: 0x3 = SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT},
     {SeCreateGlobalPrivilege: 0x3 = SE_PRIVILEGE_ENABLED | SE_PRIVILEGE_ENABLED_BY_DEFAULT},
    }
    Thrd ID: 0x4FC
    Priorty Lvl: 0x0 = THREAD_PRIORITY_NORMAL
    Thrd Priorty Boost: 0
    Thrd Crtd: 07/15 10:05:04
    Thrd Krnl Time: 00:00.811
    Thrd Usr Time: 00:05.803
    Base Priorty (Bkgnd): 7
    Base Priorty (Frgnd): 9
    Img Path: "C:\Games\World_of_Tanks\WorldOfTanks.exe"
    Img Type: [32bit-GUI]
    Mod Path: "C:\Games\World_of_Tanks\WorldOfTanks.exe"
    Mod Type: [32bit-GUI]
    HINST: 0x400000
    ShtDn Priorty Lvl: 0x280
    ShtDn Flgs: 0x0
    ShtDn No Retry: 0
    Parent HWND: 
    Parent Class: 
    Wnd Styles: 0x14CF0000 = WS_VISIBLE | WS_CLIPSIBLINGS | WS_BORDER | WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_OVERLAPPEDWINDOW
    Wnd ExStyles: 0x100 = WS_EX_WINDOWEDGE
    merci

  12. #12
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    J'utilise Spy++, il y a un curseur que l'on positionne sur la fenetre dont on recherche le Handle et l'on a quelque chose comme ceci
    0019038E "Sans titre - Bloc-notes" Notepad
    0019038E est le Handle hWnd
    "Sans titre - Bloc-notes" n'est pas utilise et correspond a NULL dans " HWND hWnd = FindWindow("notepad",NULL); "

    WinID je ne connais pas
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  13. #13
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    je viens de faire une capture d’écran de Spy++ en fichier joint
    Images attachées Images attachées  

  14. #14
    Rédacteur
    Avatar de blondelle
    Homme Profil pro
    Inscrit en
    Mars 2006
    Messages
    2 738
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Mars 2006
    Messages : 2 738
    Points : 3 766
    Points
    3 766
    Par défaut
    Recherche " Class Name " c'est cela qui va te permettre de trouver ton Handle
    --
    Plutot que d'essayer de réinventer la roue, apprenons à nous en servir

  15. #15
    Membre du Club
    Homme Profil pro
    Electromécanicien
    Inscrit en
    Octobre 2009
    Messages
    76
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Electromécanicien

    Informations forums :
    Inscription : Octobre 2009
    Messages : 76
    Points : 41
    Points
    41
    Par défaut
    bonsoir,
    merci ça fonctionne avec " Class Name " !

    merci

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Couplage avec Apache: mapper root context sur une appli?
    Par jfourment dans le forum Tomcat et TomEE
    Réponses: 3
    Dernier message: 18/07/2007, 08h28
  2. focus quand on revient sur une appli VB
    Par pinot dans le forum VB 6 et antérieur
    Réponses: 5
    Dernier message: 12/01/2007, 09h09
  3. Glisser/déposer un fichier sur une appli VB
    Par kafifi dans le forum Windows Forms
    Réponses: 4
    Dernier message: 28/11/2006, 23h06
  4. [vb6]MAJ sur une appli qui tourne 24h/24
    Par riesseg dans le forum VB 6 et antérieur
    Réponses: 13
    Dernier message: 25/04/2006, 22h49

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