function GetWinText(AWin: Thandle): string;
var
ResultStr: String;
begin
SetLength(ResultStr, GetWindowTextLength(AWin));
GetWindowText(AWin,@ResultStr[1],Length(ResultStr)+1);
Result := ResultStr;
ResultStr := '';
end;
function MessageFunc(hWnd, Msg, wParam, lParam: integer): integer; stdcall;
begin
case Msg of
$0111 :
begin
if ((wParam and $FFFF) = 1) then
begin
MessageBox(hwndMain,':)','xx',MB_OK);
end;
end;
$0002 : PostQuitMessage(0);
end;
result:=DefWindowProc(hWnd, Msg, wParam, lParam);
end;
function NewBtnWndProc(hWin: HWND; uMsg: word; wParam: WPARAM;
lParam: LPARAM):DWORD; stdcall;
var
memDC: HDC;
Rect: TRect;
Pt: TPoint;
ps: TPaintStruct;
WndHdc: HDC;
begin
case uMsg of
WM_Paint, WM_ERASEBKGND, WM_CAPTURECHANGED, WM_SETFOCUS, WM_KILLFOCUS, WM_MOUSEACTIVATE:
begin
if uMsg = WM_PAINT then
WndHdc := BeginPaint(hWin, ps);
GetClientRect(hWin, rect);
if not ((uMsg = WM_PAINT) or (uMsg = WM_ERASEBKGND)) then
InvalidateRect(hWin, @rect, True);
//边框
FillRect(wParam, rect, CreateSolidBrush($00FF0000));
//背景
InflateRect(Rect,-1,-1);
FillRect(wParam, rect, CreateSolidBrush($0));
//文字
InflateRect(Rect,-1,-1);
SetBtnMemDCText(wParam,Rect,GetWinText(hWin));
Result := 1;
if uMsg = WM_PAINT then
EndPaint(hWin, ps);
exit;
end;
end;
Result := CallWindowProc(OldBtnWndProc, hWin, uMsg, wParam, lParam);
end;