, : "KeyLook",

̳

ϲ-40

5

KeyLock"

,

2011 .


 

, :

Massege Key Char Repeat Scan Ext Alt Prev Tran

,

#nclude <wndows.h>

#nclude <stdo.h>

LRESULT CALLBACK WndProc (HWND, UNT, WPARAM, LPARAM) ; //

RECT rect ; // Rect, 볺

nt cxChar, cyChar ; //cxChar , cyChar

nt WNAP WnMan (HNSTANCE hnstance, HNSTANCE hPrevnstance,

PSTR szCmdLne, nt CmdShow)

{

statc char szAppName[] = "KeyLook" ;

HWND hwnd ; //

MSG msg ; //

WNDCLASSEX wndclass ; //


wndclass.cbSze = szeof (wndclass) ; //

wndclass.style = CS_HREDRAW | CS_VREDRAW ; //

wndclass.lpfnWndProc = WndProc ; //

wndclass.cbClsExtra = 0 ; // .

wndclass.cbWndExtra = 0 ; // .

wndclass.hnstance = hnstance ; //

wndclass.hcon = Loadcon (NULL, D_APPLCATON) ; //

wndclass.hCursor = LoadCursor (NULL, DC_ARROW) ; //

wndclass.hbrBackground = (HBRUSH) GetStockObject (WHTE_BRUSH) ; // .


wndclass.lpszMenuName = NULL ; //

wndclass.lpszClassName = szAppName ; //

wndclass.hconSm = Loadcon (NULL, D_APPLCATON) ; // 󠠠

RegsterClassEx (&wndclass) ; //

hwnd = CreateWndow//

(szAppName, //

" Keyboard Message Looker ", //

WS_OVERLAPPEDWNDOW, //

CW_USEDEFAULT, //

CW_USEDEFAULT, //

CW_USEDEFAULT, //

CW_USEDEFAULT, //

NULL, //

NULL, //

hnstance, //

NULL) ; //

ShowWndow (hwnd, CmdShow) ; //

UpdateWndow (hwnd) ; // .


whle (GetMessage (&msg, NULL, 0, 0)) //

WM_QUT // 

{

TranslateMessage (&msg) ; // msg Wndows ,

DspatchMessage (&msg) ; //

}

return msg.wParam ;

}

vod ShowKey (HWND hwnd, nt Type, char *szMessage,

WPARAM wParam, LPARAM lParam) //

{

//

statc char *szFormat[2] = { "%-14s %3d %c %6u %4d %3s %3s %4s %4s",

"%-14s %3d %c %6u %4d %3s %3s %4s %4s" } ;

char szBuffer[80] ;

HDC hdc ; //

//

ScrollWndow (hwnd, 0, -cyChar, &rect, &rect) ;

//

hdc = GetDC (hwnd) ;

//

SelectObject (hdc, GetStockObject (SYSTEM_FXED_FONT)) ;

// .

TextOut (hdc, cxChar, rect.bottom - cyChar, szBuffer,

wsprntf (szBuffer, szFormat [Type],

szMessage, wParam,

(BYTE) (Type ? wParam : ' '),

LOWORD (lParam), //

HWORD (lParam) & 0xFF, //

(PSTR) (0x01000000 & lParam ? "Yes" : "No"), // .

(PSTR) (0x20000000 & lParam ? "Yes" : "No"), // Alt

(PSTR) (0x40000000 & lParam ? "Down" : "Up"), //

(PSTR) (0x80000000 & lParam ? "Up" : "Down"))) ; //

ReleaseDC (hwnd, hdc) ; //

ValdateRect (hwnd, NULL) ; //,

}


LRESULT CALLBACK WndProc (HWND hwnd, UNT Msg, WPARAM wParam, LPARAM lParam)

{

// ,

statc char szTop[] =

"Message Key Char Repeat Scan Ext ALT Prev Tran";

statc char szUnd[] =

"_______ ___ ____ ______ ____ ___ ___ ____ ____";

HDC hdc ; //

PANTSTRUCT ps ;

TEXTMETRC tm ; //

swtch (Msg)

{

case WM_CREATE : //

//

hdc = GetDC (hwnd) ;

//

SelectObject (hdc, GetStockObject (SYSTEM_FXED_FONT)) ;

//

GetTextMetrcs (hdc, &tm) ;

cxChar = tm.tmAveCharWdth ;

cyChar = tm.tmHeght ;


//

ReleaseDC (hwnd, hdc) ;

rect.top = 3 * cyChar / 2 ;

return 0 ;

case WM_SZE : //

rect.rght = LOWORD (lParam) ; //

rect.bottom = HWORD (lParam) ;

UpdateWndow (hwnd) ; // .

return 0 ;

case WM_PANT : /*  */

//,

nvaldateRect (hwnd, NULL, TRUE) ;

//

hdc = BegnPant (hwnd, &ps) ;

//

SelectObject (hdc, GetStockObject (SYSTEM_FXED_FONT)) ;

//.

SetBkMode (hdc, TRANSPARENT) ;

//

TextOut (hdc, cxChar, cyChar / 2, szTop, (szeof szTop) - 1) ;

TextOut (hdc, cxChar, cyChar / 2, szUnd, (szeof szUnd) - 1) ;

//

EndPant (hwnd, &ps) ;

return 0 ;

case WM_KEYDOWN : //

// .

ShowKey (hwnd, 0, "WM_KEYDOWN", wParam, lParam) ;

return 0 ;

case WM_KEYUP : //

// .

ShowKey (hwnd, 0, "WM_KEYUP", wParam, lParam) ;

return 0 ;

case WM_CHAR : // .

// .

ShowKey (hwnd, 1, "WM_CHAR", wParam, lParam) ;

return 0 ;

case WM_DEADCHAR : //

ShowKey (hwnd, 1, "WM_DEADCHAR", wParam, lParam) ;

return 0 ;

case WM_SYSKEYDOWN : // <ALT>

ShowKey (hwnd, 0, "WM_SYSKEYDOWN", wParam, lParam) ;

break ; // e, call DefWndowProc

case WM_SYSKEYUP :

ShowKey (hwnd, 0, "WM_SYSKEYUP", wParam, lParam) ;

break ; // e, call DefWndowProc //

case WM_SYSCHAR : // <ALT> + < >

ShowKey (hwnd, 1, "WM_SYSCHAR", wParam, lParam) ;

break ; // e, call DefWndowProc //

case WM_SYSDEADCHAR : // <Alt>

ShowKey (hwnd, 1, "WM_SYSDEADCHAR", wParam, lParam) ;

break ; // e, call DefWndowProc

case WM_DESTROY : /* WM_QUT */

PostQutMessage (0) ;

return 0 ;

}

/* ,

return DefWndowProc (hwnd, Msg, wParam, lParam) ;

 


,


, :


 
 
 
 
 
. , . , .
 
 
  
  
   
 
 
bigmir)net TOP 100