View Issue Details

IDProjectCategoryView StatusLast Update
0019134LazarusPatchpublic2011-04-19 10:31
ReporterStephanoAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionfixed 
Product Version0.9.31 (SVN)Product Build 
Target VersionFixed in Version0.9.31 (SVN) 
Summary0019134: Patch for more Delphi messages compatibility
DescriptionAttached is a patch that adds Delphi compatible message definitions.

- As I am not sure about 64 bit and little/big endian differences, some of the messages may need to be adapted accordingly, especially that I defined TCMChildKey to be in line with TLMKey which takes these factors into consideration.

- TLMEnter and TLMExit are defined in the original LMessages unit as TLMNoPara and not TLMNoParams (they are different). Is this supposed to be the case?

TLMNoPara = record
  Msg: Cardinal;
end;

{$ifndef WINDOWS}
  TLMNoParams = record
    Msg: Cardinal;
{$ifdef cpu64}
    UnusedMsg: Cardinal;
{$endif}
    Unused: array[0..1] of PtrInt;
    Result: LRESULT;
  end;
{$else}
  TLMNoParams = TWMNoParams;
{$endif}
TagsNo tags attached.
Fixed in Revision30356,30375
LazTarget-
Widgetset
Attached Files
  • DelphiCompat-2011-04-09.diff (3,647 bytes)
    Index: lcl/nonwin32/messages.pp
    ===================================================================
    --- lcl/nonwin32/messages.pp	(revision 30250)
    +++ lcl/nonwin32/messages.pp	(working copy)
    @@ -54,19 +54,50 @@
       WM_SYSKEYUP      = LM_SYSKEYUP;
       WM_VSCROLL       = LM_VSCROLL;
     
    +  WM_NCPAINT          = LM_NCPAINT;
    +  WM_CAPTURECHANGED   = LM_CAPTURECHANGED;
    +  WM_KEYDOWN          = LM_KEYDOWN;
    +  WM_WINDOWPOSCHANGED = LM_WINDOWPOSCHANGED;
    +  WM_CUT              = LM_CUT;
    +  WM_COPY             = LM_COPY;
    +  WM_PASTE            = LM_PASTE;
    +  WM_SETCURSOR        = LM_SETCURSOR;
    +  WM_PAINT            = LM_PAINT;
    +  WM_LBUTTONDOWN      = LM_LBUTTONDOWN;
    +  WM_CHAR             = LM_CHAR;
    +  WM_COMMAND          = LM_COMMAND;
    +  WM_CANCELMODE       = LM_CANCELMODE;
    +  WM_NOTIFY           = LM_NOTIFY;
    +  WM_CREATE           = LM_CREATE;
    +
     type
     
       TMessage = TLMessage;
     
    -  TWMEraseBkgnd     = TLMEraseBkgnd;
    -  TWMKillFocus      = TLMKillFocus;
    -  TWMMouse          = TLMMouse;
    -  TWMNCHITTEST      = TLMNCHITTEST;
    -  TWMSCROLL         = TLMSCROLL;
    -  TWMSetFocus       = TLMSetFocus;
    -  TWMSIZE           = TLMSIZE;
    -  TWMHScroll        = TLMHScroll;
    -  TWMVScroll        = TLMVScroll;
    +  TWMEraseBkgnd       = TLMEraseBkgnd;
    +  TWMKillFocus        = TLMKillFocus;
    +  TWMMouse            = TLMMouse;
    +  TWMNCHITTEST        = TLMNCHITTEST;
    +  TWMSCROLL           = TLMSCROLL;
    +  TWMSetFocus         = TLMSetFocus;
    +  TWMSIZE             = TLMSIZE;
    +  TWMHScroll          = TLMHScroll;
    +  TWMVScroll          = TLMVScroll;
    +  TWMKeyDown          = TLMKeyDown;
    +  TWMWindowPosChanged = TLMWindowPosChanged;
    +  TWMPaint            = TLMPaint;
    +  TWMLButtonDown      = TLMLButtonDown;
    +  TWMLButtonUp        = TLMLButtonUp;
    +  TWMLButtonDblClk    = TLMLButtonDblClk;
    +  TWMKey              = TLMKey;
    +  TWMCommand          = TLMCommand;
    +  TWMChar             = TLMChar;
    +  TWMNotify           = TLMNotify;
    +  TWMCut              = TLMCut;
    +  TWMCopy             = TLMCopy;
    +  TWMPaste            = TLMPaste;
    +  TWMSetCursor        = TLMSetCursor;
    +  TWMNoParams         = TLMNoParams;
     
       TWMGetDlgCode = TLMNoParams;
     
    Index: lcl/lmessages.pp
    ===================================================================
    --- lcl/lmessages.pp	(revision 30250)
    +++ lcl/lmessages.pp	(working copy)
    @@ -455,6 +455,18 @@
       TLMSysKeyUp = TLMKey;
     
     
    +  TLMCut = TLMNoParams;
    +  TLMCopy = TLMNoParams;
    +  TLMPaste = TLMNoParams;
    +
    +  TLMSetCursor = record
    +    Msg: Cardinal;
    +    CursorWnd: HWND;
    +    HitTest: SmallInt;
    +    MouseMsg: Word;
    +    Result: Longint;
    +  end;
    +
       TLMMouse = record
         Msg : Cardinal;
         Keys: PtrInt;
    Index: lcl/controls.pp
    ===================================================================
    --- lcl/controls.pp	(revision 30250)
    +++ lcl/controls.pp	(working copy)
    @@ -115,6 +115,35 @@
       TCMDialogChar = TLMKEY;
       TCMDialogKey = TLMKEY;
     
    +  TCMEnter = TLMEnter;
    +  TCMExit = TLMExit;
    +
    +  TCMCancelMode = record
    +    Msg: Cardinal;
    +    Unused: Integer;
    +    Sender: TControl;
    +    Result: Longint;
    +  end;
    +
    +  TCMChildKey = record
    +    Msg: Cardinal;
    +{$ifdef cpu64}
    +    UnusedMsg: Cardinal;
    +{$endif}
    +{$IFDEF FPC_LITTLE_ENDIAN}
    +    CharCode: Word; // VK_XXX constants as TLMKeyDown/Up, ascii if TLMChar
    +    Unused: Word;
    +{$ELSE}
    +    Unused: Word;
    +    CharCode: Word; // VK_XXX constants as TLMKeyDown/Up, ascii if TLMChar
    +{$ENDIF}
    +{$ifdef cpu64}
    +    Unused2 : Longint;
    +{$endif cpu64}
    +    Sender: TWinControl;
    +    Result: LRESULT;
    +  end;
    +
       TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom);
       TAlignSet = set of TAlign;
       TAnchorKind = (akTop, akLeft, akRight, akBottom);
    

