Plus de precisions pour la communication multiple stp !!!

cs_Xs Messages postés 368 Date d'inscription mercredi 14 novembre 2001 Statut Membre Dernière intervention 1 septembre 2008 - 4 avril 2002 à 11:52
mmuller57 Messages postés 174 Date d'inscription mardi 10 avril 2001 Statut Membre Dernière intervention 30 juillet 2003 - 4 avril 2002 à 15:20
salut !

bon, recement, j'ai posté un msg demandant comment faire plusieurs boites de dialog
(cf : plusieurs dialogs [API])

bon, comme dit, ca marche.

mais j'ai pas compris comment les faire comuniquer entres elles ?

vous me dite de fairemes propres message du style
#define WM_VALIDSONG WM_USER+1

puis de les envoyer avec SendMessage.

quelques petits trucs, cloches, enfin, j'ai pas compris :

1- pourquoi, a quoi ca sert, WM_USER+1
2- comment on utilise SendMessage (d'hab, j'utilise SetDlgItem ou GetDlGitem et pas les trucs a ralonge...)

PS : je tiens a preciser : mon prog est composé de 2 dialogs, celle de depart a un texte static avec pour Id : IDC_STATCONF

la deuxieme, elle a un bouton d'Id : "ID_BUTCONF".

quand j'appuie sur le bouton, je veux que le message "PRIS", apparaisse sur le bouton.

2 réponses

cs_Xs Messages postés 368 Date d'inscription mercredi 14 novembre 2001 Statut Membre Dernière intervention 1 septembre 2008
4 avril 2002 à 14:58
vala le code. en fait, c'est pas vraiment l'exemple decrit mais c'est similaire a l'exception que je dois reproduire ce code (que je cherche !) autant de faois qu'il y a de boutons, donc de variables bool....

code :

#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <commctrl.h>
#include "resource.h"

HMENU hMenu;

bool M110H11 = true;
bool M111H12 = true;
bool M112H13 = true;
bool M113H14 = true;
bool M114H15 = true;
bool M115H16 = true;
bool M116H17 = true;
bool M117H18 = true;
bool M118H19 = true;
bool M119H20 = true;
bool M210H11 = true;
bool M211H12 = true;
bool M212H13 = true;
bool M213H14 = true;
bool M214H15 = true;
bool M215H16 = true;
bool M216H17 = true;
bool M217H18 = true;
bool M218H19 = true;
bool M219H20 = true;
bool M310H11 = true;
bool M311H12 = true;
bool M312H13 = true;
bool M313H14 = true;
bool M314H15 = true;
bool M315H16 = true;
bool M316H17 = true;
bool M317H18 = true;
bool M318H19 = true;
bool M319H20 = true;
bool M410H11 = true;
bool M411H12 = true;
bool M412H13 = true;
bool M413H14 = true;
bool M414H15 = true;
bool M415H16 = true;
bool M416H17 = true;
bool M417H18 = true;
bool M418H19 = true;
bool M419H20 = true;
bool M510H11 = true;
bool M511H12 = true;
bool M512H13 = true;
bool M513H14 = true;
bool M514H15 = true;
bool M515H16 = true;
bool M516H17 = true;
bool M517H18 = true;
bool M518H19 = true;
bool M519H20 = true;
bool M610H11 = true;
bool M611H12 = true;
bool M612H13 = true;
bool M613H14 = true;
bool M614H15 = true;
bool M615H16 = true;
bool M616H17 = true;
bool M617H18 = true;
bool M618H19 = true;
bool M619H20 = true;
bool M710H11 = true;
bool M711H12 = true;
bool M712H13 = true;
bool M713H14 = true;
bool M714H15 = true;
bool M715H16 = true;
bool M716H17 = true;
bool M717H18 = true;
bool M718H19 = true;
bool M719H20 = true;
bool M810H11 = true;
bool M811H12 = true;
bool M812H13 = true;
bool M813H14 = true;
bool M814H15 = true;
bool M815H16 = true;
bool M816H17 = true;
bool M817H18 = true;
bool M818H19 = true;
bool M819H20 = true;
bool M910H11 = true;
bool M911H12 = true;
bool M912H13 = true;
bool M913H14 = true;
bool M914H15 = true;
bool M915H16 = true;
bool M916H17 = true;
bool M917H18 = true;
bool M918H19 = true;
bool M919H20 = true;
bool M1010H11 = true;
bool M1011H12 = true;
bool M1012H13 = true;
bool M1013H14 = true;
bool M1014H15 = true;
bool M1015H16 = true;
bool M1016H17 = true;
bool M1017H18 = true;
bool M1018H19 = true;
bool M1019H20 = true;

