Recent

Author Topic: What is the difference between a window and a control?  (Read 1240 times)

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
What is the difference between a window and a control?
« on: January 21, 2024, 03:23:57 am »
How do systems like X11 and Microsoft Windows distinguish between windows and controls?

It seems to me that windows are what controls are placed in.

I've come across a problem where after embedding a Emacs in a TPanel I am unable to get the Emacs to resize after resizing the TPanel, point being that X11 needs a different handle to the Emacs window itself.

There must be a way of getting Emacs to retrieve the handle of its frame (windows to other GUI users) but in the meantime I've got settle for a way by which TPanel can obtain the handle of an object embedded in it.
Lazarus 3.0/FPC 3.2.2

Thaddy

  • Hero Member
  • *****
  • Posts: 14367
  • Sensorship about opinions does not belong here.
Re: What is the difference between a window and a control?
« Reply #1 on: January 21, 2024, 04:51:15 pm »

There must be a way of getting Emacs to retrieve the handle of its frame (windows to other GUI users) but in the meantime I've got settle for a way by which TPanel can obtain the handle of an object embedded in it.
The Tpanel.Components[] property contains a list of components on the Panel. Yoou can iterate that to find the component you need.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11448
  • FPC developer.
Re: What is the difference between a window and a control?
« Reply #2 on: January 21, 2024, 06:40:14 pm »
How do systems like X11 and Microsoft Windows distinguish between windows and controls?

A window are a handle that processes messages (can be non-visual).   A control has screen realestate somewhere.

Quote
I've come across a problem where after embedding a Emacs in a TPanel I am unable to get the Emacs to resize after resizing the TPanel, point being that X11 needs a different handle to the Emacs window itself.

Emacs is a cool OS, pity about the bad editor


MarkMLl

  • Hero Member
  • *****
  • Posts: 6685
Re: What is the difference between a window and a control?
« Reply #3 on: January 21, 2024, 06:57:01 pm »
I've come across a problem where after embedding a Emacs in a TPanel I am unable to get the Emacs to resize after resizing the TPanel, point being that X11 needs a different handle to the Emacs window itself.

There must be a way of getting Emacs to retrieve the handle of its frame (windows to other GUI users) but in the meantime I've got settle for a way by which TPanel can obtain the handle of an object embedded in it.

I swear somebody was asking about this in a different thread just yesterday. This isn't about handles, it's about signals.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: What is the difference between a window and a control?
« Reply #4 on: January 21, 2024, 07:02:21 pm »

There must be a way of getting Emacs to retrieve the handle of its frame (windows to other GUI users) but in the meantime I've got settle for a way by which TPanel can obtain the handle of an object embedded in it.
The Tpanel.Components[] property contains a list of components on the Panel. Yoou can iterate that to find the component you need.

In this case the TPanel has no components on it. The embedded Emacs is passed the window handle of the TPanel and embeds itself directly in it.

There is probably some kind of "child" component there but whether it is accessible from the LCL code is another issue.

The code is something along these lines

Code for getting the panel's window handle.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.btnPanelHandleClick(Sender: TObject);
  2. begin
  3.   edtWinHandle.Text := IntToStr(QWidget_winId(TQtWidget(pnlEmacsParent.Handle).Widget));
  4. end;
  5.  


Emacs command, with window handle 102760473
Code: Bash  [Select][+][-]
  1. emacs  --parent-id 102760473 --with-profile doom01
  2.  

Lazarus 3.0/FPC 3.2.2

vfclists

  • Hero Member
  • *****
  • Posts: 1013
    • HowTos Considered Harmful?
Re: What is the difference between a window and a control?
« Reply #5 on: January 21, 2024, 07:04:59 pm »
How do systems like X11 and Microsoft Windows distinguish between windows and controls?

A window are a handle that processes messages (can be non-visual).   A control has screen realestate somewhere.


Can you give an LCL examples of this distinction?

Does this apply to both X11 and Windows?

I would have thought it would be the other way round, with something with visible screen estate being a window, and something handling events being the control. The usual mixed up terminology we get in CS.

« Last Edit: January 21, 2024, 07:08:08 pm by vfclists »
Lazarus 3.0/FPC 3.2.2

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2054
  • Fifty shades of code.
    • Delphi & FreePascal
Re: What is the difference between a window and a control?
« Reply #6 on: January 21, 2024, 07:37:03 pm »
How do systems like Microsoft Windows distinguish between windows and controls?
Code: Pascal  [Select][+][-]
  1. uses
  2.  Windows;
  3.  
  4. function HandleIsWindow(AHandle: HWND): Boolean;
  5. begin
  6.  Result := IsWindow(AHandle) <> 0;
  7. end;
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11448
  • FPC developer.
Re: What is the difference between a window and a control?
« Reply #7 on: January 21, 2024, 09:06:18 pm »
Can you give an LCL examples of this distinction?

Sure TWincontrol vs Forms.allocatehwnd.

440bx

  • Hero Member
  • *****
  • Posts: 4023
Re: What is the difference between a window and a control?
« Reply #8 on: January 21, 2024, 11:36:56 pm »
How do systems like X11 and Microsoft Windows distinguish between windows and controls?

It seems to me that windows are what controls are placed in.
The following is strictly Windows only. 

In Windows, a control is a window with a predetermined function, e.g, edit, combobox, scrollbar, etc, etc. As such, the code that will process the message routed to it is already written (it is identified by the control class name.)

A non-control window, what could be considered a "normal window", is a container that may consist of other windows, such as controls or, non-windowed graphical elements, e.g, lines, curves, etc.  A crucial difference between the two is that, the code that processes messages and therefore determines the function of a non-control window must be programmer-written, IOW, it is not mostly (or entirely) "canned code" that can be identified by referring to a pre-existing class name. 

All of the above said, OOP libraries, such as those used in Lazarus, can blur the distinction between the two to some extent, making it a bit subjective as to what is a window and what is a control.

HTH.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Joanna

  • Hero Member
  • *****
  • Posts: 759
Re: What is the difference between a window and a control?
« Reply #9 on: January 21, 2024, 11:55:50 pm »
Quote
All of the above said, OOP libraries, such as those used in Lazarus, can blur the distinction between the two to some extent, making it a bit subjective as to what is a window and what is a control. 

In Lazarus I believe the twincontrol is a control which can contain other controls. Not all tcontrol descendants can do this of course

The only control that is an independent window is the tform afaik.
« Last Edit: January 22, 2024, 12:18:15 am by Joanna »
✨ 🙋🏻‍♀️ More Pascal enthusiasts are needed on IRC .. https://libera.chat/guides/ IRC.LIBERA.CHAT  Ports [6667 plaintext ] or [6697 secure] channel #fpc  Please private Message me if you have any questions or need assistance. 💁🏻‍♀️

 

TinyPortal © 2005-2018