Activities

2011-04-09 22:07

 

DelphiCompat-2011-04-09.diff (3,647 bytes)
Index: lcl/nonwin32/messages.pp
===================================================================
--- lcl/nonwin32/messages.pp	(revision 30250)
+++ lcl/nonwin32/messages.pp	(working copy)
@@ -54,19 +54,50 @@
   WM_SYSKEYUP      = LM_SYSKEYUP;
   WM_VSCROLL       = LM_VSCROLL;
 
+  WM_NCPAINT          = LM_NCPAINT;
+  WM_CAPTURECHANGED   = LM_CAPTURECHANGED;
+  WM_KEYDOWN          = LM_KEYDOWN;
+  WM_WINDOWPOSCHANGED = LM_WINDOWPOSCHANGED;
+  WM_CUT              = LM_CUT;
+  WM_COPY             = LM_COPY;
+  WM_PASTE            = LM_PASTE;
+  WM_SETCURSOR        = LM_SETCURSOR;
+  WM_PAINT            = LM_PAINT;
+  WM_LBUTTONDOWN      = LM_LBUTTONDOWN;
+  WM_CHAR             = LM_CHAR;
+  WM_COMMAND          = LM_COMMAND;
+  WM_CANCELMODE       = LM_CANCELMODE;
+  WM_NOTIFY           = LM_NOTIFY;
+  WM_CREATE           = LM_CREATE;
+
 type
 
   TMessage = TLMessage;
 
