0

I have my own Form Resize function, but i have problem with TChromium component. When I'm trying to resize Form, TChromium's background color changing to black and blinking fast until resize process stops, instead of it must be white everytime. This bug works only in DelphiXE3. In Delphi7 all fine, but i can't use Delphi7 for some reason(Some TChromium Functions Not Works).

Help me fix this problem, please. Here is my Resize Function code, based on Timer Component(Interval:1):

//-------------------------FORM RESIZE TIMER BEGIN
if(Form1.Width>=((Screen.Width div 2))) then
begin
    if(resize_to=LEF) then
    begin
        //Lets Resize To Left
        if((Form1.Width>((Screen.Width div 2))) OR ((Mouse.CursorPos.X-Last_Cur_POSx)<0)) then 
            Form1.Left:=Mouse.CursorPos.X;

        if((Form1.Width>((Screen.Width div 2))) OR ((Mouse.CursorPos.X-Last_Cur_POSx)<0)) then 
            Form1.Width:=Form1.Width-(Mouse.CursorPos.X-Last_Cur_POSx);

        SetCursorPos(Form1.Left,Mouse.CursorPos.Y);
        Last_Cur_POSx:=Mouse.CursorPos.X; //Remember Last Cursor Position
    end
    else
        if(resize_to=RIGHT) then
        begin
            //Lets Resize To Right
            if((Form1.Width>((Screen.Width div 2))) OR ((Mouse.CursorPos.X-Last_Cur_POSx)>0)) then 
                Form1.Width:=Form1.Width+(Mouse.CursorPos.X-Last_Cur_POSx);

            SetCursorPos(Form1.Left+Form1.Width,Mouse.CursorPos.Y);
            Last_Cur_POSx:=Mouse.CursorPos.X; //Remember Last Cursor Position
        end
        else
            if(resize_to=BOTTOM) then
            begin
                //Lets Resize To Bottom
                if(Form1.Height<(Screen.Height div 2)) then 
                     Form1.Height:=Screen.Height div 2
                else
                    if((Form1.Height-Form1.Top)<=((Screen.Height-Task_Panel_Size)-Form1.Top)) then 
                        Form1.Height:=Form1.Height+(Mouse.CursorPos.Y-Last_Cur_POSy)
                    else 
                        Form1.Height:=((Screen.Height-Task_Panel_Size)-Form1.Top);

                SetCursorPos(Mouse.CursorPos.X,Form1.Top+Form1.Height);
                Last_Cur_POSy:=Mouse.CursorPos.Y; //Remember Last Cursor Position
            end
end
else
begin
    Form1.Width:=(Screen.Width div 2);
end
//-------------------------FORM RESIZE TIMER END

Thanks.

The problem is solved, by adding sleep(100); command in Form1.Paint event :) The problem solved, by removing all handmade resize functions, and activating Form default resizers.
Thanks to everybody for helping

Priler
  • 55
  • 10
  • 1
    Interval 1ms is too low. And, it looks to me not fair to user to move their mouse cursor. – TLama Jul 15 '13 at 21:48
  • But 1ms its minimum value. – Priler Jul 15 '13 at 21:52
  • Low interval = high frequency. – TLama Jul 15 '13 at 22:01
  • 1
    Please [edit] your code to properly indent it. It's pretty much unreadable as it is now. Also, as @TLama said, this code with a `Timer.Interval` of 1 ms means it's going to start running again before the code has much of a chance to complete, which is going to cause painting issues and major flickering. Increase the interval to a higher value (50-100 ms) and see what it changes. – Ken White Jul 16 '13 at 00:45
  • No, settings 50-100ms on Timer changes nothing, still black blinking. But, i solved this problem, by adding sleep(100); on Form1.Paint event :) And now its not blinking :) Thanks for helping! – Priler Jul 16 '13 at 08:24
  • 1
    That's really, really ugly workaround, if I would even call it workaround. – TLama Jul 16 '13 at 10:37
  • Forget it, i have removed all resize function and placed normal Form with Normal resizes. – Priler Jul 16 '13 at 13:44

0 Answers0