Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var
- //CompLabel: TLabel;
- CompForm: TSetupForm;
- CompImage: TBitmapImage;
- LoadingImage: Boolean;
- LastMouse: TPoint;
- InstallMessage: TLabel;
- type
- TTimerProc = procedure(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
- function GetCursorPos(var lpPoint: TPoint): BOOL; external 'GetCursorPos@user32.dll stdcall';
- function SetTimer(hWnd: longword; nIDEvent, uElapse: LongWord; lpTimerFunc: LongWord): LongWord; external 'SetTimer@user32.dll stdcall';
- function ScreenToClient(hWnd: HWND; var lpPoint: TPoint): BOOL; external 'ScreenToClient@user32.dll stdcall';
- function ClientToScreen(hWnd: HWND; var lpPoint: TPoint): BOOL; external 'ClientToScreen@user32.dll stdcall';
- function ListBox_GetItemRect(const hWnd: HWND; const Msg: Integer; Index: LongInt; var Rect: TRect): LongInt; external 'SendMessageW@user32.dll stdcall';
- const
- LB_GETITEMRECT = $0198;
- LB_GETTOPINDEX = $018E;
- function WrapTimerProc(Callback: TTimerProc; ParamCount: Integer): LongWord; external 'wrapcallback@files:InnoCallback.dll stdcall';
- function FindControl(Parent: TWinControl; P: TPoint): TControl;
- var
- Control: TControl;
- WinControl: TWinControl;
- I: Integer;
- P2: TPoint;
- begin
- for I := 0 to Parent.ControlCount - 1 do
- begin
- Control := Parent.Controls[I];
- if Control.Visible and (Control.Left <= P.X) and (P.X < Control.Left + Control.Width) and (Control.Top <= P.Y) and (P.Y < Control.Top + Control.Height) then
- begin
- if Control is TWinControl then
- begin
- P2 := P;
- ClientToScreen(Parent.Handle, P2);
- WinControl := TWinControl(Control);
- ScreenToClient(WinControl.Handle, P2);
- Result := FindControl(WinControl, P2);
- if Result <> nil then Exit;
- end;
- Result := Control;
- Exit;
- end;
- end;
- Result := nil;
- end;
- function PointInRect(const Rect: TRect; const Point: TPoint): Boolean;
- begin
- Result := (Point.X >= Rect.Left) and (Point.X <= Rect.Right) and (Point.Y >= Rect.Top) and (Point.Y <= Rect.Bottom);
- end;
- function ListBoxItemAtPos(ListBox: TCustomListBox; Pos: TPoint): Integer;
- var
- Count: Integer;
- ItemRect: TRect;
- begin
- Result := SendMessage(ListBox.Handle, LB_GETTOPINDEX, 0, 0);
- Count := ListBox.Items.Count;
- while Result < Count do
- begin
- ListBox_GetItemRect(ListBox.Handle, LB_GETITEMRECT, Result, ItemRect);
- if PointInRect(ItemRect, Pos) then Exit;
- Inc(Result);
- end;
- Result := -1;
- end;
- procedure HoverComponentChanged(Index: Integer);
- var
- Image, form_caption: string;
- ImagePath, ImageWaitPath: string;
- Image_Fail: Boolean;
- image_x, image_y: Integer;
- begin
- CompForm.Caption := 'Bild Vorschau';
- form_caption := GetDATString('Description', 'index'+RightStr('000'+IntToStr(Index),3), '', ExpandConstant('{tmp}\Filebase.ini'));
- if form_caption <> ''then
- begin
- CompForm.Caption := form_caption;
- end;
- Image := GetDATString('Picture', 'index'+RightStr('000'+IntToStr(Index),3), '', ExpandConstant('{tmp}\Filebase.ini'));
- if Image <> '' then
- begin
- Image_Fail := False;
- { The ExtractTemporaryFile pumps the message queue, prevent recursion }
- if not LoadingImage then
- begin
- LoadingImage := True;
- try
- ImagePath := ExpandConstant('{app}\Budyx69_Modpack\DL_Preview\' + Image);
- GetPictureSize(ImagePath, image_x, image_y);
- //Log('Image: ' + Image + ' '+ intToStr(image_x) + ' ' + IntToStr(image_y));
- CompForm.ClientWidth := image_x + 20;
- CompForm.ClientHeight := image_y + 20;
- CompImage.Width := image_x;
- CompImage.Height := image_y;
- if not FileExists(ImagePath) then
- begin
- Image_Fail := True;
- ImageWaitPath := ImagePath;
- ImagePath := ExpandConstant('{tmp}\wait.bmp');
- CompImage.Bitmap.LoadFromFile(ImagePath);
- //CompImage.Bitmap.Canvas.Refesh;
- end
- else
- begin
- CompImage.Bitmap.LoadFromFile(ImagePath);
- end;
- finally
- LoadingImage := False;
- end;
- end;
- CompForm.Left := WizardForm.Left + WizardForm.Width;
- CompForm.Top := WizardForm.Top;
- CompForm.Visible := True;
- if Image_Fail then
- begin
- idpDownloadFile('http://dieschwarzenschafe.com/modpack/preview_images/' + Image, ExpandConstant('{app}\Budyx69_Modpack\DL_Preview\' + Image));
- ImagePath := ImageWaitPath;
- if FileExists(ImagePath) then
- begin
- CompImage.Bitmap.LoadFromFile(ImagePath);
- //CompForm.Left := WizardForm.Left + WizardForm.Width;
- //CompForm.Top := WizardForm.Top;
- //CompForm.Visible := True;
- end
- else
- begin
- Log('Image not found: ' + ImagePath);
- end;
- end;
- end
- else
- begin
- CompForm.Visible := False;
- end;
- end;
- procedure HoverTimerProc(H: LongWord; Msg: LongWord; IdEvent: LongWord; Time: LongWord);
- var
- P: TPoint;
- Control: TControl;
- Index: Integer;
- begin
- GetCursorPos(P);
- if P <> LastMouse then
- begin
- LastMouse := P;
- ScreenToClient(WizardForm.Handle, P);
- if (P.X < 0) or (P.Y < 0) or (P.X > WizardForm.ClientWidth) or (P.Y > WizardForm.ClientHeight) then
- begin
- Control := nil;
- end
- else
- begin
- Control := FindControl(WizardForm, P);
- end;
- Index := -1;
- if (Control = WizardForm.ComponentsList) and (not WizardForm.TypesCombo.DroppedDown) then
- begin
- P := LastMouse;
- ScreenToClient(WizardForm.ComponentsList.Handle, P);
- Index := ListBoxItemAtPos(WizardForm.ComponentsList, P);
- end;
- HoverComponentChanged(Index);
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement