Bonjour,
pour crée un client socket avec une intreface windows j'ai crée une class WindowClient dont voici le 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
 
#include <windows.h>
 
#define WCICON 1
#define WCMENU 2
 
class WindowClient
{
	public :
		bool CreateWindowClient(HWND,int);
		LRESULT CALLBACK WindowClientProc(HWND ,UINT ,WPARAM ,LPARAM );
	private :
		HWND hdWindow,hdEditSend,hdEditRecv,hdButton;
		HINSTANCE hInstance;
	protected :
};
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
 
#include "WindowClient.h"
#include <iostream>
 
using namespace std;
 
bool WindowClient::CreateWindowClient(HWND WinPar,int visible)
{
	hInstance =(HINSTANCE) GetWindowLong(WinPar,GWL_HINSTANCE);
 
	WNDCLASSEX wmclCClient;
	wmclCClient.cbSize = sizeof(WNDCLASSEX);
	wmclCClient.style = 0;
	wmclCClient.lpfnWndProc=WindowClientProc;
	wmclCClient.cbClsExtra = 0;
	wmclCClient.cbWndExtra = 0;
	wmclCClient.hInstance= hInstance;
	wmclCClient.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(WCICON) );
	wmclCClient.hCursor = NULL;
	wmclCClient.hbrBackground = GetSysColorBrush(15) ;
	wmclCClient.lpszMenuName = MAKEINTRESOURCE(WCMENU);
	wmclCClient.lpszClassName = "WindowClientClass";
	wmclCClient.hIconSm = NULL;
	if(!RegisterClassEx(&wmclCClient))
		return 0;
 
	hdWindow = CreateWindowEx(0,
				"WindowClientClass",
				"Client",
				WS_OVERLAPPEDWINDOW,
				GetSystemMetrics(SM_CXSCREEN)/4,
				GetSystemMetrics(SM_CYSCREEN)/4,
				GetSystemMetrics(SM_CXSCREEN)/2,
				GetSystemMetrics(SM_CYSCREEN)/2,
				WinPar,
				NULL,
				hInstance, 
				NULL);
	if(hdWindow==NULL)
		return 0;
	ShowWindow(hdWindow, visible);
	return 1;
}
 
WNDPROC OrigEditSendProc;
LRESULT CALLBACK EditSendProc (HWND , UINT , WPARAM , LPARAM );
 
LRESULT CALLBACK WindowClient::WindowClientProc(HWND hClient, UINT msgClient, WPARAM wParam, LPARAM lParam)
{
	switch(msgClient)
	{
		case WM_CREATE :
		{
			NOTIFYICONDATA nid;
			RECT rcClient;
			GetClientRect (hClient, &rcClient);
			hdEditRecv = CreateWindowEx(0,
				"EDIT",
				"",
				WS_VISIBLE|WS_CHILD|ES_MULTILINE|WS_VSCROLL,
				rcClient.left+10,
				rcClient.top+10,
				rcClient.right-20,
				rcClient.bottom-110,
				hClient,
				NULL,
				hInstance,
				NULL);
			if(hdEditRecv==NULL)
				return 0;
			hdEditSend = CreateWindowEx(0,
				"EDIT",
				"",
				WS_VISIBLE|WS_CHILD|ES_MULTILINE|WS_VSCROLL,
				rcClient.left+10,
				rcClient.bottom-60,
				rcClient.right-80,
				50,
				hClient,
				NULL,
				hInstance,
				NULL);
			if(hdEditSend==NULL)
				return 0;
			OrigEditSendProc = (WNDPROC)SetWindowLong(hdEditSend,GWL_WNDPROC, (LONG)EditSendProc);
			hdButton = CreateWindowEx(0,
				"BUTTON",
				"OK",
				WS_VISIBLE|WS_CHILD,
				rcClient.right-60,
				rcClient.bottom-60,
				50,
				50,
				hClient,
				NULL,
				hInstance,
				NULL);
			if(hdButton==NULL)
				return 0;
			EnableWindow(hdButton,false);
			break;
		}
		case WM_COMMAND :
			switch(HIWORD(wParam))
			{
				case BN_CLICKED :
				{	//(HWND)lParam HANDLE TO THE BUTTON
					char* buffer=new char[GetWindowTextLength(hdEditSend)+1];
					GetWindowText(hdEditSend,buffer,GetWindowTextLength(hdEditSend)+1);
					SetWindowText(hdEditRecv,buffer);
					delete[] buffer;
					while(HIWORD(SendMessage(hdEditRecv,EM_SCROLL,SB_PAGEDOWN,0)));
				}
					break;
				case EN_CHANGE :
					if (hdEditSend==(HWND)lParam)
						if (GetWindowTextLength(hdEditSend)>0)
							EnableWindow(hdButton,true);
						else
							EnableWindow(hdButton,false);
					break;
			}
		case WM_CHAR :
			if(wParam == 27)
				SendMessage(hClient,WM_CLOSE,0,0);
			break;
		case WM_SIZE :
		{
			RECT rcClient;
			GetClientRect (hClient, &rcClient);
			MoveWindow(hdEditRecv,rcClient.left+10,
								rcClient.top+10,
								rcClient.right-rcClient.left-20,
								rcClient.bottom-rcClient.top-110,true);
			MoveWindow(hdEditSend,rcClient.left+10,
								rcClient.bottom-60,
								rcClient.right-rcClient.left-80,
								50,true);
			MoveWindow(hdButton,rcClient.right-60,
								rcClient.bottom-60,
								50,
								50,true);
			break;
		}
		case WM_CLOSE :
			break;
		case WM_DESTROY :
			break;
		default: // Messages non gérés
			return DefWindowProc(hClient, msgClient, wParam, lParam);
	}
}
 
LRESULT CALLBACK EditSendProc(HWND hEdit, UINT msgEdit, WPARAM wParam, LPARAM lParam)
{
	if (msgEdit == WM_CHAR)
	{
		cout<<wParam<<endl;
	}
	return CallWindowProc(OrigEditSendProc, hEdit, msgEdit, wParam, lParam);
}
a la compilation avec Dev-C++ j'obtien l'erreur suivante :
argument of type `LRESULT (WindowClient:(HWND__*, UINT, WPARAM, LPARAM)' does not match `LRESULT (*)(HWND__*, UINT, WPARAM, LPARAM)'

cependant cela devrait marché (enfin je veux)

ou quand le met
static LRESULT CALLBACK WindowClientProc(HWND ,UINT ,WPARAM ,LPARAM );

je ne peux pas utiliser les diffèrentes variable HWND et HINSTANCE
je prefert mettre static car c'est un callback et que c'est pas utile de le recée a chaque fois !

Si quelqu'un peu m'aider j'en serai ravi
Merci