LRESULT CALLBACK addBProc(HWND addBDlg, UINT msg, WPARAM wParam, LPARAM lParam);

LRESULT CALLBACK addProc(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int nCmdShow;
switch(msg)
{
case WM_CLOSE:
EndDialog(hdlg,0);
break;
case WM_INITDIALOG:
SetWindowPos(hdlg,HWND_TOP,50,50,672,425,SWP_SHOWWINDOW);
break;
case WM_DESTROY:
EndDialog(hdlg,0);
break;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case BN_CLICKED:
switch(LOWORD(wParam))
{
case ID_PC6a10:
EndDialog(hdlg,0);
hdlg = CreateDialog(NULL,MAKEINTRESOURCE(IDD_ADD), NULL, (DLGPROC) addBProc);

EnableWindow(GetDlgItem(hdlg,ID_PC1a5), FALSE);

hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1));
SetMenu(hdlg,hMenu);

if(hdlg == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hdlg, nCmdShow);
UpdateWindow(hdlg);
break;
case ID_PC1a5:
MessageBox(NULL,"Je ne peux pas ouvrir cette fenetre :\n elle est déjà ouverte !","Erreur !",0+MB_ICONEXCLAMATION+MB_OK);
break;
/*---------------Ici, c'est quand on appuie sur le bouton qui doit configurer le static*/
case IDC_M110H11 :
{
if (M110H11== true)
{
M110H11 = false;
SetDlgItemText(hdlg,IDC_M110H11,"PRIS");
SendMessage(GetDlgItem(hdlg,IDC_M110H11),NULL,0,M110H11 = false);
}
else if (M110H11 == false)
{
M110H11 = true;
SetDlgItemText(hdlg,IDC_H10H11H_P1,"LIBRE");
SendMessage(GetDlgItem(hdlg,IDC_M110H11),NULL,0,M110H11 = true);
}
/*fin du code-prototype*/
}
break;
case IDC_M111H12 :
{
}
break;
case IDC_M113H14 :
{
}
break;
case IDC_M114H15 :
{
}
break;
case IDC_M115H16 :
{
}
break;
case IDC_M116H17 :
{
}
break;
case IDC_M117H18 :
{
}
break;
case IDC_M118H19 :
{
}
break;
case IDC_M119H20 :
{
}
break;
case IDC_M210H11 :
{
}
break;
case IDC_M211H12 :
{
}
break;
case IDC_M213H14 :
{
}
break;
case IDC_M214H15 :
{
}
break;
case IDC_M215H16 :
{
}
break;
case IDC_M216H17 :
{
}
break;
case IDC_M217H18 :
{
}
break;
case IDC_M218H19 :
{
}
break;
case IDC_M219H20 :
{
}
break;
case IDC_M310H11 :
{
}
break;
case IDC_M311H12 :
{
}
break;
case IDC_M313H14 :
{
}
break;
case IDC_M314H15 :
{
}
break;
case IDC_M315H16 :
{
}
break;
case IDC_M316H17 :
{
}
break;
case IDC_M317H18 :
{
}
break;
case IDC_M318H19 :
{
}
break;
case IDC_M319H20 :
{
}
break;
case IDC_M410H11 :
{
}
break;
case IDC_M411H12 :
{
}
break;
case IDC_M413H14 :
{
}
break;
case IDC_M414H15 :
{
}
break;
case IDC_M415H16 :
{
}
break;
case IDC_M416H17 :
{
}
break;
case IDC_M417H18 :
{
}
break;
case IDC_M418H19 :
{
}
break;
case IDC_M419H20 :
{
}
break;
case IDC_M510H11 :
{
}
break;
case IDC_M511H12 :
{
}
break;
case IDC_M513H14 :
{
}
break;
case IDC_M514H15 :
{
}
break;
case IDC_M515H16 :
{
}
break;
case IDC_M516H17 :
{
}
break;
case IDC_M517H18 :
{
}
break;
case IDC_M518H19 :
{
}
break;
case IDC_M519H20 :
{
}
break;
case IDCANCEL:
EndDialog(hdlg,0);
break;
}
}
break;
default:
return FALSE;
}
return FALSE;
}

