How to do flickerfree resizing of gadgets?
Re: How to do flickerfree resizing of gadgets?
Afraid not. Still the same.
I may look like a mule, but I'm not a complete ass.
Re: How to do flickerfree resizing of gadgets?
Also without StopWindowUpdate() + ContinueWindowUpdate()?
Re: How to do flickerfree resizing of gadgets?
No change (still flickers badly) except that the UI then becomes corrupted because certain parts of it are not repainted.
I may look like a mule, but I'm not a complete ass.
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: How to do flickerfree resizing of gadgets?
I already tried to simulate FrameGaget by using multiple images to create a frame, but I stopped that - it's to much work...
Another point to erase the icons background is seen below, interestingly it works for some icons but not for all here:
Another point to erase the icons background is seen below, interestingly it works for some icons but not for all here:
Code: Select all
; Define;
#WinW=720
#WinH=552
#WinZ=400
Global WinID;
Enumeration;
#StrName; 0;
#StrExt; 1;
#StrOutput; 2;
#IcoName; 3;
#IcoExt; 4;
#IcoOut; 5;
#IcoSearch;
#IcoReplace;
#WinID;
#Frm01;
#Frm02;
#Frm03;
#TxtInfo;
#TxtName;
#TxtExt;
#TxtOutput;
#StrInfo;
#TxtSearch;
#TxtReplace;
#FlgOutCase;
#FlgNameOnly;
#FlgCase;
#FlgAll;
#FlgDate;
#List;
#ButRename;
#ButClose;
#ButProfile;
#ButFilter;
#ButExtras;
#TxtWriteName;
#TxtWriteExt;
#StrSearch;
#StrReplace;
#StrWriteName; \;
#StrWriteExt ; /;
#KeySearch;
#KeyReplace;
#IconOk ;
#IconKill
EndEnumeration;
Enumeration
#WriteUnchanged;
#WriteAllLower;
#WriteWordUpper;
#WriteAllUpper;
EndEnumeration;
Enumeration;
#ListOldName;
#ListNewName;
#ListSize;
#ListDate;
#ListState;
EndEnumeration;
DataSection;
IconOk: ; 1406 Bytes;
Data.q $1010000100010000,$568000800010000,$28000000160000,$20000000100000,$800010000;
Data.q $1000000,$100000000000000,$3737000001000000,$CB4A0089B5320037,$FFFF00B5E15D009F;
Data.q $FF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$505000000000000,$505050505050505,$505050505050505;
Data.q $505050505050505,$505050505050505,$505050500050505,$505050505050505,$505050001000505;
Data.q $505050505050505,$505000102020005,$505050505050505,$500010202020200,$5050505050505;
Data.q $1020300020202,$300050505050505,$102030005000202,$5050505050500,$203000505050003;
Data.q $505050505050001,$300050505050500,$505050505000102,$5050505050505,$505050500010203;
Data.q $505050505050505,$505050001020300,$505050505050505,$505050500030005,$505050505050505;
Data.q $505050505000505,$505050505050505,$505050505050505,$505050505050505,$FFFF050505050505;
Data.q $FFFB0000FFFF0000,$FFE00000FFF10000,$3F8000007FC00000,$F8E00001F040000,$83FF000007DF0000;
Data.q $E3FF0000C1FF0000,$FFFF0000F7FF0000,$FFFF0000;
EndDataSection;
; EndDefine;
Procedure SmoothGadgetIcon(gadget,icon,tooltip.s);
;
icon=ImageID(icon);
;
If GetGadgetState(gadget)<>icon;
SetGadgetState(gadget,icon);
GadgetToolTip(gadget,tooltip);
EndIf;
;
EndProcedure;
Procedure ResizeComboGadget(gadget,x,y,width,height);
;
ResizeGadget(gadget,x,y,width,height);
If GetActiveGadget()<>gadget;
SendMessage_(GadgetID(gadget),#CB_SETEDITSEL,0,-1);
EndIf;
;
EndProcedure;
Procedure Events();
;
Protected x,y,n,m;
Protected z,z0,z1,z2;
;
If EventWindow()=#WinID;
x=WindowWidth(#WinID);
y=WindowHeight(#WinID);
If GadgetWidth(#TxtInfo)=x;
ResizeGadget(#List,#PB_Ignore,#PB_Ignore,#PB_Ignore,y-262);
ResizeGadget(#TxtInfo,#PB_Ignore,y-22,#PB_Ignore,#PB_Ignore);
ResizeGadget(#StrInfo,#PB_Ignore,y-18,#PB_Ignore,#PB_Ignore);
Else;
;
SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#False,0);
n=(x-#WinW)/5;
ResizeGadget(#List,#PB_Ignore,#PB_Ignore,x-26,y-262); 720-694;
ResizeGadget(#TxtInfo,#PB_Ignore,y-22,x,#PB_Ignore);;
ResizeComboGadget(#StrInfo,#PB_Ignore,y-18,#PB_Ignore,#PB_Ignore);;
;
y=n<<1;
m=n<<2;
ResizeGadget(#Frm01,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore); 720-560;
ResizeGadget(#Frm02,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore); 720-560;
ResizeGadget(#Frm03,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore); 720-560;
;
x=y+n>>1;
z0=207+x; Position (105) + Breite (207) + Verbreiterung (x);
ResizeComboGadget(#StrName,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
ResizeComboGadget(#StrOutput,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
ResizeComboGadget(#StrSearch,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
ResizeComboGadget(#StrReplace,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
z0+100;
ResizeComboGadget(#IcoName,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeComboGadget(#IcoOut,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeComboGadget(#IcoReplace,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeComboGadget(#IcoSearch,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
;
x=y+(n*3)>>2;
z=125+(n*5)>>2;
ResizeGadget(#TxtExt,345+x,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#StrExt,410+x,#PB_Ignore,z,#PB_Ignore);;
ResizeGadget(#IcoExt,415+x+z,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#FlgOutCase,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#FlgNameOnly,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#FlgCase,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#FlgAll,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
;
If n>40;
z=40;
Else;
z=n;
EndIf;
;
z1=240+n;
z2=455+y+n;
;
If m>120;
If m>260;
z=7+n>>1;
z1=z0-z-175;
z2=346+x;
EndIf;
x=136;
Else;
x=76;
EndIf;
;
ResizeGadget(#StrWriteName,#PB_Ignore,#PB_Ignore,100+z,#PB_Ignore);;
ResizeGadget(#TxtWriteExt,z1,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeGadget(#StrWriteExt,z1+70,#PB_Ignore,100+z,#PB_Ignore);;
ResizeGadget(#FlgDate,z2,#PB_Ignore,x,#PB_Ignore)
;
ResizeGadget(#ButRename,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButClose,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButProfile,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButExtras,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButFilter,585+m,#PB_Ignore,115+n,#PB_Ignore) ;;
;
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListOldName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListNewName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,78+n,#ListState);
;
SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#True,0);
For i=#StrName To #IcoOut
SetGadgetState(i,ImageID(#IconKill))
Next i
InvalidateRgn_(WindowID(#WinID),0,1);
For i=#StrName To #IcoOut
SetGadgetState(i,ImageID(#IconOk))
Next i
EndIf;
EndIf;
;
EndProcedure;
Procedure Init();
;
Protected i;
Protected makro;
Protected flag;
Protected s.s;
CatchImage(#IconOk,?IconOk);
CreateImage(#IconKill,16,16,32,GetSysColor_(#COLOR_BTNFACE))
;
WinID=OpenWindow(#WinID,0,0,#WinW,#WinH,"",#WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_Invisible|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget);
WindowBounds(#WinID,#WinW,#WinZ,#PB_Default,#PB_Default);
;
FrameGadget(#Frm01,10,10,560,72,"Reguläre Ausdrücke");
TextGadget(#TxtName,20,30,60,20,"Datei&name:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrName,95,29,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoName,307,32,16,16,ImageID(#IconOk));
TextGadget(#TxtExt,345,30,75,20,"&Erweiterung:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrExt,410,29,125,22,#PB_ComboBox_Editable);
ImageGadget(#IcoExt,540,32,16,16,ImageID(#IconOk));
TextGadget(#TxtOutput,20,55,60,20,"Ändern &in:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrOutput,95,54,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoOut,307,57,16,16,ImageID(#IconOk));
CheckBoxGadget(#FlgOutCase,346,55,175,22," &Groß-/Kleinschreibung beachten");
;
FrameGadget(#Frm02,10,90,560,72,"Suchen und Ersetzen");
TextGadget(#TxtSearch,20,110,100,20,"&Anfangs:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrSearch,95,109,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoSearch,307,112,16,16,ImageID(#IconOk));
;
TextGadget(#TxtReplace,20,135,100,20,"A&bschließend:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrReplace,95,134,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoReplace,307,137,16,16,ImageID(#IconOk));
;
CheckBoxGadget(#FlgNameOnly,346,104,180,18," Nur den Dateina&men verändern");
CheckBoxGadget(#FlgCase,346,122,175,18," Groß-/&Kleinschreibung beachten");
CheckBoxGadget(#FlgAll,346,140,175,18," Alle &Vorkommen ersetzen");
;
FrameGadget(#Frm03,10,168,560,48,"Erweitert");
TextGadget(#TxtWriteName,20,188,75,20,"Schreib&weise:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrWriteName,95,188,100,20);
TextGadget(#TxtWriteExt,240,188,70,20,"Erwei&terung:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrWriteExt,310,188,100,20);
CheckBoxGadget(#FlgDate,455,188,76,18," Datei&datum aktualisieren"); 140;
;SetWindowLongPtr_(GadgetID(#Frm03),#GWL_HWNDPARENT,GadgetID(#TxtWriteName))
;
For i=0 To 1;
AddGadgetItem(#StrWriteName+i,#WriteUnchanged,"Unverändert");
AddGadgetItem(#StrWriteName+i,#WriteAllLower,"Alles klein");
AddGadgetItem(#StrWriteName+i,#WriteWordUpper,"Wortanfänge groß");
AddGadgetItem(#StrWriteName+i,#WriteAllUpper,"Alles groß");
Next i;
;
ListIconGadget(#List,10,230,694,285," ·",20,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines);
;SetGadgetColor(#List,#PB_ListIcon_GridLines,#Black);
AddGadgetColumn(#List,#ListOldName,"Alter Dateiname",210);
AddGadgetColumn(#List,#ListNewName,"Neuer Dateiname",210);
AddGadgetColumn(#List,#ListSize,"Größe",52);
AddGadgetColumn(#List,#ListDate,"Datum",102);
AddGadgetColumn(#List,#ListState,"Status",78);
EnableGadgetDrop(#List,#PB_Drop_Files,#PB_Drag_Move|#PB_Drag_Copy);
;
Global lvm.LV_COLUMN;
lvm\mask=#LVCF_FMT;
lvm\fmt=#LVCFMT_CENTER;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListDate,@lvm);
lvm\mask=#LVCF_FMT;
lvm\fmt=#LVCFMT_RIGHT;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListSize,@lvm);
;
FrameGadget(#TxtInfo,0,530,#WinW,2,"",#PB_Frame_Single);
TextGadget(#StrInfo,0,534,999,16,"",#SS_CENTERIMAGE);
;
ButtonGadget(#ButRename,585,15,115,30,"&Umbenennen",#PB_Button_Default);
ButtonGadget(#ButClose,585,53,115,30,"S&chließen");
ButtonGadget(#ButProfile,585,95,115,30,"&Profile");
ButtonGadget(#ButExtras,585,132,115,30,"S&onderfunktionen");
ButtonGadget(#ButFilter,585,180,115,30,"Ergebnisliste &filtern",#PB_Button_Toggle);
;
BindEvent(#PB_Event_SizeWindow,@Events(),#WinID);
;
SetActiveWindow(#WinID);
SetActiveGadget(#StrName);
HideWindow(#WinID,#Null) ;
SmartWindowRefresh(#WinID,#True)
EndProcedure;
Init()
ResizeWindow(#WinID,10,10,1000,#PB_Ignore)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Re: How to do flickerfree resizing of gadgets?
The only way I've found to stop the flickering for all programs on my PC is to clear the Windows system-level parameter "Show windows contents while dragging". That way, when a window is resized the contents are only redrawn when the user releases the mouse button. Hence, no flickering at all, in anything being resized.HanPBF wrote:Would also really be happy about a solution.
I checked some programs; for example PowerGrep from JustGreatSoftware.
The program has a complex GUI and... it flickers...
Maybe a general windows problem.
Even Excel 2010 in Win7; standard win32 controls are flickering.
Annoying...
Being a system-wide parameter it applies to all programs but it has the drawbacks of (1) you can't see the impact of the resize until you release the mouse and (2) it doesn't help other users if your PB program causes flicker when the option is enabled (unless they have it cleared too). For me though, it works very well.
Hopefully the PB geniuses above can come up with a programmatic solution / strategy for individual PB programs so that at least our work can look good
Windows 10 and PB 5.73 (both x64)
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: How to do flickerfree resizing of gadgets?
Okay, another idea - even it look a little bit old schoolGadget wrote:... to clear the Windows system-level parameter "Show windows contents while dragging".
Hopefully the PB geniuses above can come up with a programmatic solution / strategy for individual PB programs so that at least our work can look good
Code: Select all
state.i
If SystemParametersInfo_(#SPI_GETDRAGFULLWINDOWS,0,@state,0)
SystemParametersInfo_(#SPI_SETDRAGFULLWINDOWS,state!1,0,0); invert old state (0=off, 1=on)
EndIf
Re: How to do flickerfree resizing of gadgets?
If you do so
Code: Select all
; Define;
#WinW=720
#WinH=552
#WinZ=400
Global WinID;
Enumeration;
#StrName; 0;
#StrExt ; 1;
#StrOutput; 2;
#IcoName ; 3;
#IcoExt ; 4;
#IcoOut ; 5;
#IcoSearch;
#IcoReplace;
#WinID;
#Frm01;
#Frm02;
#Frm03;
#TxtInfo;
#TxtName;
#TxtExt ;
#TxtOutput;
#StrInfo ;
#TxtSearch;
#TxtReplace;
#FlgOutCase;
#FlgNameOnly;
#FlgCase ;
#FlgAll ;
#FlgDate ;
#List ;
#ButRename ;
#ButClose ;
#ButProfile ;
#ButFilter ;
#ButExtras ;
#TxtWriteName;
#TxtWriteExt ;
#StrSearch ;
#StrReplace ;
#StrWriteName; \;
#StrWriteExt ; /;
#KeySearch ;
#KeyReplace ;
#IconOk ;
EndEnumeration ;
Enumeration
#WriteUnchanged;
#WriteAllLower ;
#WriteWordUpper;
#WriteAllUpper ;
EndEnumeration ;
Enumeration;
#ListOldName;
#ListNewName;
#ListSize ;
#ListDate ;
#ListState ;
EndEnumeration ;
DataSection;
IconOk:; 1406 Bytes;
Data.q $1010000100010000,$568000800010000,$28000000160000,$20000000100000,$800010000;
Data.q $1000000,$100000000000000,$3737000001000000,$CB4A0089B5320037,$FFFF00B5E15D009F;
Data.q $FF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$505000000000000,$505050505050505,$505050505050505;
Data.q $505050505050505,$505050505050505,$505050500050505,$505050505050505,$505050001000505 ;
Data.q $505050505050505,$505000102020005,$505050505050505,$500010202020200,$5050505050505 ;
Data.q $1020300020202,$300050505050505,$102030005000202,$5050505050500,$203000505050003 ;
Data.q $505050505050001,$300050505050500,$505050505000102,$5050505050505,$505050500010203 ;
Data.q $505050505050505,$505050001020300,$505050505050505,$505050500030005,$505050505050505 ;
Data.q $505050505000505,$505050505050505,$505050505050505,$505050505050505,$FFFF050505050505 ;
Data.q $FFFB0000FFFF0000,$FFE00000FFF10000,$3F8000007FC00000,$F8E00001F040000,$83FF000007DF0000 ;
Data.q $E3FF0000C1FF0000,$FFFF0000F7FF0000,$FFFF0000 ;
EndDataSection ;
; EndDefine;
Structure GadgetResizeInfo
gadget.i
x.i
y.i
width.i
height.i
EndStructure
Global NewList gadgetsForResizing.GadgetResizeInfo()
DeclareModule RS_gadget
EnableExplicit
;
#PB_Align_Avto =1<<0
#PB_Align_Left =1<<1
#PB_Align_Top =1<<2
#PB_Align_Right =1<<3
#PB_Align_Bottom =1<<4
#PB_Align_Full =1<<5
#PB_Align_Center =1<<6
#PB_Align_Client =1<<7
#PB_Align_Botton_Right = #PB_Align_Left|#PB_Align_Bottom|#PB_Align_Right
#PB_Align_Top_Right = #PB_Align_Left|#PB_Align_Top|#PB_Align_Right
#PB_Align_Right_Botton = #PB_Align_Right|#PB_Align_Bottom
#PB_Align_Left_Botton = #PB_Align_Left|#PB_Align_Bottom
#PB_Align_Right_Top = #PB_Align_Right|#PB_Align_Top
#PB_Align_Left_Top = #PB_Align_Left|#PB_Align_Top
Declare RS_Resize()
Declare RS_Init(RS_Window)
Declare RS_UnRegister(RS_Gadget)
Declare RS_Use_ParentID(RS_ParentID)
Declare RS_Register(RS_Gadget, RS_Flags, RS_gap_x = #False, RS_gap_y = #False)
EndDeclareModule
Module RS_Gadget
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Import ""
CompilerElse
ImportC ""
CompilerEndIf
PB_Object_EnumerateStart( PB_Objects )
PB_Object_EnumerateNext( PB_Objects, *ID.Integer )
PB_Object_EnumerateAbort( PB_Objects )
PB_Object_Count( PB_Objects )
PB_Window_Objects.i
PB_Gadget_Objects.i
EndImport
Structure RS_Struct
ParentID.l
Gadget.l
Parent.l
X.l
Y.l
Width.l
Height.l
Top.l
Left.l
Right.l
Bottom.l
Flags.l
EndStructure
Global NewList RS_Parents.RS_Struct()
Global NewList RS_Gadgets.RS_Struct()
; RS_Resize - Resize all registered gadgets for the resizing window.
; Parameters: Parent ID (long).
Procedure RS_Resize()
Protected RS_x, RS_y, RS_w, RS_h, RS_Parent, RS_ParentID
If ListSize(RS_Parents())
ForEach RS_Parents()
RS_Parent = RS_Parents()\Parent
RS_ParentID = RS_Parents()\ParentID
If (IsWindow(RS_Parent) And WindowID(RS_Parent) = RS_ParentID)
RS_w = WindowWidth(RS_Parent)
RS_h = WindowHeight(RS_Parent)
ElseIf (IsGadget(RS_Parent) And GadgetID(RS_Parent) = RS_ParentID)
If GadgetType(RS_Parent) = #PB_GadgetType_Panel
Rs_w = GetGadgetAttribute(RS_Parent, #PB_Panel_ItemWidth)
Rs_h = GetGadgetAttribute(RS_Parent, #PB_Panel_ItemHeight)
Else
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Protected RECT.RECT : GetClientRect_(RS_ParentID,RECT.RECT)
Rs_w = GadgetWidth(RS_Parent) - ((GadgetWidth(RS_Parent)-(RECT\right - RECT\left)) )
Rs_h = GadgetHeight(RS_Parent) - ((GadgetHeight(RS_Parent)-(RECT\bottom - RECT\top)) )
CompilerElse
; TODO
RS_w = GadgetWidth(RS_Parent)
RS_h = GadgetHeight(RS_Parent)
CompilerEndIf
EndIf
EndIf
If ListSize(RS_gadgets()) And ((RS_Parents()\Width <> Rs_w) Or (RS_Parents()\Height <> Rs_h)) : RS_Parents()\Width = Rs_w : RS_Parents()\Height = Rs_h
ForEach RS_gadgets()
If RS_gadgets()\ParentID = RS_ParentID
If ((RS_gadgets()\Flags & #PB_Align_Left) = #PB_Align_Left)
If ((RS_gadgets()\Flags & #PB_Align_Right) = #PB_Align_Right) ; По ширине
ResizeGadget(RS_gadgets()\Gadget, #PB_Ignore, #PB_Ignore, ((RS_w - GadgetX(RS_gadgets()\Gadget)) - RS_gadgets()\Right), #PB_Ignore)
EndIf
Else
RS_x = (RS_w - RS_gadgets()\Left)
If Not ((RS_gadgets()\Flags & #PB_Align_Right) = #PB_Align_Right)
RS_x = (RS_gadgets()\X + ((RS_x - RS_gadgets()\X) / 2)) ; Середина по вертикали
EndIf
ResizeGadget(RS_gadgets()\Gadget, RS_x, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndIf
If ((RS_gadgets()\Flags & #PB_Align_Top) = #PB_Align_Top)
If ((RS_gadgets()\Flags & #PB_Align_Bottom) = #PB_Align_Bottom) ; По высоте
ResizeGadget(RS_gadgets()\Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, ((RS_h - GadgetY(RS_gadgets()\Gadget)) - RS_gadgets()\Bottom))
EndIf
Else
RS_y = (RS_h - RS_gadgets()\Top)
If Not ((RS_gadgets()\Flags & #PB_Align_Bottom) = #PB_Align_Bottom)
RS_y = (RS_gadgets()\Y + ((RS_y - RS_gadgets()\Y) / 2)) ; Середина по горизонтали
EndIf
ResizeGadget(RS_gadgets()\Gadget, #PB_Ignore, RS_y, #PB_Ignore, #PB_Ignore)
EndIf
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
If GadgetType(RS_gadgets()\Gadget) = #PB_GadgetType_Frame
RedrawWindow_(GadgetID(RS_gadgets()\Gadget), 0, 0, #RDW_ALLCHILDREN|#RDW_UPDATENOW)
EndIf
RedrawWindow_(RS_ParentID, 0, 0, #RDW_ALLCHILDREN|#RDW_UPDATENOW)
CompilerEndIf
EndIf
Next
EndIf
Next
EndIf
EndProcedure
Procedure RS_Align(RS_ParentID, RS_w, RS_h)
Protected RS_Flags, RS_Parent, RS_Gadget, RS_x, RS_y
If ListSize(RS_gadgets())
If RS_gadgets()\ParentID = RS_ParentID
RS_Flags = RS_gadgets()\Flags
RS_gadget = RS_gadgets()\Gadget
RS_Parent = RS_gadgets()\Parent
Protected RS_gap_x = GadgetX(RS_Gadget)
Protected RS_gap_y = GadgetY(RS_Gadget)
If (((RS_Flags & #PB_Align_Left) = #PB_Align_Left) And ((RS_Flags & #PB_Align_Top) = #PB_Align_Top) ) And (((RS_Flags & #PB_Align_Right) = #PB_Align_Right) And ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom) ) ; (RS_gadgets()\Lock_left And RS_gadgets()\Lock_top) And (RS_gadgets()\Lock_right And RS_gadgets()\Lock_bottom)
ResizeGadget(RS_gadget, RS_gap_x, RS_gap_y, Rs_w-RS_gap_x*2, Rs_h-RS_gap_y*2)
Else
If ((RS_Flags & #PB_Align_Left) = #PB_Align_Left)
If ((RS_Flags & #PB_Align_Right) = #PB_Align_Right)
If ((RS_Flags & #PB_Align_Top) = #PB_Align_Top) Or (((RS_Flags & #PB_Align_Right) = #PB_Align_Right) And ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom) ); RS_gadgets()\Lock_top Or (RS_gadgets()\Lock_right And RS_gadgets()\Lock_bottom)
ResizeGadget(RS_gadget, (Rs_w - GadgetWidth(RS_gadget)) /2, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndIf
ResizeGadget(RS_gadget, #PB_Ignore, #PB_Ignore, (Rs_w - GadgetX(RS_gadget)) - (Rs_w - (GadgetX(RS_gadget) + GadgetWidth(RS_gadget))), #PB_Ignore)
Else
If ((RS_Flags & #PB_Align_Top) = #PB_Align_Top)
ResizeGadget(RS_gadget, RS_gap_x, RS_gap_y, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
Else
RS_x = (Rs_w - GadgetWidth(RS_gadget))-RS_gap_y
If Not ((RS_Flags & #PB_Align_Right) = #PB_Align_Right)
RS_x = GadgetX(RS_gadget) + ((RS_x - (GadgetX(RS_gadget) - RS_gap_y)) /2) ; Середина по вертикали
EndIf
ResizeGadget(RS_gadget, RS_x, #PB_Ignore, #PB_Ignore, #PB_Ignore)
If ((RS_Flags & #PB_Align_Top) = #PB_Align_Top)
ResizeGadget(RS_gadget, #PB_Ignore, RS_gap_y, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
If ((RS_Flags & #PB_Align_Top) = #PB_Align_Top)
If ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom)
If ((RS_Flags & #PB_Align_Left) = #PB_Align_Left) Or (((RS_Flags & #PB_Align_Right) = #PB_Align_Right) And ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom) ) ; RS_gadgets()\Lock_left Or (RS_gadgets()\Lock_bottom And RS_gadgets()\Lock_right)
ResizeGadget(RS_gadget, #PB_Ignore, (Rs_h - GadgetHeight(RS_gadget)) /2, #PB_Ignore, #PB_Ignore)
EndIf
ResizeGadget(RS_gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, (Rs_h - GadgetY(RS_gadget)) - (Rs_h - (GadgetY(RS_gadget) + GadgetHeight(RS_gadget))))
Else
If ((RS_Flags & #PB_Align_Left) = #PB_Align_Left)
ResizeGadget(RS_gadget, RS_gap_x, RS_gap_y, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
Else
RS_y = (Rs_h - GadgetHeight(RS_gadget))-RS_gap_y
If Not ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom)
RS_y = (GadgetY(RS_gadget) + ((RS_y - (GadgetY(RS_gadget) - RS_gap_y)) /2)) ; Середина по горизонтали
EndIf
ResizeGadget(RS_gadget, #PB_Ignore, RS_y, #PB_Ignore, #PB_Ignore)
If ((RS_Flags & #PB_Align_Left) = #PB_Align_Left)
ResizeGadget(RS_gadget, RS_gap_x, #PB_Ignore, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
EndIf
EndIf
EndIf
EndProcedure
;PROCEDURES
; RS_Register - Register Gadget to be resized and how to resize.
; Specify #TRUE for each side of the Gadget you want to LOCK, else #FALSE.
; Parameters: Window (long), Gadget (long), Left (boolean), Top (boolean), Right (boolean), Bottom (boolean).
Procedure RS_Register(RS_Gadget, RS_Flags, RS_gap_x = #False, RS_gap_y = #False) ;
Protected RS_x.l, RS_y.l, RS_w.l, RS_h.l
If IsGadget(RS_Gadget)
If ListSize(RS_Parents())
If Not (GadgetX(RS_Gadget)+GadgetY(RS_Gadget))
RS_Flags = RS_Flags | #PB_Align_Avto
EndIf
If (RS_Flags & #PB_Align_Avto) = #PB_Align_Avto
If (RS_Flags & #PB_Align_Full) = #PB_Align_Full
RS_Flags = #PB_Align_Avto|#PB_Align_Left|#PB_Align_Top|#PB_Align_Right|#PB_Align_Bottom
EndIf
If (RS_Flags & #PB_Align_Center) = #PB_Align_Center
RS_Flags = #PB_Align_Avto
EndIf
Else
If (RS_Flags & #PB_Align_Center) = #PB_Align_Center
RS_Flags = #False
EndIf
If (RS_Flags & #PB_Align_Full) = #PB_Align_Full
RS_Flags = #PB_Align_Left|#PB_Align_Top|#PB_Align_Right|#PB_Align_Bottom
EndIf
EndIf
AddElement(RS_gadgets())
RS_gadgets()\Flags = RS_Flags
RS_gadgets()\Gadget = RS_Gadget
RS_gadgets()\Parent = RS_Parents()\Parent
RS_gadgets()\ParentID = RS_Parents()\ParentID
If IsWindow(RS_gadgets()\Parent) And
WindowID(RS_gadgets()\Parent) = RS_gadgets()\ParentID
Rs_w = WindowWidth(RS_gadgets()\Parent)
Rs_h = WindowHeight(RS_gadgets()\Parent)
ElseIf IsGadget(RS_gadgets()\Parent) And
GadgetID(RS_gadgets()\Parent) = RS_gadgets()\ParentID
If GadgetType(RS_gadgets()\Parent) = #PB_GadgetType_Panel
Rs_w = GetGadgetAttribute(RS_gadgets()\Parent, #PB_Panel_ItemWidth)
Rs_h = GetGadgetAttribute(RS_gadgets()\Parent, #PB_Panel_ItemHeight)
Else
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Protected RECT.RECT : GetClientRect_(RS_gadgets()\ParentID,RECT.RECT)
Rs_w = GadgetWidth(RS_gadgets()\Parent) - ((GadgetWidth(RS_gadgets()\Parent)-(RECT\right - RECT\left)) )
Rs_h = GadgetHeight(RS_gadgets()\Parent) - ((GadgetHeight(RS_gadgets()\Parent)-(RECT\bottom - RECT\top)) )
CompilerElse
; TODO
RS_w = GadgetWidth(RS_gadgets()\Parent)
RS_h = GadgetHeight(RS_gadgets()\Parent)
CompilerEndIf
EndIf
EndIf
If (RS_Flags & #PB_Align_Avto) = #PB_Align_Avto
RS_Align(RS_gadgets()\ParentID, Rs_w, Rs_h)
EndIf
RS_x = GadgetX(RS_Gadget)
RS_y = GadgetY(RS_Gadget)
If ((RS_Flags & #PB_Align_Left) = #PB_Align_Left)
If ((RS_Flags & #PB_Align_Right) = #PB_Align_Right)
RS_gadgets()\Right = Rs_w - (RS_x + GadgetWidth(RS_Gadget))
EndIf
Else
RS_gadgets()\X = RS_x
RS_gadgets()\Left = Rs_w - RS_x
EndIf
If ((RS_Flags & #PB_Align_Top) = #PB_Align_Top)
If ((RS_Flags & #PB_Align_Bottom) = #PB_Align_Bottom)
RS_gadgets()\Bottom = Rs_h - (RS_y + GadgetHeight(RS_Gadget))
EndIf
Else
RS_gadgets()\Y = RS_y
RS_gadgets()\Top = Rs_h - RS_y
EndIf
EndIf
EndIf
EndProcedure
; RS_Unregister - Unregister Gadget from resizing
Procedure RS_UnRegister(RS_gadget)
ForEach RS_gadgets()
If (RS_gadgets()\Gadget = RS_gadget)
DeleteElement(RS_gadgets())
EndIf
Next
EndProcedure
; RS_Use - Use resizing Parent
Procedure RS_Use_ParentID(RS_ParentID)
Protected Window, Gadget
AddElement(RS_Parents())
PB_Object_EnumerateStart( PB_Window_Objects )
If PB_Window_Objects
While PB_Object_EnumerateNext(PB_Window_Objects, @Window )
If WindowID( Window ) = RS_ParentID
RS_Parents()\Parent = Window
RS_Parents()\ParentID = WindowID( Window )
ProcedureReturn Window
EndIf
Wend
PB_Object_EnumerateAbort( PB_Window_Objects )
EndIf
PB_Object_EnumerateStart( PB_Gadget_Objects )
If PB_Gadget_Objects
While PB_Object_EnumerateNext(PB_Gadget_Objects, @Gadget )
If GadgetID( Gadget ) = RS_ParentID
RS_Parents()\Parent = Gadget
RS_Parents()\ParentID = GadgetID( Gadget )
ProcedureReturn Gadget
EndIf
Wend
PB_Object_EnumerateAbort( PB_Gadget_Objects )
EndIf
ProcedureReturn #PB_Any
EndProcedure
; RS_Init - Init resizing
Procedure RS_Init(RS_window)
;SmartWindowRefresh(RS_window, #True)
AddWindowTimer(RS_window,#PB_Ignore,2)
BindEvent(#PB_Event_Timer,@RS_Resize(),RS_window)
RS_Use_ParentID(UseGadgetList(0))
EndProcedure
; RS_Free - Free init resizing
Procedure RS_Free(RS_window)
ForEach RS_gadgets()
If (RS_gadgets()\Gadget = RS_window)
DeleteElement(RS_gadgets())
EndIf
Next
EndProcedure
EndModule
Procedure Clipgadgets( WindowID ) ;
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Protected Dim EnumerateList.I(0)
Protected gadgetID
If FindWindowEx_( FindWindowEx_( WindowID, 0,0,0 ), 0,0,0 ) = #False
gadgetID = FindWindowEx_( WindowID, 0,0,0 )
Else
gadgetID = FindWindowEx_( FindWindowEx_( WindowID, 0,0,0 ), 0,0,0 )
EndIf
; Debug ""
; Debug FindWindowEx_( WindowID, 0,0,0 )
; Debug FindWindowEx_( FindWindowEx_( WindowID, 0,0,0 ), 0,0,0 )
; Debug FindWindowEx_( FindWindowEx_( FindWindowEx_( WindowID, 0,0,0 ), 0,0,0 ), 0,0,0 )
While gadgetID
If gadgetID
If GetWindowLongPtr_( gadgetID, #GWL_STYLE ) & #WS_CLIPSIBLINGS = #False
Protected Gadget = GetProp_( gadgetID, "PB_ID" ) ; IDgadget( gadgetID )
If ( IsGadget( Gadget ) And GadgetID( Gadget ) = gadgetID )
Protected Height = GadgetHeight( Gadget )
SetWindowLongPtr_( gadgetID, #GWL_STYLE, GetWindowLongPtr_( gadgetID, #GWL_STYLE )|#WS_CLIPSIBLINGS )
ResizeGadget( Gadget, #PB_Ignore, #PB_Ignore, #PB_Ignore, Height )
EndIf
EndIf
ReDim EnumerateList( ArraySize( EnumerateList() ) + (1) ) : EnumerateList( ArraySize( EnumerateList() ) ) = gadgetID
EndIf
gadgetID = GetWindow_( gadgetID, #GW_HWNDNEXT )
;Debug GetProp_( gadgetID, "PB_ID" )
;gadgetID = FindWindowEx_( gadgetID, 0,0,0 )
Wend
While ArraySize( EnumerateList() )
If ArraySize( EnumerateList() )
gadgetID = EnumerateList( ArraySize( EnumerateList() ) ) : ReDim EnumerateList( ArraySize( EnumerateList() ) - (1) )
SetWindowPos_( gadgetID, #GW_HWNDLAST, 0,0,0,0, #SWP_NOMOVE|#SWP_NOSIZE )
EndIf
Wend
FreeArray( EnumerateList() )
CompilerEndIf
EndProcedure
UseModule RS_gadget
Procedure Events() ;
;
Protected x,y,n,m ;
If EventWindow()=#WinID ;
winID = WindowID(#WinID)
x=WindowWidth(#WinID) ;
n=(x-#WinW)/5 ;
y=n<<1
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListOldName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListNewName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,78+n,#ListState) ;
RedrawWindow_(winID, 0, 0, #RDW_ALLCHILDREN|#RDW_UPDATENOW)
EndIf ;
;
EndProcedure ;
Procedure Init() ;
;
Protected i ;
Protected makro ;
Protected flag ;
Protected s.s ;
CatchImage(#IconOk,?IconOk);
;
WinID=OpenWindow(#WinID,0,0,#WinW,#WinH,"",#WS_CLIPCHILDREN|#WS_CLIPSIBLINGS|#WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_Invisible|#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget);
WindowBounds(#WinID,#WinW,#WinZ,#PB_Default,#PB_Default) ;
;
FrameGadget(#Frm01,10,10,560,72,"Reguläre Ausdrücke") ;
TextGadget(#TxtName,20,30,60,20,"Datei&name:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrName,95,29,207,22,#PB_ComboBox_Editable) ;
ImageGadget(#IcoName,307,32,16,16,ImageID(#IconOk)) ;
TextGadget(#TxtExt,345,30,75,20,"&Erweiterung:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrExt,410,29,125,22,#PB_ComboBox_Editable) ;
ImageGadget(#IcoExt,540,32,16,16,ImageID(#IconOk)) ;
TextGadget(#TxtOutput,20,55,60,20,"Ändern &in:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrOutput,95,54,207,22,#PB_ComboBox_Editable) ;
ImageGadget(#IcoOut,307,57,16,16,ImageID(#IconOk)) ;
CheckBoxGadget(#FlgOutCase,346,55,175,22," &Groß-/Kleinschreibung beachten") ;
;
FrameGadget(#Frm02,10,90,560,72,"Suchen und Ersetzen") ;
TextGadget(#TxtSearch,20,110,100,20,"&Anfangs:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrSearch,95,109,207,22,#PB_ComboBox_Editable) ;
ImageGadget(#IcoSearch,307,112,16,16,ImageID(#IconOk)) ;
;
TextGadget(#TxtReplace,20,135,100,20,"A&bschließend:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrReplace,95,134,207,22,#PB_ComboBox_Editable) ;
ImageGadget(#IcoReplace,307,137,16,16,ImageID(#IconOk)) ;
;
CheckBoxGadget(#FlgNameOnly,346,104,180,18," Nur den Dateina&men verändern") ;
CheckBoxGadget(#FlgCase,346,122,175,18," Groß-/&Kleinschreibung beachten") ;
CheckBoxGadget(#FlgAll,346,140,175,18," Alle &Vorkommen ersetzen") ;
;
FrameGadget(#Frm03,10,168,560,48,"Erweitert") ;
TextGadget(#TxtWriteName,20,188,75,20,"Schreib&weise:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrWriteName,95,188,100,20) ;
TextGadget(#TxtWriteExt,240,188,70,20,"Erwei&terung:",#SS_CENTERIMAGE) ;
ComboBoxGadget(#StrWriteExt,310,188,100,20) ;
CheckBoxGadget(#FlgDate,455,188,76,18," Datei&datum aktualisieren") ; 140;
;
For i=0 To 1 ;
AddGadgetItem(#StrWriteName+i,#WriteUnchanged,"Unverändert") ;
AddGadgetItem(#StrWriteName+i,#WriteAllLower,"Alles klein") ;
AddGadgetItem(#StrWriteName+i,#WriteWordUpper,"Wortanfänge groß") ;
AddGadgetItem(#StrWriteName+i,#WriteAllUpper,"Alles groß") ;
Next i ;
;
ListIconGadget(#List,10,230,694,285," ·",20,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines) ;
;SetGadgetColor(#List,#PB_ListIcon_GridLines,#Black);
AddGadgetColumn(#List,#ListOldName,"Alter Dateiname",210) ;
AddGadgetColumn(#List,#ListNewName,"Neuer Dateiname",210) ;
AddGadgetColumn(#List,#ListSize,"Größe",52) ;
AddGadgetColumn(#List,#ListDate,"Datum",102) ;
AddGadgetColumn(#List,#ListState,"Status",78) ;
EnableGadgetDrop(#List,#PB_Drop_Files,#PB_Drag_Move|#PB_Drag_Copy) ;
;
Global lvm.LV_COLUMN ;
lvm\mask=#LVCF_FMT ;
lvm\fmt=#LVCFMT_CENTER ;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListDate,@lvm) ;
lvm\mask=#LVCF_FMT ;
lvm\fmt=#LVCFMT_RIGHT ;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListSize,@lvm) ;
;
FrameGadget(#TxtInfo,0,530,#WinW,2,"",#PB_Frame_Single) ;
TextGadget(#StrInfo,0,534,999,16,"StrInfo",#SS_CENTERIMAGE) ;
;
ButtonGadget(#ButRename,585,15,115,30,"&Umbenennen",#PB_Button_Default) ;
ButtonGadget(#ButClose,585,53,115,30,"S&chließen") ;
ButtonGadget(#ButProfile,585,95,115,30,"&Profile") ;
ButtonGadget(#ButExtras,585,132,115,30,"S&onderfunktionen") ;
ButtonGadget(#ButFilter,585,180,115,30,"Ergebnisliste &filtern",#PB_Button_Toggle) ;
RS_Init(#WinID)
RS_Register(#Frm01,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#StrName,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#IcoName,#PB_Align_Right_Top)
RS_Register(#TxtExt,#PB_Align_Right_Top)
RS_Register(#StrExt,#PB_Align_Right_Top)
RS_Register(#IcoExt,#PB_Align_Right_Top)
RS_Register(#StrOutput,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#IcoOut,#PB_Align_Right_Top)
RS_Register(#FlgOutCase,#PB_Align_Right_Top)
RS_Register(#Frm02,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#StrSearch,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#IcoSearch,#PB_Align_Right_Top)
RS_Register(#StrReplace,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#IcoReplace,#PB_Align_Right_Top)
RS_Register(#FlgNameOnly,#PB_Align_Right_Top)
RS_Register(#FlgCase,#PB_Align_Right_Top)
RS_Register(#FlgAll,#PB_Align_Right_Top)
RS_Register(#Frm03,#PB_Align_Left_Top|#PB_Align_Right_Top)
RS_Register(#StrWriteName,#PB_Align_Left_Top|#PB_Align_Right_Top) ;
RS_Register(#TxtWriteExt,#PB_Align_Right_Top) ;
RS_Register(#StrWriteExt,#PB_Align_Right_Top) ;
RS_Register(#FlgDate,#PB_Align_Right_Top)
RS_Register(#List,#PB_Align_Full)
RS_Register(#ButRename,#PB_Align_Right_Top)
RS_Register(#ButClose,#PB_Align_Right_Top)
RS_Register(#ButProfile,#PB_Align_Right_Top)
RS_Register(#ButExtras,#PB_Align_Right_Top)
RS_Register(#ButFilter,#PB_Align_Right_Top)
RS_Register(#TxtInfo,#PB_Align_Left_Botton|#PB_Align_Right_Botton)
RS_Register(#StrInfo,#PB_Align_Left_Botton|#PB_Align_Right_Botton)
;
BindEvent(#PB_Event_SizeWindow,@Events(),#WinID) ;
Clipgadgets( WindowID(#WinID) )
;
SetActiveWindow(#WinID) ;
SetActiveGadget(#StrName) ;
HideWindow(#WinID,#Null) ;
EndProcedure ;
Init()
UnuseModule RS_gadget
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Last edited by mestnyi on Mon Feb 22, 2016 8:49 pm, edited 1 time in total.
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: How to do flickerfree resizing of gadgets?
This one looks fine here (even it does not enlarge some elements nor expand the #FlgDate gadget) - but only if I remove the SmartWindowRefresh()mestnyi wrote:If you do so
Re: How to do flickerfree resizing of gadgets?
Vast improvement although there seems to be some corruption of the ticked tickboxes, especially when enlarging horizontally ...mestnyi wrote:
If you do so
Re: How to do flickerfree resizing of gadgets?
Relating to THIS article from James Brown (who has been awarded as 'Most Valuable Professional' in 2006 and 2007 by Microsoft), the best way to avoid flicker, is to not draw a pixel twice.
Following this rule I excluded most of the Gadgets from being painted over by the background and ended up with a mostly flicker-free result (at least on my Notebook with i7-4500U).
The only parts that still flickers a bit, are the Frames of the FrameGadgets, and the ImageGadgets.
About the FrameGadgets:
In this code I prevent the Text-Part of the FrameGadget to be painted over by the background, so the text should not flicker.
To prevent the lines also from flicker it would need a bit more time and effort someone could put into this if he wants.
About the ImageGadgets:
In Michaels Example the images do have transparent areas, so the Background has to be repainted to prevent bad results, which will end up in slightly flicker.
If they where not transparent, the backgroundredraw could be prohibited and they could be redrawn without flicker as well.
I have not changed Michael original code a lot. Here are the only relevant changes I've done:
- deactivate window-redraw (Line 120)
- reactivate window-redraw (Line 190)
- preventing the Gadgets from being painted over by the Background and do the refresh (Line 192 - 238)
I would be pleased, if you could compare this code to the original from Michael and give me some feedback if the result is as good on your System as it is on mine.
Following this rule I excluded most of the Gadgets from being painted over by the background and ended up with a mostly flicker-free result (at least on my Notebook with i7-4500U).
The only parts that still flickers a bit, are the Frames of the FrameGadgets, and the ImageGadgets.
About the FrameGadgets:
In this code I prevent the Text-Part of the FrameGadget to be painted over by the background, so the text should not flicker.
To prevent the lines also from flicker it would need a bit more time and effort someone could put into this if he wants.
About the ImageGadgets:
In Michaels Example the images do have transparent areas, so the Background has to be repainted to prevent bad results, which will end up in slightly flicker.
If they where not transparent, the backgroundredraw could be prohibited and they could be redrawn without flicker as well.
I have not changed Michael original code a lot. Here are the only relevant changes I've done:
- deactivate window-redraw (Line 120)
- reactivate window-redraw (Line 190)
- preventing the Gadgets from being painted over by the Background and do the refresh (Line 192 - 238)
I would be pleased, if you could compare this code to the original from Michael and give me some feedback if the result is as good on your System as it is on mine.
Code: Select all
EnableExplicit
DisableDebugger
#WinW=720
#WinH=552
#WinZ=400
Global WinID;
Enumeration;
#StrName; 0;
#StrExt; 1;
#StrOutput; 2;
#IcoName; 3;
#IcoExt; 4;
#IcoOut; 5;
#IcoSearch;
#IcoReplace;
#WinID;
#Frm01;
#Frm02;
#Frm03;
#TxtInfo;
#TxtName;
#TxtExt;
#TxtOutput;
#StrInfo;
#TxtSearch;
#TxtReplace;
#FlgOutCase;
#FlgNameOnly;
#FlgCase;
#FlgAll;
#FlgDate;
#List;
#ButRename;
#ButClose;
#ButProfile;
#ButFilter;
#ButExtras;
#TxtWriteName;
#TxtWriteExt;
#StrSearch;
#StrReplace;
#StrWriteName; \;
#StrWriteExt ; /;
#KeySearch;
#KeyReplace;
#IconOk;
EndEnumeration;
Enumeration
#WriteUnchanged;
#WriteAllLower;
#WriteWordUpper;
#WriteAllUpper;
EndEnumeration;
Enumeration;
#ListOldName;
#ListNewName;
#ListSize;
#ListDate;
#ListState;
EndEnumeration;
DataSection;
IconOk: ; 1406 Bytes;
Data.q $1010000100010000,$568000800010000,$28000000160000,$20000000100000,$800010000;
Data.q $1000000,$100000000000000,$3737000001000000,$CB4A0089B5320037,$FFFF00B5E15D009F;
Data.q $FF,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
Data.q 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,$505000000000000,$505050505050505,$505050505050505;
Data.q $505050505050505,$505050505050505,$505050500050505,$505050505050505,$505050001000505;
Data.q $505050505050505,$505000102020005,$505050505050505,$500010202020200,$5050505050505;
Data.q $1020300020202,$300050505050505,$102030005000202,$5050505050500,$203000505050003;
Data.q $505050505050001,$300050505050500,$505050505000102,$5050505050505,$505050500010203;
Data.q $505050505050505,$505050001020300,$505050505050505,$505050500030005,$505050505050505;
Data.q $505050505000505,$505050505050505,$505050505050505,$505050505050505,$FFFF050505050505;
Data.q $FFFB0000FFFF0000,$FFE00000FFF10000,$3F8000007FC00000,$F8E00001F040000,$83FF000007DF0000;
Data.q $E3FF0000C1FF0000,$FFFF0000F7FF0000,$FFFF0000;
EndDataSection;
; EndDefine;
Procedure SmoothGadgetIcon(gadget,icon,tooltip.s);
;
icon=ImageID(icon);
;
If GetGadgetState(gadget)<>icon;
SetGadgetState(gadget,icon);
GadgetToolTip(gadget,tooltip);
EndIf;
;
EndProcedure;
Procedure ResizeComboGadget(gadget,x,y,width,height);
;
ResizeGadget(gadget,x,y,width,height);
If GetActiveGadget()<>gadget;
SendMessage_(GadgetID(gadget),#CB_SETEDITSEL,0,-1);
EndIf;
;
EndProcedure;
Procedure Events();
;
Protected x,y,n,m;
Protected z,z0,z1,z2;
;
If EventWindow()=#WinID;
x=WindowWidth(#WinID);
y=WindowHeight(#WinID);
If GadgetWidth(#TxtInfo)=x;
ResizeGadget(#List,#PB_Ignore,#PB_Ignore,#PB_Ignore,y-262);
ResizeGadget(#TxtInfo,#PB_Ignore,y-22,#PB_Ignore,#PB_Ignore);
ResizeGadget(#StrInfo,#PB_Ignore,y-18,#PB_Ignore,#PB_Ignore);
Else ;
;
SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#False,0) ;
;
n=(x-#WinW)/5 ;
ResizeGadget(#List,#PB_Ignore,#PB_Ignore,x-26,y-262) ; 720-694;
ResizeGadget(#TxtInfo,#PB_Ignore,y-22,x,#PB_Ignore) ;;
ResizeComboGadget(#StrInfo,#PB_Ignore,y-18,#PB_Ignore,#PB_Ignore);;
;
y=n<<1 ;
m=n<<2 ;
ResizeGadget(#Frm01,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore) ; 720-560;
ResizeGadget(#Frm02,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore) ; 720-560;
ResizeGadget(#Frm03,#PB_Ignore,#PB_Ignore,565+m,#PB_Ignore) ; 720-560;
;
x=y+n>>1 ;
z0=207+x ; Position (105) + Breite (207) + Verbreiterung (x);
ResizeComboGadget(#StrName,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore) ;;
ResizeComboGadget(#StrOutput,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
ResizeComboGadget(#StrSearch,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
ResizeComboGadget(#StrReplace,#PB_Ignore,#PB_Ignore,z0,#PB_Ignore);;
z0+100 ;
ResizeComboGadget(#IcoName,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeComboGadget(#IcoOut,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeComboGadget(#IcoReplace,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore);;
ResizeComboGadget(#IcoSearch,z0,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
;
x=y+(n*3)>>2 ;
z=125+(n*5)>>2 ;
ResizeGadget(#TxtExt,345+x,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#StrExt,410+x,#PB_Ignore,z,#PB_Ignore) ;;
ResizeGadget(#IcoExt,415+x+z,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#FlgOutCase,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#FlgNameOnly,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#FlgCase,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#FlgAll,346+x,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
;
If n>40 ;
z=40 ;
Else ;
z=n ;
EndIf ;
;
z1=240+n ;
z2=455+y+n ;
;
If m>120 ;
If m>260 ;
z=7+n>>1 ;
z1=z0-z-175 ;
z2=346+x ;
EndIf ;
x=136 ;
Else ;
x=76 ;
EndIf ;
;
ResizeGadget(#StrWriteName,#PB_Ignore,#PB_Ignore,100+z,#PB_Ignore);;
ResizeGadget(#TxtWriteExt,z1,#PB_Ignore,#PB_Ignore,#PB_Ignore) ;;
ResizeGadget(#StrWriteExt,z1+70,#PB_Ignore,100+z,#PB_Ignore) ;;
ResizeGadget(#FlgDate,z2,#PB_Ignore,x,#PB_Ignore)
;
ResizeGadget(#ButRename,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButClose,585+m,#PB_Ignore,115+n,#PB_Ignore) ;;
ResizeGadget(#ButProfile,585+m,#PB_Ignore,115+n,#PB_Ignore);;
ResizeGadget(#ButExtras,585+m,#PB_Ignore,115+n,#PB_Ignore) ;;
ResizeGadget(#ButFilter,585+m,#PB_Ignore,115+n,#PB_Ignore) ;;
;
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListOldName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+y,#ListNewName);
SetGadgetItemAttribute(#List,#PB_Ignore,#PB_ListIcon_ColumnWidth,78+n,#ListState) ;
;
SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#True,0) ;
Protected WinRect.rect, GadgetRect.RECT
Protected hWnd = WindowID(#WinID), hGad, ps.PAINTSTRUCT
Protected xOffset, yOffset
; 1st Step: mark complete Window-Region as invalid
GetClientRect_(hWnd, @WinRect)
InvalidateRect_(hWnd,WinRect,1)
xOffset = WindowX(#WinID, #PB_Window_InnerCoordinate)
yOffset = WindowY(#WinID, #PB_Window_InnerCoordinate)
; 2nd Step: Validate the areas of all 'good' Gadgets, so the background will not be painted above these Gadgets
For n = #StrName To #IconOk ; Loop from 1st to last Gadget
If IsGadget(n)
Select GadgetType(n)
Case #PB_GadgetType_Frame ; validate only the Text-Area of the Frame-Gadgets
GetWindowRect_(GadgetID(n), @GadgetRect) ; get Gadget-Area
GadgetRect\top - yOffset
GadgetRect\left - xOffset
GadgetRect\bottom = GadgetRect\top + 16 ; set valid area-hight to 16 Pixel
GadgetRect\right = GadgetRect\top + 180 ; set valid area-width to 180 Pixel
ValidateRect_(WindowID(#WinID),GadgetRect) ; validate Area
Case #PB_GadgetType_Image ; don't validate Image-Gadgets - only neccesarry, if transparent 32bit-images
Default ; validate area of all 'good' Gadgets
GetWindowRect_(GadgetID(n), @GadgetRect) ; get Gadget-Area
GadgetRect\top - yOffset
GadgetRect\left - xOffset
GadgetRect\bottom - yOffset
GadgetRect\right - xOffset
ValidateRect_(WindowID(#WinID),GadgetRect) ; validate Gadget-Area
EndSelect
EndIf
Next
; 3rd Step: Redraw Background only on invalid area (i.e. excluding the 'good' gadgets) and refresh Gadgets
BeginPaint_(hWnd, ps.PAINTSTRUCT)
EndPaint_(hWnd, ps.PAINTSTRUCT)
RedrawWindow_(hWnd,#Null,#Null,#RDW_INVALIDATE);
EndIf;
EndIf ;
;
EndProcedure;
Procedure Init();
;
Protected i;
Protected makro;
Protected flag;
Protected s.s;
CatchImage(#IconOk,?IconOk);
;
Protected WindowFlags = #WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_Invisible|#PB_Window_SizeGadget
WindowFlags = WindowFlags | #PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget ; | #WS_CLIPCHILDREN | #WS_CLIPSIBLINGS
WinID=OpenWindow(#WinID,0,0,#WinW,#WinH,"",WindowFlags)
WindowBounds(#WinID,#WinW,#WinZ,#PB_Default,#PB_Default);
;
FrameGadget(#Frm01,10,10,560,72,"Reguläre Ausdrücke");
TextGadget(#TxtName,20,30,60,20,"Datei&name:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrName,95,29,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoName,307,32,16,16,ImageID(#IconOk));
TextGadget(#TxtExt,345,30,75,20,"&Erweiterung:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrExt,410,29,125,22,#PB_ComboBox_Editable);
ImageGadget(#IcoExt,540,32,16,16,ImageID(#IconOk));
TextGadget(#TxtOutput,20,55,60,20,"Ändern &in:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrOutput,95,54,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoOut,307,57,16,16,ImageID(#IconOk));
CheckBoxGadget(#FlgOutCase,346,55,175,22," &Groß-/Kleinschreibung beachten");
;
FrameGadget(#Frm02,10,90,560,72,"Suchen und Ersetzen");
TextGadget(#TxtSearch,20,110,100,20,"&Anfangs:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrSearch,95,109,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoSearch,307,112,16,16,ImageID(#IconOk));
;
TextGadget(#TxtReplace,20,135,100,20,"A&bschließend:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrReplace,95,134,207,22,#PB_ComboBox_Editable);
ImageGadget(#IcoReplace,307,137,16,16,ImageID(#IconOk));
;
CheckBoxGadget(#FlgNameOnly,346,104,180,18," Nur den Dateina&men verändern");
CheckBoxGadget(#FlgCase,346,122,175,18," Groß-/&Kleinschreibung beachten");
CheckBoxGadget(#FlgAll,346,140,175,18," Alle &Vorkommen ersetzen");
;
FrameGadget(#Frm03,10,168,560,48,"Erweitert");
TextGadget(#TxtWriteName,20,188,75,20,"Schreib&weise:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrWriteName,95,188,100,20);
TextGadget(#TxtWriteExt,240,188,70,20,"Erwei&terung:",#SS_CENTERIMAGE);
ComboBoxGadget(#StrWriteExt,310,188,100,20);
CheckBoxGadget(#FlgDate,455,188,76,18," Datei&datum aktualisieren"); 140;
;
For i=0 To 1;
AddGadgetItem(#StrWriteName+i,#WriteUnchanged,"Unverändert");
AddGadgetItem(#StrWriteName+i,#WriteAllLower,"Alles klein");
AddGadgetItem(#StrWriteName+i,#WriteWordUpper,"Wortanfänge groß");
AddGadgetItem(#StrWriteName+i,#WriteAllUpper,"Alles groß");
Next i;
;
ListIconGadget(#List,10,230,694,285," ·",20,#PB_ListIcon_FullRowSelect|#PB_ListIcon_GridLines);
;SetGadgetColor(#List,#PB_ListIcon_GridLines,#Black);
AddGadgetColumn(#List,#ListOldName,"Alter Dateiname",210);
AddGadgetColumn(#List,#ListNewName,"Neuer Dateiname",210);
AddGadgetColumn(#List,#ListSize,"Größe",52);
AddGadgetColumn(#List,#ListDate,"Datum",102);
AddGadgetColumn(#List,#ListState,"Status",78);
EnableGadgetDrop(#List,#PB_Drop_Files,#PB_Drag_Move|#PB_Drag_Copy);
;
Global lvm.LV_COLUMN;
lvm\mask=#LVCF_FMT;
lvm\fmt=#LVCFMT_CENTER;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListDate,@lvm);
lvm\mask=#LVCF_FMT;
lvm\fmt=#LVCFMT_RIGHT;
SendMessage_(GadgetID(#List),#LVM_SETCOLUMN,#ListSize,@lvm);
;
FrameGadget(#TxtInfo,0,530,#WinW,2,"",#PB_Frame_Single);
TextGadget(#StrInfo,0,534,999,16,"",#SS_CENTERIMAGE);
;
ButtonGadget(#ButRename,585,15,115,30,"&Umbenennen",#PB_Button_Default);
ButtonGadget(#ButClose,585,53,115,30,"S&chließen");
ButtonGadget(#ButProfile,585,95,115,30,"&Profile");
ButtonGadget(#ButExtras,585,132,115,30,"S&onderfunktionen");
ButtonGadget(#ButFilter,585,180,115,30,"Ergebnisliste &filtern",#PB_Button_Toggle);
;
BindEvent(#PB_Event_SizeWindow,@Events(),#WinID);
;
SetActiveWindow(#WinID);
SetActiveGadget(#StrName);
HideWindow(#WinID,#Null);
EndProcedure;
Init()
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: How to do flickerfree resizing of gadgets?
Two great things in one posting - thank you...PureLust wrote:Relating to this article from James Brown [...] the best way to avoid flicker, is to not draw a pixel twice.
[...]
I would be pleased, if you could compare this code to the original from Michael and give me some feedback if the result is as good on your System as it is on mine.
...what a difference!
Re: How to do flickerfree resizing of gadgets?
Works perfectly here, no flickering at all (Win 10 64 bit)
Nice One
Nice One
Windows 10 and PB 5.73 (both x64)
Re: How to do flickerfree resizing of gadgets?
Similar to SmartErase... but simpler! Nice.
I may look like a mule, but I'm not a complete ass.
- Michael Vogel
- Addict
- Posts: 2666
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: How to do flickerfree resizing of gadgets?
Brilliant result and even simple to integrate into my project, thank you once more...
Your free additional hint for getting even smoother icons are nice as well, only added few lines now to get this done...
Your free additional hint for getting even smoother icons are nice as well, only added few lines now to get this done...
Code: Select all
Global Flickering=0
Procedure Events()
:
;Case #PB_GadgetType_Image; don't validate Image-Gadgets - only neccesarry, if transparent 32bit-images
Case Flickering
:
EndProcedure
Procedure CatchIcon(icon,*mem)
If Flickering
CatchImage(icon,*mem)
Else
CreateImage(icon,16,16,32,GetSysColor_(#COLOR_3DFACE))
CatchImage(#IconTemp,*mem)
StartDrawing(ImageOutput(icon))
DrawImage(ImageID(#IconTemp),0,0)
StopDrawing()
EndIf
EndProcedure
Procedure Init()
:
If Flickering
Flickering=#PB_GadgetType_Image
EndIf
CatchIcon(#IconOk,?IconOk)
:
EndProcedure