Recent

Author Topic: How do I use customdraw / compiler error  (Read 9542 times)

MISV

  • Hero Member
  • *****
  • Posts: 804
How do I use customdraw / compiler error
« on: May 23, 2017, 02:07:47 pm »
First I do;

IDEMacro - LCLWidgetType:=customdrawn
in "project settings" and "application overrides and defines"

Then

Code: Pascal  [Select][+][-]
  1. initialization
  2.   {$IFDEF mymsFPCDevTool}
  3.   // http://wiki.freepascal.org/Lazarus_Custom_Drawn_Controls#Custom_Drawn_Packages
  4.   customdrawndrawers.DefaultStyle := dsWin2000;
  5.   {$ENDIF}
  6.  



However, when compiling I get error

Quote
customdrawnobject_win.inc(590,78) Error: Incompatible type for arg no. 4: Got "<address of procedure(QWord;QWord;QWord;LongWord);StdCall>", expected "<procedure variable type of procedure(QWord;LongWord;QWord;LongWord);StdCall>"

at
Code: Pascal  [Select]
TimerInfo^.TimerID := Windows.SetTimer(0, 0, Interval, @TimerCallBackProc);

which is line 590 in unit customdrawnobject_win.inc




If I read the documentation correctly - I should be able too combine dsWindows7 drawing (where I can select a theme somehow?) with by installing http://wiki.freepascal.org/BGRAControls since that contains a drawer? Is that correct? I would love if I could thme my Win+Mac app in a custom theme/style/skin somehow





Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1430
    • Lebeau Software
Re: How do I use customdraw / compiler error
« Reply #1 on: May 23, 2017, 08:45:18 pm »
However, when compiling I get error

Quote
customdrawnobject_win.inc(590,78) Error: Incompatible type for arg no. 4: Got "<address of procedure(QWord;QWord;QWord;LongWord);StdCall>", expected "<procedure variable type of procedure(QWord;LongWord;QWord;LongWord);StdCall>"

at
TimerInfo^.TimerID := Windows.SetTimer(0, 0, Interval, @TimerCallBackProc);

which is line 590 in unit customdrawnobject_win.inc

It is pretty obvious what the error is.  TimerCallBackProc() is not declared correctly, its 2nd parameter is a QWord when a LongWord is expected instead.  This is the official callback declaration in the Win32 API:

Code: [Select]
VOID CALLBACK TimerProc(
  _In_ HWND     hwnd,
  _In_ UINT     uMsg,
  _In_ UINT_PTR idEvent,
  _In_ DWORD    dwTime
);

UINT and DWORD are always 32-bit in size, whether compiling for 32-bit or 64-bit systems.  On a 32-bit system, HWND and UINT_PTR are 32-bit in size.  On a 64-bit system, they are 64-bit in size.  Since the error message shows the 1st and 3rd parameters are QWord, the code is clearly being compiled for 64-bit.

Without actually seeing the declaration off TimerCallBackProc() in customdrawnobject_win.inc, my guess is that it is using UINT_PTR instead of UINT for the 2nd parameter.
« Last Edit: May 23, 2017, 08:47:55 pm by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

MISV

  • Hero Member
  • *****
  • Posts: 804
Re: How do I use customdraw / compiler error
« Reply #2 on: May 24, 2017, 09:32:22 am »
From that I can probably conclude not many people use customdraw. I was hoping I had setup something wrong. I will make a bug report later.



The other at least as important part of my question was this:

Quote
If I read the documentation correctly - I should be able too combine dsWindows7 drawing (where *I* can select a custom sub style somehow?) by installing http://wiki.freepascal.org/BGRAControls since that contains a drawer? Is that correct? I would love if I could theme my Win+Mac app in a custom theme/style/skin somehow

But not sure if that works yet or something still being worked on.

MISV

  • Hero Member
  • *****
  • Posts: 804
Re: How do I use customdraw / compiler error
« Reply #3 on: June 05, 2017, 03:44:16 pm »
For what it is worth - I have submitted a bug report here:

https://bugs.freepascal.org/view.php?id=31968

The version I have is 1.6.4 - I guess it may have been fixed in the meantime, but now the bug report is there at least

Bart

  • Hero Member
  • *****
  • Posts: 5467
    • Bart en Mariska's Webstek
Re: How do I use customdraw / compiler error
« Reply #4 on: June 05, 2017, 06:18:49 pm »
For what it is worth - I have submitted a bug report here:

https://bugs.freepascal.org/view.php?id=31968

Please look at my remarks there.

Bart

 

TinyPortal © 2005-2018