Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для El Sanchez

Ветеран


Contributor


Сообщения: 1209
Благодарности: 949

Профиль | Отправить PM | Цитировать


Цитата AlekseyPopovv:
А как в стандартных MsgBox поменять цвет? »
AlekseyPopovv, например, так:
Скрытый текст

Код: Выделить весь код
[Setup]
AppName=test
AppVerName=test
DefaultDirName={tmp}\test
CreateAppDir=no
Uninstallable=no
CreateUninstallRegKey=no

[Languages]
Name: ru; MessagesFile: compiler:Languages\russian.isl

[Code]
#define A = (Defined UNICODE) ? "W" : "A"
const
  WH_CBT = 5;
  HCBT_CREATEWND = 3; 
  WC_DIALOG = '#32770';
  WM_INITDIALOG = $0110;
  WM_ERASEBKGND = $0014;
  WM_PAINT = $000F;
  WM_CTLCOLORSTATIC = $0138;
  WM_CTLCOLORBTN = $0135; 
  WM_DESTROY = $0002;
  TRANSPARENT = 1;

type
  PAINTSTRUCT = record
    hdc: THandle;
    fErase: BOOL;
    rcPaint: TRect;
    fRestore: BOOL;
    fIncUpdate: BOOL;
    rgbReserved: array [0..31] of Byte;
  end;

function GetCurrentThreadId: DWORD; external 'GetCurrentThreadId@kernel32.dll stdcall';
function CallNextHookEx(hhk: THandle; nCode: Integer; wParam, lParam: Longint): Longint; external 'CallNextHookEx@user32.dll stdcall';
function SetWindowsHookEx(idHook: Integer; lpfn, hMod: Longint; dwThreadId: DWORD): THandle; external 'SetWindowsHookEx{#A}@user32.dll stdcall';
function UnhookWindowsHookEx(hhk: THandle): BOOL; external 'UnhookWindowsHookEx@user32.dll stdcall';
function SetWindowSubclass(hWnd: HWND; pfnSubclass: Longint; uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): BOOL; external 'SetWindowSubclass@comctl32.dll stdcall';
function RemoveWindowSubclass(hWnd: HWND; pfnSubclass: Longint; uIdSubclass: UINT_PTR): BOOL; external 'RemoveWindowSubclass@comctl32.dll stdcall';
function DefSubclassProc(hWnd: HWND; uMsg: UINT; wParam, lParam: Longint): Longint; external 'DefSubclassProc@comctl32.dll stdcall';
function GetClassName(hWnd: HWND; lpClassName: string; nMaxCount: Integer): Integer; external 'GetClassName{#A}@user32.dll stdcall';
function GetSysColorBrush(nIndex: Integer): THandle; external 'GetSysColorBrush@user32.dll stdcall';
function SetBkMode(hdc: THandle; iBkMode: Integer): Integer; external 'SetBkMode@gdi32.dll stdcall';
function BeginPaint(hWnd: HWND; var lpPaint: PAINTSTRUCT): Longint; external 'BeginPaint@user32.dll stdcall';
function EndPaint(hWnd: HWND; const lpPaint: PAINTSTRUCT): Boolean; external 'EndPaint@user32.dll stdcall';
function FillRect(hDC: THandle; const lprc: TRect; hbr: THandle): Integer; external 'FillRect@user32.dll stdcall';
function GetUpdateRect(hWnd: HWND; var lpRect: TRect; bErase: BOOL): BOOL; external 'GetUpdateRect@user32.dll stdcall';

var
  GCBTProc, GDlgProc: Longint;  
  GDlgHook, GBgndBrush: THandle; 
  
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function DlgProc(hWnd: HWND; uMsg: UINT; wParam, lParam: Longint; uIdSubclass: UINT_PTR; dwRefData: DWORD_PTR): Longint;
var
  ps: PAINTSTRUCT;
  rc: TRect;
begin
  case uMsg of  
    WM_INITDIALOG: 
      begin
        if GBgndBrush = 0 then
          GBgndBrush := GetSysColorBrush(13{COLOR_HIGHLIGHT для примера});
        Result := DefSubclassProc(hWnd, uMsg, wParam, lParam);        
      end;
    WM_ERASEBKGND:
      begin
        GetUpdateRect(hWnd, rc, False);
        FillRect(wParam, rc, GBgndBrush);
        Result := 1;
      end;
    WM_PAINT:
      begin
        BeginPaint(hWnd, ps);
        FillRect(ps.hdc, ps.rcPaint, GBgndBrush);
        EndPaint(hWnd, ps);
      end;
    WM_CTLCOLORBTN, WM_CTLCOLORSTATIC:
      begin
        SetBkMode(wParam, TRANSPARENT);
        Result := GBgndBrush;
      end;
    WM_DESTROY:
      begin
        RemoveWindowSubclass(hWnd, GDlgProc, 0);
        Result := DefSubclassProc(hWnd, uMsg, wParam, lParam);
      end;
  else
    Result := DefSubclassProc(hWnd, uMsg, wParam, lParam);
  end;
end;   

///////////////////////////////////////////////////////////////////
function CBTProc(nCode: Integer; wParam, lParam: Longint): Longint;
var
  ClassName: string;   
begin
  case nCode of  
    HCBT_CREATEWND:
      begin      
        ClassName := StringOfChar(#0, 64);
        GetClassName(wParam, ClassName, Length(ClassName));
        ClassName := TrimRight(ClassName);        
        case ClassName of
          WC_DIALOG:
            begin
              if GDlgProc = 0 then
                GDlgProc := CallbackAddr('DlgProc');
              SetWindowSubclass(wParam, GDlgProc, 0, 0);
            end;
        end;
        Result := 0;
      end;      
  else  
    Result := CallNextHookEx(GDlgHook, nCode, wParam, lParam);  
  end;
end;

//////////////////
procedure HookDlg;
begin
  if GCBTProc = 0 then
    GCBTProc := CallbackAddr('CBTProc');
  GDlgHook := SetWindowsHookEx(WH_CBT, GCBTProc, 0, GetCurrentThreadId);
end;

////////////////////
procedure UnHookDlg;
begin
  UnhookWindowsHookEx(GDlgHook);
end;

///////////////////////////
procedure InitializeWizard;
begin
  HookDlg;  
end;

////////////////////////////
procedure DeinitializeSetup;
begin
  if ExpandConstant('{wizardhwnd}') = '0' then Exit;
  UnHookDlg;
end;

//////////////////////////////////////
function InitializeUninstall: Boolean;
begin
  Result := True;
  HookDlg;
end;

////////////////////////////////
procedure DeinitializeUninstall;
begin
  UnHookDlg;
end;
Это сообщение посчитали полезным следующие участники:

Отправлено: 19:56, 21-03-2016 | #1445