LRESULT CALLBACK addBProc(HWND addBDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int nCmdShow;
switch(msg)
{
case WM_CLOSE:
EndDialog(addBDlg,0);
break;
case WM_INITDIALOG:
SetWindowPos(addBDlg,HWND_TOP,50,50,672,425,SWP_SHOWWINDOW);
break;
case WM_DESTROY:
EndDialog(addBDlg,0);
break;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case BN_CLICKED:
switch(LOWORD(wParam))
{
case ID_PC1a5:
EndDialog(addBDlg,0);
addBDlg = CreateDialog(NULL,MAKEINTRESOURCE(IDD_ADD), NULL, (DLGPROC) addProc);

EnableWindow(GetDlgItem(addBDlg,ID_PC1a5), FALSE);

hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1));
SetMenu(addBDlg,hMenu);

if(addBDlg == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(addBDlg, nCmdShow);
UpdateWindow(addBDlg);
break;
case ID_PC6a10:
MessageBox(NULL,"Je ne peux pas ouvrir cette fenetre :\n elle est déjà ouverte !","Erreur !",0+MB_ICONEXCLAMATION+MB_OK);
break;
case IDC_M610H11 :
{
}
break;
case IDC_M611H12 :
{
}
break;
case IDC_M613H14 :
{
}
break;
case IDC_M614H15 :
{
}
break;
case IDC_M615H16 :
{
}
break;
case IDC_M616H17 :
{
}
break;
case IDC_M617H18 :
{
}
break;
case IDC_M618H19 :
{
}
break;
case IDC_M619H20 :
{
}
break;
case IDC_M710H11 :
{
}
break;
case IDC_M711H12 :
{
}
break;
case IDC_M713H14 :
{
}
break;
case IDC_M714H15 :
{
}
break;
case IDC_M715H16 :
{
}
break;
case IDC_M716H17 :
{
}
break;
case IDC_M717H18 :
{
}
break;
case IDC_M718H19 :
{
}
break;
case IDC_M719H20 :
{
}
break;
case IDC_M810H11 :
{
}
break;
case IDC_M811H12 :
{
}
break;
case IDC_M813H14 :
{
}
break;
case IDC_M814H15 :
{
}
break;
case IDC_M815H16 :
{
}
break;
case IDC_M816H17 :
{
}
break;
case IDC_M817H18 :
{
}
break;
case IDC_M818H19 :
{
}
break;
case IDC_M819H20 :
{
}
break;
case IDC_M910H11 :
{
}
break;
case IDC_M911H12 :
{
}
break;
case IDC_M913H14 :
{
}
break;
case IDC_M914H15 :
{
}
break;
case IDC_M915H16 :
{
}
break;
case IDC_M916H17 :
{
}
break;
case IDC_M917H18 :
{
}
break;
case IDC_M918H19 :
{
}
break;
case IDC_M919H20 :
{
}
break;
case IDC_M1010H11 :
{
}
break;
case IDC_M1011H12 :
{
}
break;
case IDC_M1013H14 :
{
}
break;
case IDC_M1014H15 :
{
}
break;
case IDC_M1015H16 :
{
}
break;
case IDC_M1016H17 :
{
}
break;
case IDC_M1017H18 :
{
}
break;
case IDC_M1018H19 :
{
}
break;
case IDC_M1019H20 :
{
}
break;

case IDCANCEL:
EndDialog(addBDlg,0);
break;
}
}
break;
default:
return FALSE;
}
return FALSE;
}

