BBC BASIC for Windows
Programming >> BBC BASIC language >> Positioning a property sheet
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1450106394

Positioning a property sheet
Post by AlanRoberts on Dec 14th, 2015, 2:19pm

A dialog box is positioned with x,y coordinates when creating it, but a property sheet ignores all the x,y, coordinates. Is there a way to position a property sheet once it's opened?
Re: Positioning a property sheet
Post by Zaphod on Dec 14th, 2015, 2:53pm

Does this work?

SYS "SetWindowPos", psh%, 0, X%, Y%, 0, 0, 5
Re: Positioning a property sheet
Post by AlanRoberts on Dec 14th, 2015, 5:12pm

Dunno, I'll try ... I'll be back.
Re: Positioning a property sheet
Post by AlanRoberts on Dec 14th, 2015, 5:18pm

Well, it might work, but I can't see how to use it. In the statement, what is psh%?

I created 6 versions of the property sheet so that I can reopen it with the dialog tab that was last used, so I launch it with:

PROC_showpropsheet(ShtTLCI%(ShtOpen%),DlgTLCI%())

... and have just tried:

SYS "SetWindowPos",ShtTLCI%(ShtOpen%),0,200,150,0,0,5

but that doesn't appear to do anything. I'm stumped as usual with SYS calls.
Re: Positioning a property sheet
Post by Zaphod on Dec 14th, 2015, 7:05pm


The variable psh% is the handle of the property sheet that you got when you initialized it using this call from the manual:
psh% = FN_newpropsheet("Property sheet",pages%,0,&20,page%())

It is the handle to the window that all the property sheets (dialogs) sit in. The property sheet container is a window like any other window so when you have its handle, as you do, you can move it and manipulate it like any other window.

The "5" in the SYS "SetWindowPos" call as the last parameter is the Windows constants SWP_NOSIZE OR SWP_NOZORDER
Re: Positioning a property sheet
Post by AlanRoberts on Dec 14th, 2015, 9:04pm

That's what I thought, but, like I said, it doesn't seem to work. Maybe it's because it's an array element in my case. if so, then I;ll pout up with not being able to place it in exchange for the ability to open it on a nominated tab.
Re: Positioning a property sheet
Post by Zaphod on Dec 14th, 2015, 9:39pm


I think you may be getting confused. To show the property sheet you called:

PROC_showpropsheet(psh%,hdlg%())

The psh% is what you want to set the position not the array of dialog handles.
Re: Positioning a property sheet
Post by AlanRoberts on Dec 15th, 2015, 09:12am

Yes, I know about that. I have created 6 identical property sheets so that I can open with the chosen tab. So my equivalent of psh% is an array ShtTLCI%() where the argument is the number of the tab. It works fine, but the positioning doesn't.

I've just tried reverting to a single property sheet, and the SetWindowPos call still doesn't work.
Re: Positioning a property sheet
Post by AlanRoberts on Dec 15th, 2015, 10:11am

The penny has dropped. Because it's a property sheet and not a dialog, the rules are different, so this doesn't work:

SYS "SetWindowPos",ShtTLCI%(ShtOpen%),0,600,300,0,0,5

... but this does -

SYS "SetWindowPos",!ShtTLCI%(ShtOpen%),0,600,300,0,0,5

In the same way, access to the dialog items in a normal dialog need, e.g.:

SYS "SendDlgItemMessage",!dlg%,i%,&143,0,text$

... but in a property sheet it needs -

SYS "SendDlgItemMessage",dlg%,n%,&143,0,text$

If only Richard had told me that a year ago, I wouldn't have wasted so much time. never mind, it works now.


Re: Positioning a property sheet
Post by Zaphod on Dec 15th, 2015, 3:22pm

Sorry, it was me that was confused by your array of property boxes and I was making the same mistake as you.

You are absolutely right the "!" is needed. The container for which we have psh% is actually dialog which needs the indirection to get the handle. The hdlg%() has a clue in that it starts with an "h" and so it IS the handle in this case although the sheets are more dialogs.

That indirection to get the handle of dialogs has caught me out so many times as well. In the case of Property sheets it really does look inconsistent.

Glad you got that sorted and it is a lesson for us all.