Пользователь
Сообщения: 78
Благодарности: 63
|
Профиль
|
Отправить PM
| Цитировать
Johny777, я думаю, ты понимаешь, что используя DrawFrameControl, форма будет иметь до XP'шный стиль.
читать дальше »
Код: 
[Setup]
AppName=MyApp
AppVerName=MyApp
DefaultDirname={pf}\MyApp
[Code]
#ifdef UNICODE
#define A "W"
type
PChar = PAnsiChar;
#else
#define A "A"
#endif
const
GWL_WNDPROC = -4;
DFC_CAPTION = 1;
DFCS_CAPTIONMIN = 1;
DFCS_PUSHED = $200;
WM_SETFOCUS = $0007;
WM_NCLBUTTONDOWN = $00A1;
WM_NCLBUTTONUP = $00A2;
WM_NCACTIVATE = $0086;
WM_NCCALCSIZE = $0083;
WM_NCPAINT = $0085;
WM_ACTIVATE = $0006;
WM_WINDOWPOSCHANGING = $0046;
WA_INACTIVE = 0;
type
LPARAM = Integer;
WPARAM = Integer;
LRESULT = Integer;
TFNWndProc = Integer;
HDC = LongWord;
SHORT = Longint;
var
OldWindowProc: Longint;
myPoint: TPoint;
myRect: TRect;
myDC: HDC;
function SetWindowLong(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint;
external 'SetWindowLong{#A}@user32.dll stdcall';
function CallWindowProc(lpPrevWndFunc: TFNWndProc; hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
external 'CallWindowProc{#A}@user32.dll stdcall';
function GetCursorPos(var lpPoint: TPoint): BOOL;
external 'GetCursorPos@user32.dll stdcall';
function GetWindowDC(hWnd: HWND): HDC;
external 'GetWindowDC@user32.dll stdcall';
function ReleaseDC(hWnd: HWND; hDC: HDC): Integer;
external 'ReleaseDC@user32.dll stdcall';
function DrawFrameControl(DC: HDC; const Rect: TRect; uType, uState: UINT): BOOL;
external 'DrawFrameControl@user32.dll stdcall';
procedure DrawButton(State: Cardinal);
begin
myRect.Left := WizardForm.Width - ScaleX(46);
myRect.Right := WizardForm.Width - ScaleX(27);
myRect.Top := ScaleY(5);
myRect.Bottom := ScaleY(22);
myDC := GetWindowDC(WizardForm.Handle);
try
DrawFrameControl(myDC, myRect, DFC_CAPTION , DFCS_CAPTIONMIN or State);
finally
ReleaseDC(WizardForm.Handle, myDC);
end;
end;
function PointIntoRect: boolean;
var
myPoint: TPoint;
begin
GetCursorPos(myPoint);
Result :=
(myPoint.X - WizardForm.Left >= WizardForm.Width - ScaleX(46)) and
(myPoint.X - WizardForm.Left <= WizardForm.Width - ScaleX(27)) and
(myPoint.Y - WizardForm.Top >= ScaleY(5)) and
(myPoint.Y - WizardForm.Top <= ScaleY(22));
end;
function WindowProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT;
begin
case Msg of
WM_NCACTIVATE, WM_NCCALCSIZE, WM_ACTIVATE, WM_NCPAINT, WM_WINDOWPOSCHANGING, WM_SETFOCUS: DrawButton(0);
//WM_NCLBUTTONDOWN: if PointIntoRect then DrawButton(DFCS_Pushed); //состояние нажатия кнопки;
WM_NCLBUTTONDOWN: if PointIntoRect then Application.Minimize;
end;
if wParam = WA_INACTIVE then DrawButton(0);
Result := CallWindowProc(OldWindowProc, hWnd, Msg, wParam, lParam);
end;
procedure InitializeWizard();
begin
with WizardForm do begin
BorderIcons := [biSystemMenu];
end;
OldWindowProc := SetWindowLong(WizardForm.Handle, GWL_WNDPROC, CallbackAddr('WindowProc'));
end;
procedure DeinitializeSetup();
begin
SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldWindowProc);
end;
|
Последний раз редактировалось Mailchik, 08-02-2013 в 18:41.
Отправлено: 18:13, 08-02-2013
| #1628
|