AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Delphi 12 und SendMessage

Ein Thema von EscapedFromMatrix · begonnen am 19. Feb 2024 · letzter Beitrag vom 20. Feb 2024
Antwort Antwort
Seite 1 von 2  1 2   
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#1

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 11:29
Hi,

Just an idea, i don't have Delphi 12, but form what i read there is change in default Integer and NativeInt...

So please check the size of TCopyDataStruct in both Delphi 11 and 12, may be something broke there with dwData,
It would be nice if you shared with us the SizeOf(TCopyDataStruct) in the 4 cases Delphi 11 and Delphi 12 for application with 32bit and 64bit.
Kas
  Mit Zitat antworten Zitat
EscapedFromMatrix

Registriert seit: 19. Feb 2024
6 Beiträge
 
#2

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 12:23
Da gibt es Abweichungen.


showmessage(inttostr(sizeof(aCopyData)));

D11
x64=24
x86=12

D12
x64=8
x86=4
  Mit Zitat antworten Zitat
EscapedFromMatrix

Registriert seit: 19. Feb 2024
6 Beiträge
 
#3

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 12:32
Ich mache noch weitere Tests, aber so scheint es zu klappen:
SendMessage(hTargetWnd, WM_COPYDATA, NativeUInt(Handle), NativeInt(@aCopyData));

Geändert von EscapedFromMatrix (19. Feb 2024 um 12:34 Uhr)
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.660 Beiträge
 
Delphi 12 Athens
 
#4

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 12:54
Und so?
SendMessage(hTargetWnd, WM_COPYDATA, wParam(Handle), lParam(@aCopyData));
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
EscapedFromMatrix

Registriert seit: 19. Feb 2024
6 Beiträge
 
#5

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 13:00
Das klappt auch.
Wenn man die Definitionen für wParam und lParam verfolgt, landet man ja letztendlich bei NativeUInt und NativeInt.
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.382 Beiträge
 
Delphi 12 Athens
 
#6

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 13:04
Das im Post #5 (für D12) kann eigentlich nicht stimmen.
Wie ist denn TCopyDataStruct deklariert? (Strg+Linkklick aka "Deklaration suchen")
Ein Therapeut entspricht 1024 Gigapeut.
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#7

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 13:06
Da gibt es Abweichungen.

showmessage(inttostr(sizeof(aCopyData)));

D11
x64=24
x86=12

D12
x64=8
x86=4
That can't be right.

First i put SizeOf(TCopyDataStruct) not sizeof(aCopyData), why it is important because 8 and 4 are the size of single and simple pointer, not a record (struct), and 8 and 4 looks like a pointer something like PCopyDataStruct not TCopyDataStruct, or you just used @aCopyData by mistake.
Second as rule of thumb, never ever use with SendMessage, PostMessage... parameters other than WPARAM and LPARAM, or just cast them.
Kas
  Mit Zitat antworten Zitat
EscapedFromMatrix

Registriert seit: 19. Feb 2024
6 Beiträge
 
#8

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 13:18
[QUOTE=Kas Ob.;1533652]
First i put SizeOf(TCopyDataStruct) not sizeof(aCopyData)...
Sorry, my mistake:

showmessage(inttostr(sizeof(TCopyDataStruct)));
D11, x86= 12
D11, x64= 24

D12, x86= 12
D12, x64= 24
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.382 Beiträge
 
Delphi 12 Athens
 
#9

AW: Delphi 12 und SendMessage

  Alt 19. Feb 2024, 16:01
SizeOf(Variable) ist nicht falsch.
Der Typ und die Variable müssten sowieso gleich groß sein, da die Variable ja den "selben" Typ hätte.

Das sieht mehr wie ein Pointer aus (4 Byte = 32 Bit und 8 Byte = 64 Bit)
z.B. PCopyDataStruct statt TCopyDataStruct
aber auch da wären SizeOf(PCopyDataStruct) und SizeOf(Variable) // var Variable: PCopyDataStruct; gleich.
Ein Therapeut entspricht 1024 Gigapeut.

Geändert von himitsu (19. Feb 2024 um 16:07 Uhr)
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
412 Beiträge
 
#10

AW: Delphi 12 und SendMessage

  Alt 20. Feb 2024, 08:19
SizeOf(Variable) ist nicht falsch.
Der Typ und die Variable müssten sowieso gleich groß sein, da die Variable ja den "selben" Typ hätte.

Das sieht mehr wie ein Pointer aus (4 Byte = 32 Bit und 8 Byte = 64 Bit)
z.B. PCopyDataStruct statt TCopyDataStruct
aber auch da wären SizeOf(PCopyDataStruct) und SizeOf(Variable) // var Variable: PCopyDataStruct; gleich.
You are right, but for best practice i prefer never to use variable, to avoid situations like the following
Code:
type
  PMyRecord = ^TMyRecord;

  TMyRecord = record
    Buffer: array[0..31] of Byte;
  end;

  TMyClass = class
  public
    Rec1: TMyRecord;
    Rec2: PMyRecord;
  end;
var
  C:TMyClass;
begin
  Writeln(IntToStr(SizeOf(C.Rec1)));  // 32 
  Writeln(IntToStr(SizeOf(C.Rec2)));  // 4 on 32bit, 8 on 64bit
  Readln;
end.
This thing will be dangerous or more impactful when TMyRecord is small like 4 or 8 and pass on one platform to fail on the other, can happen when updating legacy code or just redesigning data structures.
Kas
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 1 von 2  1 2   

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:34 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz