Jump to content

dwrbudr

Members
  • Content Count

    91
  • Joined

  • Last visited

Community Reputation

12 Good

Technical Information

  • Delphi-Version
    Delphi 13 Florence

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. If you want to do specific actions based on the VCL control that was about to receive the message, like a TTreeView, TEdit, etc.
  2. Drop TApplicationEvents component on the form and implement the OnMessage event handler. procedure TMainForm.ApplicationEventsMessage(var Msg: tagMSG; var Handled: boolean); var Key: Word; ShiftState: TShiftState; ctrl: TWinControl; begin case Msg.Message of WM_KEYDOWN: begin Key := Msg.wParam; ShiftState := KeyDataToShiftState(Msg.lParam); if (ssCtrl in ShiftState) and (Key = Ord('V')) then begin ctrl := FindControl(Msg.hwnd); //do whatever you need to do Handled := true; end; end; end; end;
  3. dwrbudr

    TBitmap.SaveToFile produces invalid image file

    @ToddFrankson In order to reproduce the issue, the PNG file has to be 8bit and probably grayscale. Try to reproduce the issue with the PNG file from the sample project I've attached.
  4. dwrbudr

    TBitmap.SaveToFile produces invalid image file

    Yes, I've missed that from the sample project, but using ms.Position := 0 doesn't change the outcome - black or invalid bitmap file.
  5. dwrbudr

    TBitmap.SaveToFile produces invalid image file

    @Anders Melander It seems the issue is much more broader that I initially thought. The change proposed by you fixes the issue above, e.g. calling SaveToFile/SaveToStream twice. But the following code produces black bitmap even if the fix is included. I have attached the sample project, but in order to test it Vcl.Graphics.pas has to be patched as described in the post above. As you said, TBitmap has to be almost entirelly rewritten from scratch. bmp := TBitmap.Create; bmp2 := TBitmap.Create; png := TPNGImage.create; png.LoadFromFile('in.png'); bmp.Assign(png); ms := TMemoryStream.Create; bmp.SaveToStream(ms); bmp2.LoadFromStream(ms); bmp2.SaveToFile('out.bmp'); // out.bmp is entirelly black BmpTest.zip
  6. dwrbudr

    TBitmap.SaveToFile produces invalid image file

    Thanks @Anders Melander What do you think is the safest fix? Probably to call InternalGetDIBSizes passing 0 instead of FDIB.dsbmih.biClrUsed Another "fix" is to set the Bitmap.Palette := 0 after the Assign call. Strangely though after assigning 8bit grayscale PNG to bitmap, the bitmap becames 24bit with palette. Is that a common use at all?
  7. The following code with this specific type of image (8-bit grayscale PNG) produces invalid .bmp (out_2.bmp) file if TBitmap.SaveToFile/SaveToStream is used more than once. The corrupt file cannot be opened in Windows Photo Viewer, FastStone Image Viewer, etc. BmpHeaderViewer shows this for out_1.bmp File Name: out_1.bmp File Size: 52.9 KB ------------------------------------------------------------------------ Type: BM Size: 54214 bytes Reserved1: 0 Reserved2: 0 OffBits: 1078 bytes ------------------------------------------------------------------------ Size: 40 bytes Width: 143 pixels Height: 123 pixels Planes: 1 BitCount: 24 bpp Compression: RGB SizeImage: 53136 bytes XPelsPerMeter: 0 YPelsPerMeter: 0 ClrUsed: 256 ClrImportant: 0 ------------------------------------------------------------------------ And this for the corrupted out_2.bmp File Name: out_2.bmp File Size: 52.9 KB ------------------------------------------------------------------------ Type: BM Size: 55238 bytes Reserved1: 0 Reserved2: 0 OffBits: 2102 bytes ------------------------------------------------------------------------ Size: 40 bytes Width: 143 pixels Height: 123 pixels Planes: 1 BitCount: 24 bpp Compression: RGB SizeImage: 53136 bytes XPelsPerMeter: 0 YPelsPerMeter: 0 ClrUsed: 256 ClrImportant: 0 ------------------------------------------------------------------------ Gap to pixels: 1024 bytes ------------------------------------------------------------------------ Image corrupt or truncated. ======================================================================== Tested on Delphi 12.3/13.0 Is this a known issue or what is possibly wrong in VCL, is it Vcl.Graphics.Pas or PNGImage.pas AssignTo method wrong? procedure TForm69.FormCreate(Sender: TObject); var bmp: TBitmap; png: TPNGImage; begin bmp := TBitmap.Create; png := TPNGImage.create; png.LoadFromFile('in.png'); bmp.Assign(png); bmp.SaveToFile('out_1.bmp'); bmp.SaveToFile('out_2.bmp'); end; Sample project to reproduce the issue is attached. BmpTest.zip
  8. dwrbudr

    New Delphi features in Delphi 13

    Yes, the freeze is there, but refactoring has worked OK for me. I suppose 12.3 will have to stay forever on my PC just for refactoring. formatter.exe can be used via CMD since we have very strict coding guideline and code reviews before pull requests.
  9. dwrbudr

    New Delphi features in Delphi 13

    No refactoring is a showstopper for me to use Delphi 13.0. Big dissapointment.
  10. dwrbudr

    Screenshot each sheet in a PageControl

    Call HandleNeeded on each tab instead of activating it.
  11. dwrbudr

    Intercepting UuidCreate function

    function Detour_UuidCreate(out guid: TGUID): Longint; stdcall; begin guid := Default(TGUID); Result := 0; end; procedure TForm68.Button1Click(Sender: TObject); var myguid: TGUID; begin InterceptCreate('rpcrt4.dll', 'UuidCreate', @Detour_UuidCreate); CreateGUID(myguid); end; So the above code does not work? On my side it works if I put a breakpoint in Detour_UuidCreate
  12. dwrbudr

    TVirtualImageList Custom component

    I think TVirtualImageList is automatically scaled when DPI changes only when TVirtualImageList is placed on a TForm/TFrame (look for SendChangeScaleMessage in the VCL code). So you'll have to override the panel ChangeScale method and set the image list size.
  13. procedure TFormPopup.CreateParams(var Params: TCreateParams); var ClassRegistered: boolean; TempClass: TWndClass; begin inherited CreateParams(Params); ClassRegistered := GetClassInfo(Params.WindowClass.hInstance, Params.WinClassName, TempClass); if ClassRegistered then begin Winapi.Windows.UnregisterClass(Params.WinClassName, Params.WindowClass.hInstance); end; If FIsBorderlessPopup then begin Params.Style := WS_POPUP; Params.WindowClass.style := Params.WindowClass.style or CS_DROPSHADOW; Params.ExStyle := WS_EX_TOPMOST; end; end;
  14. dwrbudr

    Alignment of group of controls

    In Inspector, change the Top value of the panel you want to move. For example if you want the panel to be last, set its Top value to be higher than the Top value of the last panel.
  15. dwrbudr

    TEdgeBrowser text or button overlay

    You can place only descendants of TWinControl, such as TButton or TStaticText, and not descendants ot TGraphicControl such as TLabel, TImage.
×