LRESULT CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
int nCmdShow;
switch(msg)
{
case WM_CLOSE:
DestroyWindow(hDlg);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case BN_CLICKED:
switch(LOWORD(wParam))
{
case ID_PC1a5:
{

hDlg = CreateDialog(NULL,MAKEINTRESOURCE(IDD_ADD), NULL, (DLGPROC) addProc);

EnableWindow(GetDlgItem(hDlg,ID_PC1a5), FALSE);

hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1));
SetMenu(hDlg,hMenu);

if(hDlg == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hDlg, nCmdShow);
UpdateWindow(hDlg);
/*--------------Endroit ou le message doit etre recuperé, enfin, je pense....*/
if (M110H11 == true)
{
SetDlgItemText(hDlg,IDC_H10H11H_P1,"PRIS");
M110H11 = false;
}
else if (M110H11 == false)
{
SetDlgItemText(hDlg,IDC_H10H11H_P1,"LIBRE");
M110H11 = false;
}
}
break;
/*fin*/
case ID_PC6a10:
{

hDlg = CreateDialog(NULL,MAKEINTRESOURCE(IDD_ADDB), NULL, (DLGPROC) addBProc);

EnableWindow(GetDlgItem(hDlg,ID_PC6a10), FALSE);

hMenu = LoadMenu(NULL,MAKEINTRESOURCE(IDR_MENU1));
SetMenu(hDlg,hMenu);

if(hDlg == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hDlg, nCmdShow);
UpdateWindow(hDlg);
}
break;
case IDCANCEL:
DestroyWindow(hDlg);
break;
}
}
break;
default:
return FALSE;
}
return FALSE;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine,int nCmdShow)
{
HWND hdlg;
MSG Msg;

hdlg = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_DIALOG), NULL, (DLGPROC) DlgProc);

InitCommonControls();

hMenu = LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU1));
SetMenu(hdlg,hMenu);

if(hdlg == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}

ShowWindow(hdlg, nCmdShow);
UpdateWindow(hdlg);

while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
0
mmuller57 Messages postés 174 Date d'inscription mardi 10 avril 2001 Statut Membre Dernière intervention 30 juillet 2003 1
4 avril 2002 à 15:20
Voila ce que dis la documentation sur les API, je pense que tu en a une non ? :

The WM_USER constant is used by applications to help define private messages.

WM_USER


Remarks

The WM_USER constant is used to distinguish between message values that are reserved for use by Windows and values that can be used by an application to send messages within a private window class. There are five ranges of message numbers:

Range Meaning
0 through WM_USER - 1 Messages reserved for use by Windows.
WM_USER through 0x7FFF Integer messages for use by private window classes.
0x8000 through 0xBFFF Messages reserved for future use by Windows.
0xC000 through 0xFFFF String messages for use by applications.
Greater than 0xFFFF Reserved by Windows for future use.
Message numbers in the first range (0 through WM_USER - 1) are defined by Windows. Values in this range that are not explicitly defined are reserved for future use by Windows.
Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class. These values cannot be used to define messages that are meaningful throughout an application, because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. Messages in this range should not be sent to other applications unless the applications have been designed to exchange messages and to attach the same meaning to the message numbers.

Message numbers in the third range (0x8000 through 0xBFFF) are reserved for future use by Windows.
Message numbers in the fourth range (0xC000 through 0xFFFF) are defined at run time when an application calls the RegisterWindowMessage function to retrieve a message number for a string. All applications that register the same string can use the associated message number for exchanging messages. The actual message number, however, is not a constant and cannot be assumed to be the same between different Windows sessions.

Message numbers in the fifth range (greater than 0xFFFF) are reserved for future use by Windows.

Voila si t'as toujours pas compris contacte moi ! @+
0
Rejoignez-nous