Keep a TPanel fixed

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Post Reply
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Keep a TPanel fixed

Post by mark_c »

I created a TForm, added a TPanel and a TImage dynamically. When the image is larger than the TForm, the scroll bars appear. My problem is that the TPanel also moves with the TImage but I would like it to remain fixed.

Code: Select all

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        TForm *MyForm = new TForm(this);
        MyForm->Visible=true;
        MyForm->HorzScrollBar->Visible=true;
        MyForm->VertScrollBar->Visible=true;
        MyForm->Width=1000;
        MyForm->Height=500;

        TPanel *MyPanel = new TPanel(MyForm);
        MyPanel->Parent=MyForm;
        MyPanel->Align=alTop;
        MyPanel->Height=40;

        TImage *Image1 = new TImage(MyForm);
        Image1->Parent=MyForm;
        Image1->Left=0;
        Image1->Top=40;

        Image1->Picture->Bitmap->LoadFromFile("mypicture.bmp");
        Image1->Picture->Bitmap->Width=12000;
        Image1->Picture->Bitmap->Height=2124;
        Image1->Width=12000;
        Image1->Height=2124;



        MyForm->VertScrollBar->Position=900;        
}
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

after many settings I am convinced that it is not possible to block the TPanel which continues to scroll together with the TImage.
How is it possible that there is no way to anchor the TPanel to the title bar so that the TImage flows under the TPanel?
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

sorry but I solved it myself using the ScrollBox component that I had never used: there is always a first time.

Thanks anyway.
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

nothing has changed, I caught a crab.
I want the TPanel to scroll horizontally but remain anchored to the title bar, as if it were a ruler.
HsiaLin
BCBJ Master
BCBJ Master
Posts: 331
Joined: Sun Jul 08, 2007 6:29 pm

Re: Keep a TPanel fixed

Post by HsiaLin »

Set panels Align property to alTop.
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

thanks, but I've already tried that way

look at the Score View of this screen https://ibb.co/c88DnGr the ruler remains stationary and the staff can freely scroll to the right and down
HsiaLin
BCBJ Master
BCBJ Master
Posts: 331
Joined: Sun Jul 08, 2007 6:29 pm

Re: Keep a TPanel fixed

Post by HsiaLin »

That an MDI application it looks like. Multiple document interface.
Last edited by HsiaLin on Wed Apr 08, 2020 7:47 pm, edited 1 time in total.
HsiaLin
BCBJ Master
BCBJ Master
Posts: 331
Joined: Sun Jul 08, 2007 6:29 pm

Re: Keep a TPanel fixed

Post by HsiaLin »

I`m not really sure what you are trying to do but maybe this will help.
If not then i don't know what to tell you.
Attachments
markscrolltest.rar
(187.95 KiB) Downloaded 749 times
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

thanks for trying, the way is that.
However, if you look well, the image must remain fixed to the left and the "page" must scroll below the image. If you look at the image I posted, the piano keyboard remains fixed while the score scrolls below.
HsiaLin
BCBJ Master
BCBJ Master
Posts: 331
Joined: Sun Jul 08, 2007 6:29 pm

Re: Keep a TPanel fixed

Post by HsiaLin »

I was only making the scrolling part for you, you could add another panel to the bottom and put pictures onto it that will not scroll, like the piano is. That whole application in the picture is custom made, you`ll have to do the same with ingenuity.
mark_c
BCBJ Master
BCBJ Master
Posts: 244
Joined: Thu Jun 21, 2012 1:13 am

Re: Keep a TPanel fixed

Post by mark_c »

you're right, I can solve the problem with a second panel on the left.

Thanks
Post Reply