-  TWMEraseBkgnd     = TLMEraseBkgnd;
-  TWMKillFocus      = TLMKillFocus;
-  TWMMouse          = TLMMouse;
-  TWMNCHITTEST      = TLMNCHITTEST;
-  TWMSCROLL         = TLMSCROLL;
-  TWMSetFocus       = TLMSetFocus;
-  TWMSIZE           = TLMSIZE;
-  TWMHScroll        = TLMHScroll;
-  TWMVScroll        = TLMVScroll;
+  TWMEraseBkgnd       = TLMEraseBkgnd;
+  TWMKillFocus        = TLMKillFocus;
+  TWMMouse            = TLMMouse;
+  TWMNCHITTEST        = TLMNCHITTEST;
+  TWMSCROLL           = TLMSCROLL;
+  TWMSetFocus         = TLMSetFocus;
+  TWMSIZE             = TLMSIZE;
+  TWMHScroll          = TLMHScroll;
+  TWMVScroll          = TLMVScroll;
+  TWMKeyDown          = TLMKeyDown;
+  TWMWindowPosChanged = TLMWindowPosChanged;
+  TWMPaint            = TLMPaint;
+  TWMLButtonDown      = TLMLButtonDown;
+  TWMLButtonUp        = TLMLButtonUp;
+  TWMLButtonDblClk    = TLMLButtonDblClk;
+  TWMKey              = TLMKey;
+  TWMCommand          = TLMCommand;
+  TWMChar             = TLMChar;
+  TWMNotify           = TLMNotify;
+  TWMCut              = TLMCut;
+  TWMCopy             = TLMCopy;
+  TWMPaste            = TLMPaste;
+  TWMSetCursor        = TLMSetCursor;
+  TWMNoParams         = TLMNoParams;
 
   TWMGetDlgCode = TLMNoParams;
 
Index: lcl/lmessages.pp
===================================================================
--- lcl/lmessages.pp	(revision 30250)
+++ lcl/lmessages.pp	(working copy)
@@ -455,6 +455,18 @@
   TLMSysKeyUp = TLMKey;
 
 
+  TLMCut = TLMNoParams;
+  TLMCopy = TLMNoParams;
+  TLMPaste = TLMNoParams;
+
+  TLMSetCursor = record
+    Msg: Cardinal;
+    CursorWnd: HWND;
+    HitTest: SmallInt;
+    MouseMsg: Word;
+    Result: Longint;
+  end;
+
   TLMMouse = record
     Msg : Cardinal;
     Keys: PtrInt;
Index: lcl/controls.pp
===================================================================
--- lcl/controls.pp	(revision 30250)
+++ lcl/controls.pp	(working copy)
@@ -115,6 +115,35 @@
   TCMDialogChar = TLMKEY;
   TCMDialogKey = TLMKEY;
 
+  TCMEnter = TLMEnter;
+  TCMExit = TLMExit;
+
+  TCMCancelMode = record
+    Msg: Cardinal;
+    Unused: Integer;
+    Sender: TControl;
+    Result: Longint;
+  end;
+
+  TCMChildKey = record
+    Msg: Cardinal;
+{$ifdef cpu64}
+    UnusedMsg: Cardinal;
+{$endif}
+{$IFDEF FPC_LITTLE_ENDIAN}
+    CharCode: Word; // VK_XXX constants as TLMKeyDown/Up, ascii if TLMChar
+    Unused: Word;
+{$ELSE}
+    Unused: Word;
+    CharCode: Word; // VK_XXX constants as TLMKeyDown/Up, ascii if TLMChar
+{$ENDIF}
+{$ifdef cpu64}
+    Unused2 : Longint;
+{$endif cpu64}
+    Sender: TWinControl;
+    Result: LRESULT;
+  end;
+
   TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient, alCustom);
   TAlignSet = set of TAlign;
   TAnchorKind = (akTop, akLeft, akRight, akBottom);

