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

Visual C++ Discussion :

Gestion de la souris listview c++ api Win32


Sujet :

Visual C++

  1. #1
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut Gestion de la souris listview c++ api Win32
    Bonjour, je voudrai savoir comment r�cup�rer la cellule d'une listview avec un click de la souris
    voila ce que j'ai fait:
    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
     
           case WM_LBUTTONUP:
           {    
             // Déterminer l'élément pointé par la souris:
             lvhti.pt.x = LOWORD(lParam);
             lvhti.pt.y = HIWORD(lParam);
             SendMessage(hlistviewA,LVM_HITTEST,0,(LPARAM)&lvhti);
             // Ne rien faire si en dehors des éléments de la ListView:
             if (lvhti.iItem == -1) break;
             // Trouver l'élément sélectionné:
             int iSelected = SendMessage(hlistviewA,LVM_GETNEXTITEM,-1,LVIS_SELECTED);
             // Ne rien faire si aucun élément sélectionné ou s'il s'agit du même élément que celui pointé par la souris:
              if ((TabListA) && (iSelected>-1))//TabListA =>listview active
              {
              DialogBox(hInst,MAKEINTRESOURCE(IDD_CHOIX),ChildAnalyse,About);
              }        
           }
    le but est de cliqu� sur un item puis d'afficher une boite de dialogue correspondant a cette item.
    Merci

  2. #2
    R�dacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par d�faut
    Citation Envoy� par spunk62 Voir le message
    Bonjour, je voudrai savoir comment r�cup�rer la cellule d'une listview avec un click de la souris
    voila ce que j'ai fait:
    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
     
           case WM_LBUTTONUP:
           {    
             // Déterminer l'élément pointé par la souris:
             lvhti.pt.x = LOWORD(lParam);
             lvhti.pt.y = HIWORD(lParam);
             SendMessage(hlistviewA,LVM_HITTEST,0,(LPARAM)&lvhti);
             // Ne rien faire si en dehors des éléments de la ListView:
             if (lvhti.iItem == -1) break;
             // Trouver l'élément sélectionné:
             int iSelected = SendMessage(hlistviewA,LVM_GETNEXTITEM,-1,LVIS_SELECTED);
             // Ne rien faire si aucun élément sélectionné ou s'il s'agit du même élément que celui pointé par la souris:
              if ((TabListA) && (iSelected>-1))//TabListA =>listview active
              {
              DialogBox(hInst,MAKEINTRESOURCE(IDD_CHOIX),ChildAnalyse,About);
              }        
           }
    le but est de cliqu� sur un item puis d'afficher une boite de dialogue correspondant a cette item.
    Merci
    Salut,
    Quel est le probl�me avec lvhti.iItem ?

  3. #3
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Bonsoir, je ne c'est pas ou est le probl�me dans mon code mais la boite de dialogue ne s'affiche pas quant je clique sur un item...

  4. #4
    R�dacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par d�faut
    As tu v�rifi� les valeurs de lvhti.iItem puis TabListA et iSelected au debugger ?

  5. #5
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Non, je ne sais pas comment utiliser le debugger sinon j'ai trouver un code qui fonctionne sur un projet, mais je poss�de un tabcontrol dans lequel j'ai ma listview, ici ma boite de dialogue s'affiche que quant je change d'onglet.

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    case WM_NOTIFY :
    {
        LPNMHDR pnmhdr;
        pnmhdr=(LPNMHDR)lParam;
        if(pnmhdr->code==NM_CLICK)
        {
    	DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
    	return 0;
        }
    }
    break;
    de ce faite j'ai modifi� le code:
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    case WM_NOTIFY :
    {
        LPNMHDR pnmhdr;
        pnmhdr=(LPNMHDR)lParam;
        if(pnmhdr->hwndFrom == hlistviewA && pnmhdr->code==NM_CLICK)
        {
    	DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
    	return 0;
        }
    }
    break;
    Maintenant la boite de dialogue IDD_CHOIX ne s'affiche pu...

    Ma fen�tre principale et une dialogue box dans laquelle j'ai un tabcontrol plusieurs onglet contenant des boites de dialogue enfant et dans la boite de dialogue enfant 1 j'ai mis une listview.

    J'explique tout sa car il me semble que hwndFrom ne fonctionne pas avec les boites de dialogue.

  6. #6
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    J'ai re�u un peu d'aide :

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    case WM_NOTIFY :
    {
        LPNMITEMACTIVATE lpnmitem;
        lpnmitem = (LPNMITEMACTIVATE) lParam;
        if(lpnmitem->pnmhdr->hwndFrom == hlistviewA && lpnmitem->pnmhdr->code==NM_CLICK)
        {
           DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
           return 0;
        }
    }
    break;
    mais j'ai les erreurs suivante:
    'pnmhdr'*: n'est pas membre de 'tagNMITEMACTIVATE'
    voir la d�claration de 'tagNMITEMACTIVATE'
    pouvez-vous m'aider !

  7. #7
    R�dacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par d�faut
    MSDN est ton ami
    Code cpp : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    typedef struct tagNMITEMACTIVATE {
        NMHDR hdr;
        int iItem;
        int iSubItem;
        UINT uNewState;
        UINT uOldState;
        UINT uChanged;
        POINT ptAction;
        LPARAM lParam;
        UINT uKeyFlags;
    } NMITEMACTIVATE, *LPNMITEMACTIVATE;
    Donc :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    case WM_NOTIFY :
    {
        LPNMITEMACTIVATE lpnmitem;
        lpnmitem = (LPNMITEMACTIVATE) lParam;
        if(lpnmitem->hdr.hwndFrom == hlistviewA && lpnmitem->hdr.code==NM_CLICK)
        {
           DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
           return 0;
        }
    }
    break;

  8. #8
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Oui, le code compile... merci pour ton aide,mais ma boite de dialogue ne se lance toujours pas quant je clique sur une cellule de ma listview...

    Je pr�cise que je charge un fichier de type csv ensuite dans un menu que j'ai cr�� je s�lectionne tableau1 puis a se moment la, la listview est g�n�r�.
    De plus apr�s test:
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
     
    case WM_NOTIFY :
        {
    	DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
        }
    break;
    Ma boite de dialogue se lance a chaque fois que je change d'onglet

  9. #9
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Re,

    j'ai cr�� un nouveau projet simple avec une listview (listview d�clarer dans case WM_INITDIALOG) le code fonctionne, apr�s j'ai cr�� une proc�dure listview dans un autre fichier "procedure.cpp" (comme dans mon code) sa ne fonctionnait pu, solution:
    d�clarer la listview en dehors de la proc�dure (la d�clarer dans INITDIALOG).
    Le probl�me c'est que je charge un fichier puis j'affiche la listview garce au menu (ex: outils\tableau)
    voici mon code:

    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
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
     
    #include <windows.h>
    #include <commctrl.h>
    #include "resource.h"
    #include "procedure.h"
    #include <commctrl.h>
     
    HINSTANCE hInst;
    bool tab=false;
    bool TabListA=false;
    static LVITEM lvi;
    static LVHITTESTINFO lvhti;
    static Plot *P1;
     
    // Déclaration des fonctions du module.
    static HWND	Childtab;
    static HWND	ChildAnalyse;
    static HWND	ChildIndic;
    static int CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM);
    static int MsgInitDialog	(HWND);
    static int MsgNotify		(WPARAM, LPARAM);
    static int MsgCommand		(WPARAM, LPARAM);
    static int CALLBACK Childtab_DlgProc(HWND, UINT, WPARAM, LPARAM);
    static int CALLBACK ChildAnalyse_DlgProc(HWND, UINT, WPARAM, LPARAM);
    static int CALLBACK ChildIndic_DlgProc(HWND, UINT, WPARAM, LPARAM);
    static void UpdateChildTab(HWND);
    static INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
     
    //Dialog principale
    int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,PSTR szCmdLine,int iCmdShow)
    {
    hInst=hInstance;
     
    return DialogBox(hInstance,MAKEINTRESOURCE(IDD_MAIN),NULL,DlgProc);
    }
    //MainDlgProc :
    int CALLBACK DlgProc(HWND hDlg,UINT message, WPARAM wParam, LPARAM lParam)
    {
    static int cx,cy;
    static Plot *P2,*P3;
    int wmId, wmEvent;
    static HWND hlistview,hlistviewA;
     
    switch (message)
        {
     
    		case WM_SIZE:
    		cx = LOWORD (lParam) ;
    		cy = HIWORD (lParam) ;
    		break;
     
    case WM_INITDIALOG : 
     
     
       return MsgInitDialog(hDlg);
     
    		case WM_DESTROY :
    		{
    			// destruction des dialogues enfants
    			DestroyWindow(Childtab);
                            DestroyWindow(ChildAnalyse);
    			DestroyWindow(ChildIndic);
    			return 0;
    		}
    		case WM_NOTIFY :
    		{
            LPNMITEMACTIVATE lpnmitem;
            lpnmitem = (LPNMITEMACTIVATE) lParam;
              if(lpnmitem->hdr.hwndFrom == hlistviewA && lpnmitem->hdr.code==NM_CLICK)
              {
                DialogBox(hInst, MAKEINTRESOURCE(IDD_CHOIX), hDlg,About);
                return 0;
              } 
    		// mise à jour de l'affichage des dialogues enfants
    		LPNMHDR lpnmhdr = (LPNMHDR) lParam;
    		  if(lpnmhdr->code == TCN_SELCHANGE)
    		  {
    		    UpdateChildTab(hDlg);
    		    return 0;
    		  }
    		} 
           break;
    	case WM_COMMAND:
    		wmId    = LOWORD(wParam);
    		wmEvent = HIWORD(wParam);
     
    		// Analyse les sélections de menu :
    		switch (wmId)
    		{
     
    		case ID_FICHIER_QUITTER:
    			EndDialog(hDlg,0);
    			break;
    		case ID_FICHIER_OUVRIR:
                chargertableau (hDlg,hlistview,ChildAnalyse);
     
    			break;
    		case ID_OUTILS_TABLEAU:
    			listview (hlistview,Childtab);
    			break;
    		case ID_OUTILS_ANALYSE:
    			TabListA=true;
                            listviewA (hlistviewA,ChildAnalyse);
    			break;
    		case ID_OUTILS_INDICATEUR:
    			break;
    		}
    		break;//break du switch
    	  break;//break du WM_COMMAND
     
          case WM_CLOSE:
    		//Fermer la boite de dialogue:
    		EndDialog(hDlg,0);
    		 break;
     
         }
    return 0;
     
    }
     
     
    int MsgInitDialog(HWND hDlg)
    {
    Childtab = CreateDialog(hInst, MAKEINTRESOURCE(IDD_TAB),
    									hDlg, Childtab_DlgProc);
    ChildAnalyse = CreateDialog(hInst, MAKEINTRESOURCE(IDD_ANALYSE),
    									hDlg, ChildAnalyse_DlgProc);
    ChildIndic = CreateDialog(hInst, MAKEINTRESOURCE(IDD_INDICATEUR),
    									hDlg, ChildIndic_DlgProc);
    	// ajout des onglets
    	HWND hTabCtrl = GetDlgItem(hDlg, IDC_TAB1);
    	TCITEM tci;
    	tci.mask = TCIF_TEXT;
    	tci.pszText = "Raport ";
    	SendMessage(hTabCtrl, TCM_INSERTITEM, 0, (LPARAM) &tci);
    	tci.pszText = "Analyse ";//hlistviewA
    	SendMessage(hTabCtrl, TCM_INSERTITEM, 1, (LPARAM) &tci);
    	tci.pszText = "Taux";
    	SendMessage(hTabCtrl, TCM_INSERTITEM, 2, (LPARAM) &tci);
    	tci.pszText = "Pareto";
    	SendMessage(hTabCtrl, TCM_INSERTITEM, 3, (LPARAM) &tci);
     
    	// détermination du rectangle où placer les dialogues enfants à partir du rectangle
    	// du tabctrl, conversion dans le systemde coordonnée de la boîte de dialogue parente
    	RECT rcTabCtrl;
    	GetWindowRect(hTabCtrl, &rcTabCtrl);
    	SendMessage(hTabCtrl, TCM_ADJUSTRECT, FALSE, (LPARAM) &rcTabCtrl);
    	MapWindowPoints(NULL, hDlg, (LPPOINT) &rcTabCtrl, 2);
     
    	// taille du dialogue enfant
    	RECT rcChildTab;
    	GetWindowRect(Childtab, &rcChildTab);
    	int x = (rcTabCtrl.left+rcTabCtrl.right)/2 - (rcChildTab.right-rcChildTab.left)/2;
    	int y = (rcTabCtrl.top+rcTabCtrl.bottom)/2 - (rcChildTab.bottom-rcChildTab.top)/2;
    	SetWindowPos(Childtab, NULL, x, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
     
        RECT rcChildAnalyse;
    	GetWindowRect(ChildAnalyse, &rcChildAnalyse);
    	int x1 = (rcTabCtrl.left+rcTabCtrl.right)/2 - (rcChildAnalyse.right-rcChildAnalyse.left)/2;
    	int y1 = (rcTabCtrl.top+rcTabCtrl.bottom)/2 - (rcChildAnalyse.bottom-rcChildAnalyse.top)/2;
    	SetWindowPos(ChildAnalyse, NULL, x, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
     
        RECT rcChildIndic;
    	GetWindowRect(ChildIndic, &rcChildIndic);
    	int x2 = (rcTabCtrl.left+rcTabCtrl.right)/2 - (rcChildIndic.right-rcChildIndic.left)/2;
    	int y2 = (rcTabCtrl.top+rcTabCtrl.bottom)/2 - (rcChildIndic.bottom-rcChildIndic.top)/2;
    	SetWindowPos(ChildIndic, NULL, x, y, 0, 0, SWP_NOZORDER|SWP_NOSIZE|SWP_NOREDRAW);
     
    	// affichage de l'onglet un et mise à jour
    	SendMessage(hTabCtrl, TCM_SETCURSEL, 0, 0);
     
    	UpdateChildTab(hDlg);
    	return TRUE;
     
    }
    // UpdateChildTab :
    void UpdateChildTab(HWND hDlg)
    {
    	// afficher le dialogue correspondant à l'onglet sélectionné et masquer les autres
    	HWND hTabCtrl = GetDlgItem(hDlg, IDC_TAB1);
    	int nSelected = SendMessage(hTabCtrl, TCM_GETCURSEL, 0, 0);
    	ShowWindow(Childtab, (0==nSelected)? SW_SHOW : SW_HIDE);
    	ShowWindow(ChildAnalyse, (1==nSelected)? SW_SHOW : SW_HIDE);
        ShowWindow(ChildIndic, (2==nSelected)? SW_SHOW : SW_HIDE);
     
    }
    int CALLBACK Childtab_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	return 0;
    }
    int CALLBACK ChildAnalyse_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	return 0;
    }
    int CALLBACK ChildIndic_DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    	return 0;
    }
    INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	UNREFERENCED_PARAMETER(lParam);
    	switch (message)
    	{
    	case WM_INITDIALOG:
    		return (INT_PTR)TRUE;
     
    	case WM_COMMAND:
    		if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
    		{
    			EndDialog(hDlg, LOWORD(wParam));
    			return (INT_PTR)TRUE;
    		}
    		break;
    	}
    	return (INT_PTR)FALSE;
    }
    J'ai vraiment besoin de votre aide ! merci

  10. #10
    R�dacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par d�faut
    Citation Envoy� par spunk62 Voir le message
    Re,

    j'ai cr�� un nouveau projet simple avec une listview (listview d�clarer dans case WM_INITDIALOG) le code fonctionne, apr�s j'ai cr�� une proc�dure listview dans un autre fichier "procedure.cpp" (comme dans mon code) sa ne fonctionnait pu
    Salut,
    A quoi ressemble les proc�dures listview et listviewA ?

  11. #11
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Re,

    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
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
     
    void listview (HWND hlistview,HWND Childtab)
    {
     
    	 DestroyWindow(hlistview);
     
    	//MessageBox(NULL,tab[2][11],"barre de titre",MB_OK| MB_ICONEXCLAMATION);
    	// Définir le titre de la boite de dialogue:
    	SetWindowText(Childtab,tab[1][0]);
    	//Créer les controles:
        hlistview=CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,0, WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL ,50, 100, 665, 320, Childtab, 0, 0, 0);
        SendMessage(hlistview,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
    	// Créer les colonnes de la ListView:
    	LVCOLUMN lvc; 
    	lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT |LVCF_SUBITEM; 
    	lvc.fmt = LVCFMT_CENTER; 
    	lvc.iSubItem =0; lvc.cx = 0; lvc.pszText = 0;
     
    	for (d=0;d<12;d++)
    	{
    	SendMessage(hlistview,LVM_INSERTCOLUMN,d,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText =tab[2][d];
    	}
    	SendMessage(hlistview,LVM_INSERTCOLUMN,12,(LPARAM)&lvc); 
    	// Ajout des éléments de la ListView:
    	lvi.mask=LVIF_TEXT | LVIF_STATE ;
    	int i;
    	for(i=0;i<nbligne;i++)
    	{
    	  for (c=0;c<=12;c++)
    	  {
    		lvi.iItem=i;
    		lvi.iSubItem=c;
    		SendMessage(hlistview,LVM_INSERTITEM ,c,(LPARAM)&lvi);
     
    		lvi.iSubItem=c;
    		lvi.pszText=tab[i+3][c-1];
    		SendMessage(hlistview,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
    		}
    	}
    }
    void listviewA (HWND hlistviewA,HWND ChildAnalyse)
    {
     
    	 DestroyWindow(hlistviewA);
     
    	//MessageBox(NULL,tab[2][11],"barre de titre",MB_OK| MB_ICONEXCLAMATION);
    	// Définir le titre de la boite de dialogue:
     
    	//Créer les controles:
        hlistviewA=CreateWindowEx(WS_EX_CLIENTEDGE,WC_LISTVIEW,0, WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_SHOWSELALWAYS | LVS_SINGLESEL ,50, 100, 665, 320, ChildAnalyse, 0, 0, 0);
        SendMessage(hlistviewA,LVM_SETEXTENDEDLISTVIEWSTYLE,0,LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES );
     
    	// Créer les colonnes de la ListView:
    	LVCOLUMN lvc; 
    	lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT |LVCF_SUBITEM; 
    	lvc.fmt = LVCFMT_CENTER; 
    	lvc.iSubItem =0; lvc.cx = 0; lvc.pszText = 0;
     
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,0,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Début de la panne";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,1,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Fin de la panne";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,2,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Sem";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,3,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Avis";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,4,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Bon";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,5,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Poste technique";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,6,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Description";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,7,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Actions";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,8,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Tps";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,9,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Regroupement";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,10,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Classement";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,11,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Type";
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,12,(LPARAM)&lvc); 
    	lvc.iSubItem =1; lvc.cx = 100; lvc.pszText ="Ordre";
     
    	SendMessage(hlistviewA,LVM_INSERTCOLUMN,13,(LPARAM)&lvc); 
    	// Ajout des éléments de la ListView:
    	lvi.mask=LVIF_TEXT | LVIF_STATE ;
     
    	int i;
    	for(i=0;i<nbligne;i++)
    	{
    	  for (c=0;c<=2;c++)
    	  {
    		lvi.iItem=i;
    		lvi.iSubItem=c;
    		SendMessage(hlistviewA,LVM_INSERTITEM ,c,(LPARAM)&lvi);
     
    		lvi.iSubItem=c;
    		lvi.pszText=tab[i+3][c-1];
    		SendMessage(hlistviewA,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
    	  }
    		lvi.iItem=i;
    		lvi.iSubItem=4;
    		SendMessage(hlistviewA,LVM_INSERTITEM ,4,(LPARAM)&lvi);
     
    		lvi.iSubItem=4;
    		lvi.pszText=tab[i+3][2];
    		SendMessage(hlistviewA,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
     
    		lvi.iItem=i;
    		lvi.iSubItem=7;
    		SendMessage(hlistviewA,LVM_INSERTITEM ,7,(LPARAM)&lvi);
     
    		lvi.iSubItem=7;
    		lvi.pszText=tab[i+3][4];
    		SendMessage(hlistviewA,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
     
    		lvi.iItem=i;
    		lvi.iSubItem=9;
    		SendMessage(hlistviewA,LVM_INSERTITEM ,9,(LPARAM)&lvi);
     
    		lvi.iSubItem=9;
    		lvi.pszText=tab[i+3][5];
    		SendMessage(hlistviewA,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
     
    		lvi.iItem=i;
    		lvi.iSubItem=13;
    		SendMessage(hlistviewA,LVM_INSERTITEM ,13,(LPARAM)&lvi);
     
    		lvi.iSubItem=13;
    		lvi.pszText=tab[i+3][8];
    		SendMessage(hlistviewA,LVM_SETITEMTEXT ,i,(LPARAM)&lvi);
    	}
     
    }

  12. #12
    R�dacteur
    Avatar de 3DArchi
    Profil pro
    Inscrit en
    Juin 2008
    Messages
    7 634
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2008
    Messages : 7 634
    Par d�faut
    Salut,
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    void listview (HWND &hlistview,HWND Childtab)
    et
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    void listviewA (HWND &hlistviewA,HWND ChildAnalyse)
    Je t'avoue ne pas avoir lu plus loin que ces deux lignes.

  13. #13
    Membre averti
    Homme Profil pro
    Inscrit en
    Juin 2009
    Messages
    38
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Juin 2009
    Messages : 38
    Par d�faut
    Sa ne fonctionne toujours pas, je ne vois vraiment pas comment faire.

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. R�ponses: 0
    Dernier message: 21/04/2008, 18h22
  2. [API WIN32] Pb avec SHGetSpecialFolderLocation
    Par Invit� dans le forum MFC
    R�ponses: 3
    Dernier message: 27/01/2004, 21h19
  3. [API Win32] WriteFile()
    Par tut dans le forum MFC
    R�ponses: 2
    Dernier message: 27/01/2004, 16h13
  4. API Win32
    Par benoit70 dans le forum MFC
    R�ponses: 8
    Dernier message: 26/01/2004, 19h11
  5. [API win32] R�cup�rer le r�pertoire d'un profile
    Par sbeu dans le forum API, COM et SDKs
    R�ponses: 3
    Dernier message: 27/09/2002, 12h38

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