How to do flickerfree resizing of gadgets?

Just starting out? Need help? Post your questions and find answers here.
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

How to do flickerfree resizing of gadgets?

Post by Michael Vogel »

Here's a snippet doing some resizing when the windo size will be changed, is it (easily) possible to get it done a little bit smoother?

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;

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);
			;;;;InvalidateRgn_(WindowID(#WinID),0,0);
			;RedrawWindow_(WindowID(#WinID),#Null,#Null,#RDW_INVALIDATE|#RDW_ERASE);
			;
		EndIf;
	EndIf;
	;
EndProcedure;
Procedure Init();
	;
	Protected i;
	Protected makro;
	Protected flag;
	Protected s.s;

	CatchImage(#IconOk,?IconOk);
	;
	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;
	;
	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
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: How to do flickerfree resizing of gadgets?

Post by PureLust »

I'm not near a PC right now, to give you an example, ... but have a look at the Dialog (XML-Dialog) Commands.
No special code needed to support resizing and refresh is smooth like a charm.

[Edit] Example : http://www.purebasic.fr/english/viewtop ... 31#p480331
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: How to do flickerfree resizing of gadgets?

Post by Michael Vogel »

Thank you for this link to your example, I've never played around with XML (in combination with dialogs and gadgets) and will definitely have a closer look at it.
For the moment, I am not sure if XML will be flexible enough to do some changes in the layout depending on the window size. In my small example, there's are only a few gadgets which do not change their size and position linear to the windows width, they are seen in the second row (gadgets #StrWriteName, #StrWriteExt and #FlgDate).
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: How to do flickerfree resizing of gadgets?

Post by PureLust »

Hi Michael,

I'm sorry, but I have to retract what I said before about the refresh, smooth like a charm.

I've reconstructed your example (as good as I could) with a XML-Dialog, but with so many Gadgets as in your example, it flickers as well.
It seems to flicker a bit less ... but still ... it flickers a lot.

The big advantage of using XML-Dialogs is, that you don't have to care about the resizing.
I could imagine, how long it took you, to get the resize of your example right.
With XML-Dialogs you just have to set it up right, and anything else is magic. :wink:

As you can see in my example down there, the only thing I had to take care if the window resizes, is to change the with of the columns in the ListIconGadget.

With a good XML-Dialog Designer one should be able to setup a complex Dialog with dynamic resizing like your Example within 5 Minutes.
(How long it took you to end up with this well working result? :mrgreen: )

As long as there is no good XML-Dialog Designer available (even mine is far away from being finished) I use a Wrapper to create the XML-Strings.
This makes it much easier to create a XML-Code with correct Syntax and the code looks much cleaner as well.
The Wrapper still doesn't wrap all Dialog-Elements, but it worked quite well while building a copy of your Example.
(The only Gadget which I had to create 'manually' was the ListIconGadget (see AddXML() in Line 148).)
[LINK] to download the wrapper.

Image

Maybe XML-Dialogs will be of some interest for you in the future. ;)

Code: Select all

; XML-Dialog-Variante zu Michael Vogels Beispiel   =>   http://www.purebasic.fr/english/viewtopic.php?f=13&t=64868

EnableExplicit

XIncludeFile "..\Dialog_Wrapper\Dialog_Wrapper.pbi"					; you can download the File at: http://www.bmi-online.de/public/Dialog_Wrapper.zip
; XIncludeFile "..\Includes\StopGadgetUpdate.pbi"

#XMLWinMain = 0
#Dialog		= 0
#IconOk		= 0

Runtime Enumeration Windows
	#winMain
EndEnumeration

Runtime Enumeration Gadgets
	#gadListIcon_Liste
EndEnumeration


#WinW=760
#WinH=552
#WinZ=400

CatchImage(#IconOk,?IconOk);

Procedure.s Create_MainWindowDialog()
	
	Protected xml$

	UseModule Dialog
	
	SetXMLOutputFormat(#XMLout_Indent, 5)
	SetXMLOutputFormat(#XMLout_AlignLineBreak, #True)
	
	ClearXML()
	
	Protected WinFlags = #WS_SYSMENU|#PB_Window_ScreenCentered|#PB_Window_Invisible|#PB_Window_SizeGadget| #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
	
 	Window(#winMain,"winMain","", WinFlags, #WinW, #winh, "margin='10' minwidth='"+Str(#winw)+"' minheight='"+Str(#winz)+"'")
 		vBox(1,0,0)
 			GridBox(2,10,5,#PB_Default,5)
 			
 			; --- Frame: Reguläre Ausdrücke
 			
 				Frame(#PB_Ignore,"","Reguläre Ausdrücke")
					SingleBox(0,0,"horizontal:5,bottom:2")
						hBox(0,0,15)
							vBox()
								hBox(2)
		 							text(#PB_Ignore, "", "Datei&name  ",0,85,0,#alignLeftCenter)
		 							ComboBox(#PB_Ignore, "",#PB_ComboBox_Editable,200)
		 							Image(#PB_Ignore, "Image1", 0,0,20,20)
		 						EndHBox()
		 						hBox(2)
		 							text(#PB_Ignore, "", "Ändern  ",0,85,0,#alignLeftCenter)
		 							ComboBox(#PB_Ignore, "",#PB_ComboBox_Editable,200)
		 							Image(#PB_Ignore, "Image3", 0,0,20,20)
		 						EndHBox()
		 					EndVBox()
		 					vBox()
		 						hBox(2)
		 							text(#PB_Ignore, "", "&Erweiterung ",0,70,0,#alignLeftCenter)
		 							ComboBox(#PB_Ignore, "",#PB_ComboBox_Editable,120)
		 							Image(#PB_Ignore, "Image2", 0,0,20,20)
		 						EndHBox()
		 						CheckBox(#PB_Ignore, "", " &Groß/Kleinschreibung beachten  ")
	 						EndVBox()
	 					EndHBox()
 	 				EndSingleBox()	
 				EndFrame()	
 				
 			; --- Buttons: Umbenennen und Schließen
 				
 				vBox(0,0,5)
 					SingleBox(0,0,"top:7")
 						Button(#PB_Ignore, "", "&Umbenennen",0,5)
 					EndSingleBox()
	 				Button(#PB_Ignore, "", "S&chließen")
	 			EndVBox()
	 				
 			; --- Frame: Suchen und Ersetzen
 			
  				Frame(#PB_Ignore,"","Suchen und Ersetzen")
					SingleBox(0,0,"horizontal:5")
						hBox(0,0,15)
							vBox(#Expand_No, #alignCenter)
								Empty(0,4)
								hBox(2)
		 							text(#PB_Ignore, "", "&Anfangs  ",0,85,0,#alignLeftCenter)
		 							ComboBox(#PB_Ignore, "",#PB_ComboBox_Editable,200)
		 							Image(#PB_Ignore, "Image4", 0,0,20,20)
		 						EndHBox()
		 						hBox(2)
		 							text(#PB_Ignore, "", "Abschließen",0,85,0,#alignLeftCenter)
		 							ComboBox(#PB_Ignore, "",#PB_ComboBox_Editable,200)
		 							Image(#PB_Ignore, "Image5", 0,0,20,20)
		 						EndHBox()
		 					EndVBox()
		 					vBox()
		 						CheckBox(#PB_Ignore, "", " Nur den Dateina&men verändern  ",0,220,10)
		 						CheckBox(#PB_Ignore, "", " Groß-/&Kleinschreibung beachten  ")
		 						CheckBox(#PB_Ignore, "", " Alle &Vorkommen ersetzen  ")
	 						EndVBox()
	 					EndHBox()
 	 				EndSingleBox()	
 				EndFrame()	
 			
 			; --- Buttons: Profile und Sonderfunktionen
 				
 				vBox(0,0,5,"width='150'")
 					SingleBox(0,0,"top:7")
 						Button(#PB_Ignore, "", "&Profile",0,5)
 					EndSingleBox()
	 				Button(#PB_Ignore, "", "&Sonderfunktionen")
	 			EndVBox()
	 				
 			; --- Frame: Erweitert
 			
  				Frame(#PB_Ignore,"","Erweitert")
					SingleBox(0,0,"horizontal:5,bottom:2")
						hBox(0,0,0)
							Empty(0,4)
							hBox(2)
	 							text(#PB_Ignore, "", "Schreib&weise: ",0,85,0,#alignLeftCenter)
	 							ComboBox(#PB_Ignore, "Combo6",0,120)
	 						EndHBox()
	 						Empty(10)	
							hBox(2)
	 							text(#PB_Ignore, "", "Erwei&terung: ",0,85,0,#alignLeftCenter)
	 							ComboBox(#PB_Ignore, "Combo7",0,120)
	 						EndHBox()
	 						Empty(10)	
	 						CheckBox(#PB_Ignore, "", " Datei&datum aktualisieren ")
	 					EndHBox()
 	 				EndSingleBox()	
 				EndFrame()	
 			
 			; --- Button: Ergebnisliste filtern
 				
 				SingleBox(0,0,"top:7")
	 				Button(#PB_Ignore, "", "Ergebnisliste &filtern")
	 			EndSingleBox()
	 			
 			; --- ListIconGadget
	 			
	 			Empty(0,2,"colspan='3'")
	 			AddXML("<ListIcon id='#gadListIcon_Liste' expand='yes' width='20' height='10' text=' ·' colspan='3' " +
	 			       "flags='#PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection'/>")
	 			
			EndGridBox()
 		EndVBox()
 	EndWindow()	
 				
	xml$ = GetXML()
	
	UnuseModule Dialog

	Debug xml$
	
	If Not (CatchXML(#XMLWinMain, @xml$, StringByteLength(xml$), 0, #XmlEncoding) And XMLStatus(#XMLWinMain) = #PB_XML_Success)
		MessageRequester("Fehler in XML-Definition !!!", "XML error: " + XMLError(#XMLWinMain) + " (Line: " + XMLErrorLine(#XMLWinMain) +
		                 ")"+Chr(10)+Chr(10)+"XML-Definition '"+xml$+"' konnte nicht decodiert werden.", #PB_MessageRequester_Ok)
		End
	EndIf
	
	ProcedureReturn xml$
	
EndProcedure

Procedure	UpdateListIconColumn()
	
	Protected x.f = (GadgetWidth(#gadListIcon_Liste)-210-210-52-102-78-40)/7
   SetGadgetItemAttribute(#gadListIcon_Liste,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+x*3,0);
   SetGadgetItemAttribute(#gadListIcon_Liste,#PB_Ignore,#PB_ListIcon_ColumnWidth,210+x*3,1);
   SetGadgetItemAttribute(#gadListIcon_Liste,#PB_Ignore,#PB_ListIcon_ColumnWidth,78+x,4)	 ;
   
EndProcedure

Define	XML$ = Create_MainWindowDialog()
Define	n

If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #XMLWinMain, "winMain")
	
   BindEvent(#PB_Event_SizeWindow,@UpdateListIconColumn(),#winMain);
   ;SmartWindowRefresh(#WinID, #True)
	
	; Die ImageIDs für ImageGadgets müssen bei XML-Dialogen derzeit noch nachträglich gesetzt werden
	
	For n = 1 To 5
		If IsGadget(DialogGadget(#Dialog, "Image"+Str(n))) : SetGadgetState(DialogGadget(#Dialog, "Image"+Str(n)), ImageID(#IconOk)) : EndIf
	Next
	
	; Einträge zu den unteren ComboBoxen hinzufügen
	
	For n=6 To 7
		If IsGadget(DialogGadget(#Dialog, "Combo"+Str(n)))
	      AddGadgetItem(DialogGadget(#Dialog, "Combo"+Str(n)),-1,"Unverändert")
	      AddGadgetItem(DialogGadget(#Dialog, "Combo"+Str(n)),-1,"Alles klein")
	      AddGadgetItem(DialogGadget(#Dialog, "Combo"+Str(n)),-1,"Wortanfänge groß")
	      AddGadgetItem(DialogGadget(#Dialog, "Combo"+Str(n)),-1,"Alles groß")
      EndIf
   Next n
   
   ; --- Spalten zum ListIconGadget hinzufügen
   
	   SetGadgetItemAttribute(#gadListIcon_Liste,0,#PB_ListIcon_ColumnWidth,20,0);
		AddGadgetColumn(#gadListIcon_Liste,0,"Status",78);
		AddGadgetColumn(#gadListIcon_Liste,0,"Datum",102);
		AddGadgetColumn(#gadListIcon_Liste,0,"Größe",52);
		AddGadgetColumn(#gadListIcon_Liste,0,"Neuer Dateiname",210);
		AddGadgetColumn(#gadListIcon_Liste,0,"Alter Dateiname",210);
		
		HideWindow(#winMain, #False)
		
	; --- Event Handling
		
		Repeat
			Define Event = WaitWindowEvent()
		Until Event = #PB_Event_CloseWindow
	EndIf

   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;
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: How to do flickerfree resizing of gadgets?

Post by Michael Vogel »

Not bad, your code is very interesting, but as you said, flickering remains...

Meantime, I tried to use the windows API to get rid of these annoying effects, but it seems to be more complicate than expected. It's easy to disable/enable redrawing which is done before/after the resizegadget commands in the procedure events now:

Code: Select all

	SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#False,0);
	:
	:
	SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#True,0);
But then I would need to update the gadgets and erase the background area, which is not possible for me (I hoped, it would be possible to invalidate the window area and validate all gadget rectangles to avoid flickering). I tried things like...

Code: Select all

	;InvalidateRgn_(WindowID(#WinID),0,0);
	;GetWindowRect_(GadgetID(#ButRename),r.rect)
	;ValidateRect_(WindowID(#WinID),r)
	RedrawWindow_(WindowID(#WinID),r,#Null,#RDW_INVALIDATE);
		
	;ValidateRgn_(GadgetID(#ButClose),0);
	;RedrawWindow_(WindowID(#WinID),#Null,#Null,#RDW_ERASE|#RDW_UPDATENOW);
...but I get only one of these results for now:
- nothing will be redrawed
- everything will be redrawed correctly but flickering will be seen as well
- the gadgets are updated, but the background won't be erased (ghost effects)
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: How to do flickerfree resizing of gadgets?

Post by HanPBF »

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...
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to do flickerfree resizing of gadgets?

Post by srod »

Hi Michael,

I have my old SmartErase Windows utility which I have just updated to run with the latest PB versions. It does a similar thing to PB's SmartWindowRefresh() but goes quite a bit further.

It basically, amongst other things, removes the regions occupied by child controls from the region of the parent controls/windows etc. and can be very effective. It is a bit of trial and error to get the best out of it as some controls can upset it a bit. I remember using it with my Pyrex designer and it removed all flicker. Other apps though proved less willing to behave!

I have just run your code above through it and, well, frame gadgets are always problematic and your icons did prove fiddly. Try SmartWindowRefresh() and see what happens to the icons! :)

Anyhow, I got it to the point where the flickering has been reduced markedly on my system. Not 100% by any means, but personally I could live with it. It certainly flickers less than the dialog example - at least on my system anyhow.

You're welcome to take a look if you pm me an email address for me to send the package to. :)

@Purelust : that is a pretty nifty utility there for creating XML dialogs. Very nice.
Last edited by srod on Sat Feb 20, 2016 4:02 pm, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: How to do flickerfree resizing of gadgets?

Post by HanPBF »

Hello srod,

is there something possible with CreateThread to resize things smoothly?

Do You know what makes the flickering happen?
Is it simply the lots of redrawing needed?

Thanks a lot,
regards
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to do flickerfree resizing of gadgets?

Post by srod »

Threads won't add anything in this regards.

The real reason for flickering is that Windows does not automatically double buffer the rendering of a Window's contents. :)

With this in mind, there are a number of reasons why we might see a UI flicker when dynamically resizing controls, and the worst offender is the erasing of a parent control/window background prior to painting updated content, especially when several controls themselves have child controls (such as container gadgets and the like).

Imagine a container gadget, for example, containing a few buttons. When the container is resized (through code) following the user resizing the main application window, the container will generally erase it’s own contents by filling it’s client area with some colour or other. When it does this, the child button controls will appear to flicker as they are momentarily blanked out during this repeating operation. This is of course more noticeable when you increase the number of such containers and the number of child controls etc.

Certain kinds of controls (e.g. Purebasic Framegadgets and PanelGadgets) exacerbate this further through their very nature and the ways in which they operate.
I may look like a mule, but I'm not a complete ass.
HanPBF
Enthusiast
Enthusiast
Posts: 570
Joined: Fri Feb 19, 2010 3:42 am

Re: How to do flickerfree resizing of gadgets?

Post by HanPBF »

Thanks srdo for that explanation.

From RASHAD I have a method how to put one CanvasGadget above another by setting a parent like this:

Code: Select all

SetWindowLongPtr_(GadgetID(PBSubControl), #GWL_HWNDPARENT, GadgetID(PBParentControl))	; without this overlapping canvas does not get event			
As I understood, each redraw of the gadgets, especially the container like ones, had to be observed and checked for redrawing.
So, mimicking a CanvasGadget as a container for other controls and doing all the maintenance of redrawing, everything should be fast enough to non-flicker-resize. Is that correct?
(CanvasGadget as container means simulated by position/z-index only; I don't know how windows handles containers).

With a non-Win32-based GUI, meaning CanvasGadget based GUI, thinks should get better/less flicker?

Thanks a lot,
regards!
PureLust
Enthusiast
Enthusiast
Posts: 477
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: How to do flickerfree resizing of gadgets?

Post by PureLust »

srod wrote:@Purelust : that is a pretty nifty utility there for creating XML dialogs. Very nice.
Thank you, you are welcome. :D

If you are interested in the always latest versions (I improve it nearly every day, depends on the time i can take), you can download it at any time directly from my Development Server: [LINK]

PS@srod: If your offer about your package is not just limited to Michael, I'd like to send you my mail-Adress (if you don't have it anymore) to have a look as well. ;)
Last edited by PureLust on Sun Feb 21, 2016 11:22 pm, edited 1 time in total.
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to do flickerfree resizing of gadgets?

Post by srod »

You're welcome to a copy of it. I just want to hear back from Michael first to see how he gets on with it.
I may look like a mule, but I'm not a complete ass.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: How to do flickerfree resizing of gadgets?

Post by Danilo »

Michael Vogel wrote:Meantime, I tried to use the windows API to get rid of these annoying effects, but it seems to be more complicate than expected. It's easy to disable/enable redrawing which is done before/after the resizegadget commands in the procedure events now:

Code: Select all

	SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#False,0);
	:
	:
	SendMessage_(WindowID(#WinID),#WM_SETREDRAW,#True,0);
Try the following, and compare results with StopWindowUpdate() + ContinueWindowUpdate(), and without:

Code: Select all

;
; http://forums.purebasic.com/german/viewtopic.php?f=3&t=28153&start=5
;
Macro DisableRedraw(hWnd)
    ; http://msdn.microsoft.com/en-US/library/dd145219(v=vs.85).aspx
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(hWnd,#WM_SETREDRAW,0,0)
    CompilerEndIf
EndMacro

Macro EnableRedraw(hWnd)
    ; http://msdn.microsoft.com/en-US/library/dd145219(v=vs.85).aspx
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(hWnd,#WM_SETREDRAW,1,0)
        RedrawWindow_(hWnd, 0, 0, #RDW_ERASE | #RDW_FRAME | #RDW_INVALIDATE | #RDW_ALLCHILDREN)
    CompilerEndIf
EndMacro

; DisableRedraw( GadgetID(listbox) )
;   fill gadget / Gadget füllen
; EnableRedraw( GadgetID(listbox) )


;===============================================================================================

Macro StopWindowUpdate(_winID_)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,0,0)
    CompilerEndIf
EndMacro

Macro ContinueWindowUpdate(_winID_, _redrawBackground_ = 0)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,1,0)
        InvalidateRect_(_winID_,0,_redrawBackground_)
        UpdateWindow_(_winID_)
    CompilerEndIf
EndMacro

Procedure OnSize()
    btn_width.d  = WindowWidth(1)  / 5.0
    btn_height.d = WindowHeight(1) / 12.0
    winID = WindowID(1)
    
    StopWindowUpdate(winID)
        For y = 0 To 11
            For x = 0 To 4
                buttonCount+1
                ResizeGadget(buttonCount,x*btn_width,y*btn_height,btn_width,btn_height)
            Next
        Next
    ContinueWindowUpdate(winID)
EndProcedure

If OpenWindow(1,0,0,1000,600,"Buttons",#PB_Window_SystemMenu|
                                       #PB_Window_ScreenCentered|
                                       #PB_Window_SizeGadget|
                                       #PB_Window_MaximizeGadget|
                                       #PB_Window_MinimizeGadget|
                                       #PB_Window_Invisible)
    
    For y = 0 To 11
        For x = 0 To 4
            buttonCount+1
            ButtonGadget(buttonCount,x*200,y*25,200,50,Str(buttonCount))
        Next
    Next
    
    BindEvent(#PB_Event_SizeWindow, @OnSize(), 1)
    
    OnSize()
    
    HideWindow(1,0)
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
With your example you need to redraw the background, so use ContinueWindowUpdate(winID,#True).
Still flickering a bit sometimes, but already much better IMO (disable Debugger for testing):

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;
   
Macro StopWindowUpdate(_winID_)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,0,0)
    CompilerEndIf
EndMacro

Macro ContinueWindowUpdate(_winID_, _redrawBackground_ = 0)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,1,0)
        InvalidateRect_(_winID_,0,_redrawBackground_)
        UpdateWindow_(_winID_)
    CompilerEndIf
EndMacro   
   
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;
      winID = WindowID(#WinID)
      StopWindowUpdate(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);
      EndIf;
      ContinueWindowUpdate(winID,#True)
   EndIf;
   ;
EndProcedure;
Procedure Init();
   ;
   Protected i;
   Protected makro;
   Protected flag;
   Protected s.s;

   CatchImage(#IconOk,?IconOk);
   ;
   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;
   ;
   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
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Re: How to do flickerfree resizing of gadgets?

Post by srod »

No noticeable difference on my Win 7 box Danilo. Still flickers a lot.
I may look like a mule, but I'm not a complete ass.
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: How to do flickerfree resizing of gadgets?

Post by Danilo »

srod wrote:No noticeable difference on my Win 7 box Danilo. Still flickers a lot.
And in combination with DeferWindowPos_(), #WS_CLIPCHILDREN|#WS_CLIPSIBLINGS? With or without StopWindowUpdate() + ContinueWindowUpdate()?

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()

Procedure BeginGadgetResize()
    ClearList( gadgetsForResizing() )
EndProcedure

Procedure ResizeGadget_(gadget,x,y,width,height)
    If AddElement( gadgetsForResizing() )
        If x      = #PB_Ignore : x      = GadgetX(gadget)      : EndIf
        If y      = #PB_Ignore : y      = GadgetY(gadget)      : EndIf
        If width  = #PB_Ignore : width  = GadgetWidth(gadget)  : EndIf
        If height = #PB_Ignore : height = GadgetHeight(gadget) : EndIf
        gadgetsForResizing()\gadget = gadget
        gadgetsForResizing()\x      = x
        gadgetsForResizing()\y      = y
        gadgetsForResizing()\width  = width
        gadgetsForResizing()\height = height
    Else
        ResizeGadget(gadget,x,y,width,height)
    EndIf
EndProcedure

Procedure ResizeAllGadgetsInList()
    ForEach gadgetsForResizing()
        ResizeGadget( gadgetsForResizing()\gadget,
                      gadgetsForResizing()\x,
                      gadgetsForResizing()\y,
                      gadgetsForResizing()\width,
                      gadgetsForResizing()\height )
    Next
EndProcedure

Procedure EndGadgetResize()
    Protected hdwp
    Protected count = ListSize( gadgetsForResizing() )
    If count
        hdwp = BeginDeferWindowPos_(count)
        If Not hdwp ; in case of failure, still resize
            ResizeAllGadgetsInList()
            ProcedureReturn 
        EndIf
        
        ForEach gadgetsForResizing()
            hdwp = DeferWindowPos_(hdwp,
                                   GadgetID( gadgetsForResizing()\gadget ),
                                   0,
                                   gadgetsForResizing()\x,
                                   gadgetsForResizing()\y,
                                   gadgetsForResizing()\width,
                                   gadgetsForResizing()\height,
                                   #SWP_NOZORDER|#SWP_NOACTIVATE)
            If Not hdwp ; in case of failure, still resize
                ResizeAllGadgetsInList()
                ProcedureReturn 
            EndIf
        Next
        
        EndDeferWindowPos_(hdwp)
    EndIf
EndProcedure

Macro StopWindowUpdate(_winID_)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,0,0)
    CompilerEndIf
EndMacro

Macro ContinueWindowUpdate(_winID_, _redrawBackground_ = 0)
    CompilerIf #PB_Compiler_OS = #PB_OS_Windows
        SendMessage_(_winID_,#WM_SETREDRAW,1,0)
        InvalidateRect_(_winID_,0,_redrawBackground_)
        UpdateWindow_(_winID_)
    CompilerEndIf
EndMacro   

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                               ;
        winID = WindowID(#WinID)
        StopWindowUpdate(winID)
        x=WindowWidth(#WinID)                             ;
        y=WindowHeight(#WinID)                            ;
        BeginGadgetResize()
        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)   ;
        EndIf                                                                                   ;
        EndGadgetResize()
        ContinueWindowUpdate(winID,#True)
    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,"",#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
Post Reply