|
-
March 29th, 2004, 02:59 AM
#1
WM_COMMAND blocks WM_KEYDOWN
Hi
I've created a window whith click events key events and buttons.
It happens that, when i click on a button the event WM_KEYDOWN doesn't work at all. Why????
I post the code of the window.
LRESULT CALLBACK FTEPROC(HWND hWndDlg, UINT Message, WPARAM wParam, LPARAM lParam)
{
PAINTSTRUCT ps;
char bu[40];
HWND hele;
int i,meseoggi;
POINT posclick;
SYSTEMTIME data_sys;
switch(Message)
{
case WM_DRAWITEM:
DrawControl(hWndDlg, (LPDRAWITEMSTRUCT)lParam);
return( DefWindowProc( hWndDlg, Message, wParam, lParam ));
break;
case WM_CREATE :
hFntpre=CreateFont(-20,9,0,0,600,0,0,0,0,3,2,1,2,"Lucida Sans Typewriter");
MESE_CUR = 0;
disp_assunti = 0; //di default visualizza i dimessi
CreateWindow("Button",
"",
BS_OWNERDRAW |
WS_VISIBLE |
WS_CHILD ,
10,
705,
120,
50,
hWndDlg,
(HMENU)ESCI,
hInst,
0);
CreateWindow("Button",
"",
BS_OWNERDRAW |
WS_VISIBLE |
WS_CHILD ,
120,
705,
120,
50,
hWndDlg,
(HMENU)EXPORT,
hInst,
0);
//lettura dei file fte e caricamento nella struttura
leggifte(MESE_CUR);
//funzione di inizializzazione dei rettangoli
//contenenti i dati della tabella
inizializza_rett_FTE();
inizializza_rett_FTE_dim();
inizializza_rett_FTE_***();
return 0L;
case WM_PAINT:
memset(&ps, 0x00, sizeof(PAINTSTRUCT));
dc = BeginPaint(hWndDlg, &ps);
//background
GetClientRect(hWndDlg,&rect);
FillRect(dc,&rect,hBr0);
disegna_schedario(dc);
SetBkMode(dc, TRANSPARENT);
SelectObject(dc,hFntcog);
SetTextColor(dc,RGB(255,205,0));
SetTextAlign(dc,TA_CENTER);
sprintf(bu,"%s","Organico");
TextOut(dc,510,10,bu,strlen(bu));
DisegnaFTE(hWndDlg,dc);
//dimessi o assunti
if(disp_assunti==0)
stampafte(dc);
else{
stampafte_***(dc);
stampafte_dim(dc);
}
tab_fte(dc);
return 0L;
//EndPaint(hWndDlg, &ps);
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ESCI:
hMnu= CreateWindow(
"MENU",
"HRA",
WS_POPUP ,
40+LVID,280+HVID,
280,420,
hWndDlg,
0,
hInst,
0);
CURME=7;
hWndM=hWndDlg;
EnableWindow(hWndDlg,FALSE);
ShowWindow(hMnu,SW_NORMAL);
SetFocus(hMnu);
return 0;
case EXPORT:
fte_excel();
return 0;
}
break;
case WM_LBUTTONDOWN:
posclick.x = LOWORD(lParam);
posclick.y = HIWORD(lParam);
if(PtInRect(&rect_tab[0],posclick) || PtInRect(&rect_tab[1],posclick))
{
InvalidateRect(hWndDlg,&rect_tab[0],TRUE);
InvalidateRect(hWndDlg,&rect_tab[1],TRUE);
if (disp_assunti == 1)
disp_assunti = 0;
else
disp_assunti = 1;
SetRect(&rect,80,130,976,768);
InvalidateRect(hWndDlg,&rect,TRUE);
}
if(PtInRect(&rect_tab[2],posclick))
{
fte_excel();
}
for(i=0;i<13;i++)
{
if(PtInRect(&rect_mesi[i],posclick))
{
if(mesistorico[i] == 1)
{
MESE_CUR = i;
leggifte(i);
SetRect(&rect,10,10,976,700);
InvalidateRect(hWndDlg,&rect,TRUE);
}
}
}
return 0L;
break;
case WM_RBUTTONDOWN:
GetSystemTime(&data_sys);
meseoggi = data_sys.wMonth;
if(MESE_CUR == 0 || MESE_CUR == meseoggi)
{
if(display_dipendenti(lParam))
{
LELE=0;
for (i=0; i<NCOLE; i++)
LELE+=ncar[ncamp[i]]*9+9;
if (LELE+44 < 410)
i=410;
else
i=LELE+44;
hele= CreateWindow(
"ELENCHI",
"HRA",
WS_POPUP| WS_VISIBLE,
20,30,
i,
703,
hWndDlg,
0,
hInst,
0);
EnableWindow(hWndDlg,FALSE);
SetFocus(hEle);
}
}
break;
case WM_MOUSEMOVE:
posclick.x = LOWORD(lParam);
posclick.y = HIWORD(lParam);
if(PtInRect(&rect_tab[0],posclick) || PtInRect(&rect_tab[1],posclick))
{
SetCursor(hMano);
break;
}
else
SetCursor(hStand);
if(disp_assunti == 0)
{
if(posclick.x >= 80 && posclick.x <= 528 && posclick.y >= 175 && posclick.y <= 665)
{
SetCursor(hMano);
break;
}
else
SetCursor(hStand);
}
else
{
if(posclick.x >= 80 && posclick.x <= 975 && posclick.y >= 175 && posclick.y <= 665)
{
SetCursor(hMano);
break;
}
else
SetCursor(hStand);
}
for(i=0;i<13;i++)
{
if(PtInRect(&rect_mesi[i],posclick))
{
SetCursor(hMano);
}
}
return 0L;
break;
case WM_CLOSE:
DestroyWindow(hWndDlg);
return(0);
case WM_KEYDOWN:
switch(wParam)
{
case VK_ESCAPE:
CURME=0;
hInd = CreateWindow(
"ANAGRAFICA",
"HRA",
WS_POPUP | WS_VISIBLE,
LVID,HVID,
1024,768,
0,
0,
hInst,
0);
PostMessage(hWndDlg,WM_CLOSE,0,0);
SetFocus(hInd);
break;
case VK_TAB:
SetRect(&rect,80,130,976,768);
InvalidateRect(hWndDlg,&rect,TRUE);
InvalidateRect(hWndDlg,&rect_tab[0],TRUE);
InvalidateRect(hWndDlg,&rect_tab[1],TRUE);
if(disp_assunti == 0)
disp_assunti = 1;
else
disp_assunti = 0;
tab_fte(hdc);
break;
}
break;
default:
return( DefWindowProc( hWndDlg, Message, wParam, lParam ));
}
return 0L;
}
Thanks.....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|