How to create a Panel control with win api ?

Windows specific questions.
Post Reply
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

How to create a Panel control with win api ?

Post by kcvinu »

Hi all,
I am trying to create a panel control, but i cant find any help related to it from web. How to create a panel control with CreateWindowex ?
deltarho[1859]
Posts: 4310
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: How to create a Panel control with win api ?

Post by deltarho[1859] »

37 views and no response. I wonder if folks don't know what you mean by 'Panel control' - I don't.

Do you mean invoking the Control Panel programmatically?
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: How to create a Panel control with win api ?

Post by Josep Roca »

A Panel control is a control that allows grouping of other controls.

You can't create a Panel control with CreateWindowEx for the simple reason that Windows doesn't natively provide one. The closest one is a GroupBox control, although it has not scroll bars.
deltarho[1859]
Posts: 4310
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: How to create a Panel control with win api ?

Post by deltarho[1859] »

Blimey, I didn't know what a GroupBox control was either. It turns out to be known as a Frame as well and I have been using Frames for years. <laugh>

Actually, I will have to increase my medication. I used a GroupBox in Encrypternet.bas and called it IDC_FRAME1.

Code: Select all

pWindow.AddControl( "GroupBox", , IDC_FRAME1, "Drag && Drop Or Left Click To browse", 24, 16, 286, 100 )
I have just spotted a remark at the head of one of José's programs.

' Remarks: In PowerBASIC it is mistakenly called "Frame" instead of "Group Box".

We live and learn - although with some of us it takes a while. <smile>
Josep Roca
Posts: 564
Joined: Sep 27, 2016 18:20
Location: Valencia, Spain

Re: How to create a Panel control with win api ?

Post by Josep Roca »

In the beginning it was called a group box, then came the Visual Basic guys and called it a frame control, and now the .NET guys call it a panel control. It's never too late to create confusion.

However, the panel control has some differences with a groupbox or frame control, among them it has no caption and has scrollbars.

In the beginning, a frame (aka framewindow) control was a static (aka label) control with a WS_GROUP and SS_BLACKFRAME, SS_WHITEFRAME or SS_GRAYFRAME styles. A group box, was a button with the WS_GROUP and BS_GROUPBOX styles.

Frame is also used, e.g. in Java, to designate a main window. In HTML defines one particular window (frame) within a "frameset"...
PaulSquires
Posts: 1002
Joined: Jul 14, 2005 23:41

Re: How to create a Panel control with win api ?

Post by PaulSquires »

A "panel" in the context that I think is being considered by the OP is best replicated by creating a normal borderless window and set its style to WS_CHILD. For example, that's how I simulate the various pages of a Tab Control. You can create child controls on this child window and the show/hide them all at once by simply showing/hiding the window itself.
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: How to create a Panel control with win api ?

Post by jj2007 »

The Panel Control is documented here. It is over 15 years old, accessible only via .NOT methods, and nobody uses it. To the point that Google refuses to honour an image search for windows "panel control" - despite the quotes, you get only images for Control Panel. Anybody noticed that Google gets more and more useless with its conviction that it knows better than you what you want?

As some mentioned earlier, a Group Box does maybe the same or better job, given that it has a caption. Scrollbars? You can add one, and move the child controls accordingly.
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: How to create a Panel control with win api ?

Post by grindstone »

jj2007 wrote:Anybody noticed that Google gets more and more useless with its conviction that it knows better than you what you want?
And I thought that it was only a delusion of mine...
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: How to create a Panel control with win api ?

Post by kcvinu »

deltarho[1859] wrote:37 views and no response. I wonder if folks don't know what you mean by 'Panel control' - I don't.

Do you mean invoking the Control Panel programmatically?
Ha ha.. Jose said it. That's a container control.
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: How to create a Panel control with win api ?

Post by kcvinu »

Thank you all for the answers.
Let me try. First of all, i am going to read the web page which jj2007 suggested.
By the way, @PaulSquires, I have tried with these styles-

Code: Select all

const PNL_STYLE : DWORD = WS_CHILD or WS_VISIBLE or WS_CLIPCHILDREN or WS_CLIPSIBLINGS 
const PNL_EX_STYLE : DWORD = WS_EX_CONTROLPARENT or WS_EX_WINDOWEDGE or WS_EX_TRANSPARENT

But didnt worked.
Do i need to use a "#32770" class name ? I am confused.
St_W
Posts: 1626
Joined: Feb 11, 2009 14:24
Location: Austria
Contact:

Re: How to create a Panel control with win api ?

Post by St_W »

jj2007 wrote:The Panel Control is documented here. It is over 15 years old, accessible only via .NOT methods, and nobody uses it.
The link is refererring to an ASP.NET panel, which is something completely different and has absolutely nothing to do with Win32 API (but rather with javascript/html). What you probably meant was a WinForms Panel, and it is used a lot. It does not match a native win32 control directly, but you can find the implementation here: https://referencesource.microsoft.com/# ... 0cc724caad
kcvinu
Posts: 232
Joined: Oct 07, 2015 16:44
Location: Keralam, India

Re: How to create a Panel control with win api ?

Post by kcvinu »

@St_W,
Thanks, THat helped. And you are right. That link says nothing about creating a panel with win32.
BTW, Now, i am able to create a panel in my window. Next hurdle is to change the back color of that panel.
Post Reply