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
|
LRESULT CALLBACK msgProcess(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND hEdit;
static HDC hdcEdit;
switch(msg)
{
//message perso demandant la mise a jour du texte du controle EDIT
case WM_SET_TEXT:
//message avec argument texte NULL, on reset le contenu du label
if (lParam == (LPARAM)NULL)
{
SetWindowText(hEdit, "");
}
//sinon on ajoute le message a la suite du contenu du label
else
{
long int mallocSize = 0;
char* szDebug = NULL;
COLORREF color;
//calcul de la taille de la memoire a allouer
mallocSize = GetWindowTextLength(hEdit);
mallocSize += strlen((char*)lParam) + 1;
szDebug = malloc(mallocSize);
GetWindowText(hEdit, szDebug, mallocSize);
sprintf(szDebug, "%s%s", szDebug, (char*)lParam);
printf("hdc : %x\n",hdcEdit);
SetTextColor(hdcEdit, RGB(0,0,255));
SetWindowText(hEdit, szDebug);
free(szDebug);
}
break;
//message informant de la creation de la fenetre parente
case WM_CREATE:
//creation du controle EDIT contenant les informations de debug
hEdit = CreateWindow("EDIT",
"",
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, WIN_WIDTH-12, WIN_HEIGHT,
hwnd, NULL,
(HINSTANCE)GetModuleHandle(NULL),
NULL);
//recuperation du HDC associe au controle que l'on vient de creer
hdcEdit = GetDC(hEdit);
break; |
Partager