Recent

Author Topic: hwnd type error  (Read 356 times)

TBMan

  • Full Member
  • ***
  • Posts: 135
hwnd type error
« on: April 28, 2025, 08:04:51 pm »
Is anyone getting an "error in type definition" when using:

Code: Pascal  [Select][+][-]
  1. uses windows;
  2.  
  3. var
  4.   hwnd:HWND;

cdbc

  • Hero Member
  • *****
  • Posts: 2150
    • http://www.cdbc.dk
Re: hwnd type error
« Reply #1 on: April 28, 2025, 08:17:03 pm »
Hi
Yes, everybody would!!!!
Pascal is case-IN-sensitive, which means both your variable and type is exactly the same word.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

ASerge

  • Hero Member
  • *****
  • Posts: 2411
Re: hwnd type error
« Reply #2 on: April 28, 2025, 08:32:12 pm »
If you really want that name, then use
Code: Pascal  [Select][+][-]
  1. var
  2.   hwnd: Windows.HWND;

TBMan

  • Full Member
  • ***
  • Posts: 135
Re: hwnd type error
« Reply #3 on: April 28, 2025, 09:10:31 pm »
If you really want that name, then use
Code: Pascal  [Select][+][-]
  1. var
  2.   hwnd: Windows.HWND;

Yep. I'm having an off day. I could just change the variable name too. 😆
**edit**

This is what happened to my brain after using ChatGPT to learn C++ and then switch to Pascal and go over using the windows api as I know nothing there. ChatgPT was making a lot of mistakes with Pascal and some issues are still ongoing (getting a clean keypressed routine for instance) and this error slipped by my common sense.
« Last Edit: April 29, 2025, 12:48:42 am by TBMan »

silvercoder70

  • Full Member
  • ***
  • Posts: 186
    • Tim Coates
Re: hwnd type error
« Reply #4 on: April 29, 2025, 01:20:51 pm »
Two thoughts...

With Chatgpt and Pascal. It definitely has problems providing good code. Perhaps it struggled finding code to copy from. I admit to trying some things myself, and it is hardly ever right.

On HWND ... for much of my programming life, whenever I had to deal with handle to a window, I would use hwnd as the variable prefix (Hungarian notation). Though if I really had to use hwnd by itself then I would add an underscore to the end of the name.
🔥 Pascal Isn’t Dead -> See What It Can Do: @silvercoder70 on YouTube

TBMan

  • Full Member
  • ***
  • Posts: 135
Re: hwnd type error
« Reply #5 on: April 29, 2025, 02:14:17 pm »
Two thoughts...

With Chatgpt and Pascal. It definitely has problems providing good code. Perhaps it struggled finding code to copy from. I admit to trying some things myself, and it is hardly ever right.

On HWND ... for much of my programming life, whenever I had to deal with handle to a window, I would use hwnd as the variable prefix (Hungarian notation). Though if I really had to use hwnd by itself then I would add an underscore to the end of the name.

Good idea.

I was having it write a Borland graph.h and a graph unit in pascal as wrappers around windows api and it came out ok, but the keyboard was an issue. I didn't start with a mouse unit yet. I'm learning from tinking with that code.

 

TinyPortal © 2005-2018