Juha Manninen

2011-04-16 12:32

developer   ~0047510

Anything that improves converting Delphi applications is good.

@Paul, do you see any problem with the patch?

Paul Ishenin

2011-04-18 04:34

manager   ~0047539

I adapted TWMSetCursor to be 64bit compatible. Please test and close if ok.

Stephano

2011-04-18 12:11

developer   ~0047553

1-
Delphi docs on the web (5 elements):
  TWMSetCursor = packed record
    Msg: Cardinal;
    CursorWnd: HWND;
    HitTest: SmallInt;
    MouseMsg: Word;
    Result: Longint;
  end;

Current commit (4 elements for 32 bits):
  TLMSetCursor = record
    Msg: Cardinal;
{$ifdef cpu64}
    UnusedMsg: Cardinal;
{$endif}
    CursorWnd: HWND;
    case Boolean of
      False: (
        HitTest: SmallInt;
        MouseMsg: Word;
      );
      True: (
        Dummy: LPARAM;
        Result: LRESULT;
      );
  end;

2- Are TLMNoPara and not TLMNoParams OK?

Otherwise the patch is fine.

Paul Ishenin

2011-04-18 15:48

manager   ~0047560

No, there are 5 elements for 32 bits:
1. Msg, 2. CursorWnd, 3. HitTest, 4. MouseMsg, 5. Result

HitTest and MouseMsg together fit into LParam in 32 bit and Result is placed after them

Stephano

2011-04-18 16:01

developer   ~0047563

I had not paid attention to the element sizes.

What about TLMNoPara and TLMNoParams?

Paul Ishenin

2011-04-19 04:27

manager   ~0047583

I removed TLMNoPara and replaced TLMEnter,TLMExit with TLMNoParams. Please close if ok.

Issue History

Date Modified Username Field Change
2011-04-09 22:07 Stephano New Issue
2011-04-09 22:07 Stephano File Added: DelphiCompat-2011-04-09.diff
2011-04-16 09:13 Paul Ishenin Status new => assigned
2011-04-16 09:13 Paul Ishenin Assigned To => Paul Ishenin
2011-04-16 12:32 Juha Manninen Note Added: 0047510
2011-04-18 04:34 Paul Ishenin Fixed in Revision => 30356
2011-04-18 04:34 Paul Ishenin LazTarget => -
2011-04-18 04:34 Paul Ishenin Status assigned => resolved
2011-04-18 04:34 Paul Ishenin Fixed in Version => 0.9.31 (SVN)
2011-04-18 04:34 Paul Ishenin Resolution open => fixed
2011-04-18 04:34 Paul Ishenin Note Added: 0047539
2011-04-18 12:11 Stephano Status resolved => assigned
2011-04-18 12:11 Stephano Resolution fixed => reopened
2011-04-18 12:11 Stephano Note Added: 0047553
2011-04-18 15:48 Paul Ishenin Note Added: 0047560
2011-04-18 16:01 Stephano Note Added: 0047563
2011-04-19 04:27 Paul Ishenin Fixed in Revision 30356 => 30356,30375
2011-04-19 04:27 Paul Ishenin Status assigned => resolved
2011-04-19 04:27 Paul Ishenin Resolution reopened => fixed
2011-04-19 04:27 Paul Ishenin Note Added: 0047583
2011-04-19 09:32 Stephano Status resolved => closed