Palette set fixed size - disable resize possibility

Palette set fixed size - disable resize possibility

5thSth
Advocate Advocate
1,204 Views
5 Replies
Message 1 of 6

Palette set fixed size - disable resize possibility

5thSth
Advocate
Advocate

I've managed to get the palette set window to be fixed using this somewhat crude and brute force method:

 

            Timer tDelayedResize = new Timer();
            tDelayedResize.Interval = 5;
            tDelayedResize.Tick += (s, e) =>
            {
                tDelayedResize.Stop();
                //Do your ResizeEnd logic here
                //...
                _ps1.Size = constSize;
            };

            _ps1.SizeChanged += (s, e) =>
            {
                tDelayedResize.Stop();
                tDelayedResize.Start();
            };


        }

 

however, I'm keen on finding a more slick way of achieving fixed palette size

After some soul searching, I came to realize I can hook to windows messages (MINMAXinfo, and similar)

 

for test purposes, I tried doing it on a winform... but still dont have the hang of it.

my ultimate goal would be that "resize cursor" doesnt even appear when hovering over PS corner... but even a constant size would be a treat at this point (my OCD just wont give me rest on this 1 :D)

 

 

 

        private void button1_Click(object sender, EventArgs e)
        {
            if (hHook == 0)
            {
                // Create an instance of HookProc.
                HookProcedure = new HookProc(Form1.WinHookProc);

                hHook = SetWindowsHookEx(   //WH_CALLWNDPROCRET,
                                            WH_CALLWNDPROC,
                                            HookProcedure,
                                            (IntPtr)0,
                                            AppDomain.GetCurrentThreadId());
            }
        }

        public static int WinHookProc(int nCode, IntPtr wParam, IntPtr lParam)
        {
            //Marshall the data from the callback.
            //CWPretStruct MyHookStruct = (CWPretStruct)Marshal.PtrToStructure(lParam, typeof(CWPretStruct));
            CWPSTRUCT MyHookStruct = (CWPSTRUCT)Marshal.PtrToStructure(lParam, typeof(CWPSTRUCT));

            if (nCode < 0)
            {
                return CallNextHookEx(hHook, nCode, wParam, lParam);
            }
            else
            {
                MINMAXINFO mmi = (MINMAXINFO)Marshal.PtrToStructure(MyHookStruct.lparam, typeof(MINMAXINFO));
                
                mmi.ptMaxSize.x = 300;
                mmi.ptMaxSize.y = 300;
                System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, MyHookStruct.lparam, true);

                return CallNextHookEx(hHook, nCode, wParam, lParam);
            }
        }

 

 

 

 

any tips on how to override such features would be graetly appreciated;
If any1 can offer a better solution than my PS code, or a tip when it comes to Hooks, I'd be more than grateful!

1,205 Views
5 Replies
Replies (5)
Message 2 of 6

5thSth
Advocate
Advocate

bump/ cmon guys... any comment would be appreciated at this point 😞

tell me to give up or something 😄

0 Likes
Message 3 of 6

SENL1362
Advisor
Advisor

Sorry, playing with Fixed values for sizes in de WPF definitions did not prevent the Panel to be resized. It prevent the UserControl to be resized but i think that's not enough

 

 

0 Likes
Message 4 of 6

5thSth
Advocate
Advocate

can you pls post the code for WPF definition override(if you've done it through hooks). maybe I learn something from it. 

 

 

0 Likes
Message 5 of 6

SENL1362
Advisor
Advisor

I doub't having code that benefits you because youre code already exceeded mine.

I "fixed" the sizes in the XAML to see what the behaviour would be for the Palette(set)-- so no hooks.

The result is that the UserControl stays fixed but the Palette keeps resizing, and it does not prevent the resize pointer to popup.

 

 

<UserControl x:Class="..FixedUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" Height="300" Width="400"  d:DesignHeight="300" d:DesignWidth="400">
   
    <Grid Background="White" >
        <Grid.RowDefinitions>
            <RowDefinition Height="200"/>
            <RowDefinition Height="50" MinHeight="50" MaxHeight="50" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="300" />
            <ColumnDefinition Width="100" MinWidth="100" MaxWidth="100"/>
        </Grid.ColumnDefinitions>

        <Grid  Grid.Row="0" Grid.Column="0"  >
            <TextBlock Name="tbkLayers"  Text="{Binding LayerText}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"  Margin="5" TextWrapping="Wrap" />
        </Grid>

        <Grid  Grid.Row="1" Grid.ColumnSpan="2" >
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="5" >
                <Button  Name="btnOk" Content="OK"  MinWidth="150" MaxWidth="150"  Margin="5"  Click="btnOk_Click"/>
                <Button  Name="btnCancel" Content="Cancel"  MinWidth="150" MaxWidth="150"   Margin="5" IsCancel="True"   Click="btnCancel_Click"/>
            </StackPanel>
        </Grid>

    </Grid>
</UserControl>
0 Likes
Message 6 of 6

5thSth
Advocate
Advocate

thanks for your reply. I'll try getting some more help on c#,c++ forum if no1 else chips in. 

As for PS, its a shame that it doesnt have an "on event ended" event. I've tried a bunch of techniques, (derived classes, and INotifyPropertyChanged, but proved I wasnt skilled enough :()

0 Likes