0000:00404A44 sub_404A44 proc near
0000:00404A44
0000:00404A44 Paint = PAINTSTRUCT ptr -4Ch
0000:00404A44 wParam = dword ptr -0Ch //这里看起来是个callback的参数,但实际上是一个HFONT。这从下面对
//WM_INITDIALOG的分析可以看到。
0000:00404A44 pt = POINT ptr -8
0000:00404A44 hWnd = dword ptr 8
0000:00404A44 arg_4 = dword ptr 0Ch
0000:00404A44 arg_8 = dword ptr 10h
0000:00404A44 arg_C = word ptr 14h
0000:00404A44
0000:00404A44 push ebp
0000:00404A45 mov ebp, esp
0000:00404A47 add esp, 0FFFFFFB4h
0000:00404A4A push ebx
0000:00404A4B push esi
0000:00404A4C push edi
0000:00404A4D mov esi, [ebp+hWnd]
0000:00404A50 xor ebx, ebx
0000:00404A52 mov eax, [ebp+arg_4]
0000:00404A55 cmp eax, 133h ; WM_CTLCOLOREDIT
0000:00404A5A jg short loc_404A87
0000:00404A5C jz loc_404CB3
0000:00404A62 sub eax, 0Fh ; WM_PAINT
0000:00404A65 jz loc_404BD6
0000:00404A6B sub eax, 1Ch ; WM_DRAWITEM
0000:00404A6E jz loc_404C86
0000:00404A74 sub eax, 0E5h ; WM_INITDIALOG
0000:00404A79 jz short loc_404AAB
0000:00404A7B dec eax ; WM_COMMAND
0000:00404A7C jz loc_404C0B
0000:00404A82 jmp loc_404CF5
0000:00404A87 loc_404A87:
0000:00404A87 sub eax, 136h ; WM_CTLCOLORDLG
0000:00404A8C jz loc_404C92
0000:00404A92 sub eax, 2 ; WM_CTLCOLORSTATIC
0000:00404A95 jz loc_404CD4
0000:00404A9B sub eax, 0C9h ; WM_LBUTTONDOWN
0000:00404AA0 jz loc_404B95
0000:00404AA6 jmp loc_404CF5
0000:00404CF5 loc_404CF5:
0000:00404CF5 xor ebx, ebx
0000:00404CF7 loc_404CF7:
0000:00404CF7 mov eax, ebx
0000:00404CF9 pop edi
0000:00404CFA pop esi
0000:00404CFB pop ebx
0000:00404CFC mov esp, ebp
0000:00404CFE pop ebp
0000:00404CFF retn 10h
0000:00404CFF sub_404A44 endp
于是有:
Function MainProc(hDlg:HWND;Msg,wParam,lParam:DWORD):LRESULT;stdcall;
Var
sPaint:PAINTSTRUCT;
sPoint:TPoint;
LFont:HFONT;
Begin
Result:=0;
Case Msg of
WM_COMMAND:
Begin
End;
WM_PAINT:
Begin
End;
WM_DRAWITEM:
Begin
End;
WM_INITDIALOG:
Begin
End;
WM_CTLCOLORDLG:
Begin
End;
WM_CTLCOLORSTATIC:
Begin
End;
WM_LBUTTONDOWN:
Begin
End;
WM_CTLCOLOREDIT:
Begin
End;
End;
End;
WM_CTLCOLOREDIT:
Begin
SetTextColor(wParam,$A0A0A0);
SetBkMode(wParam,TRANSPARENT);
Result:=h_Brush;
End;
WM_PAINT:
Begin
Paint(BeginPaint(hDlg,sPaint),h_Icon,szMainCaption,$767676,0,sRECTM);
EndPaint(hDlg,sPaint);
End;
WM_DRAWITEM:
Begin
ItemDraw(PDrawItemStruct(lParam));
Result:=0;
End;
WM_CTLCOLORDLG:
Begin
SetTextColor(wParam,$A0A0A0);
SetBkMode(wParam,TRANSPARENT);
Result:=h_Brush;
End;
WM_CTLCOLORSTATIC:
Begin
SetTextColor(wParam,$A0A0A0);
SetBkMode(wParam,TRANSPARENT);
Result:=h_Brush;
End;
WM_LBUTTONDOWN:
Begin
sPoint.x:=lParam AND $FFFF;
sPoint.y:=lParam SHR 16;
If PtInRect(sRectM,sPoint) Then
Begin
PostMessage(hDlg,WM_NCLBUTTONDOWN,2,0);
End;
End;
WM_COMMAND:
Begin
Case wParam of
MAIN_CALC:
Begin
GetDlgItemText(hDlg,$7DA,@RegName,255);
GetRegCode;
SetDlgItemText(hDlg,$7D9,@RegCode);
End;
MAIN_EXIT:
Begin
EndDialog(hDlg,0);
End;
MAIN_ABOUT:
Begin
MessageBeep(0);
DialogBox(h_Inst,LPCTSTR(IDD_ABOUTDLG),0,@AboutProc);
End;
MAIN_CLOSE:
Begin
EndDialog(hDlg,0);
End;
End;
End;
Function LinkProc(hDlg:HWND;Msg,wParam,lParam:DWORD):LRESULT;stdcall;
Begin
Result:=1;
Case Msg of
WM_SETCURSOR:
Begin
SetCursor(h_Cur);
End;
WM_NCHITTEST:
Begin
Result:=1;
End;
WM_LBUTTONUP:
Begin
ShellExecute(0,nil,szLink,nil,nil,0);//偷了点懒
End;
Else
Begin
CallWindowProc(Pointer(GetWindowLong(hDlg,GWL_USERDATA)),hDlg,Msg,wParam,lParam);
End;
End;
End;
Case wParam AND $FFFF of
$7DA://就是RegName的ID,感觉越来越懒了……
Begin
Case wParam SHR 16 of
EN_CHANGE:
Begin
GetDlgItemText(hDlg,$7DA,@RegName,255);
GetRegCode;
SetDlgItemText(hDlg,$7D9,@RegCode);
End;
End;
End;
End;
==========================================================================
$7DA://就是RegName的ID
Begin
Case wParam SHR 16 of
EN_CHANGE:
Begin
GetDlgItemText(hDlg,$7DA,@RegName,255);
GetRegCode;
SetDlgItemText(hDlg,$7D9,@RegCode);
End;
End;
End;