6/25/2023 0 Comments Purebasic window outer size![]() However, it has some problems too:Ģ) You can't update the list contents without closing and restarting the program.ģ) If you resize the window, the gadgets don't resize with it.Ĥ) The attributes column is still not very useful. ForEverĪt this point the application already has some useful features. In practice the loop isn't infinite because it can be stopped by clicking the window's Close button. If EventWindow = #WindowFiles CloseWindow( #WindowFiles)īreak EndIf EndSelect Go round and do it again. If EventGadget = #Folder ElseIf EventGadget = #Files EndIf Case #PB_Event_CloseWindow The window was closed. In programs with more than one form, which window did the event occur on.Ĭase #PB_Event_Gadget A gadget event occurred. Repeat Wait until a new window or gadget event occurs. It will deal with all the user interaction events that we wish to use. The Line Feed character 'Chr(10)' tells the gadget to move to the next column. Convert the attributes to a string, for now. Convert the file size to a padded string the same as with the index value above, but allow space for the maximum size of a quad. Modify = FormatDate("?/%mm/%yyyy", Files()\DateModified) These lines convert the three date values to something more familiar.Ĭreate = FormatDate("?/%mm/%yyyy", Files()\DateCreated)Īccess = FormatDate("?/%mm/%yyyy", Files()\DateAccessed) AddGadgetColumn( #Files, 1, "Name", 200)ĪddGadgetColumn( #Files, 2, "Created", 100)ĪddGadgetColumn( #Files, 3, "Accessed", 100)ĪddGadgetColumn( #Files, 4, "Modified", 100)ĪddGadgetColumn( #Files, 5, "Attributes", 150) Add columns to the ListIconGadget to hold each property. A list icon gadget to hold the file list and properties. A text gadget to show the name of the folder. OpenWindow( #WindowFiles, 50, 50, 450, 400, "File Properties", Flags) This line defines a flag for the window attributes by OR-ing together the desired attribute constants.įlags = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_TitleBar Open a GUI window. The interesting stuff starts to happen here. SortStructuredList( Files(), #PB_Sort_Ascending, OffsetOf(FILEITEM\Name), #PB_String) FinishDirectory(0)ĮndIf Sort the list into ascending alphabetical order of file name. Files()\Name = DirectoryEntryName(0)įiles()\Attributes = DirectoryEntryAttributes(0)įiles()\DateCreated = DirectoryEntryDate(0, #PB_Date_Created)įiles()\DateAccessed = DirectoryEntryDate(0, #PB_Date_Accessed)įiles()\DateModified = DirectoryEntryDate(0, #PB_Date_Modified)ĮndIf Wend Close the directory. And populate it with the properties of the file. If DirectoryEntryType(0) = #PB_DirectoryEntry_File Add a new element to the list. If the directory entry is a file, not a folder. Loop through until NextDirectoryEntry(0) becomes zero - indicating that there are no more entries. If this is ok, begin enumeration of entries. Result = ExamineDirectory(0, Folder, "*.*") Open the directory to enumerate its contents. This function gets the home directory for the logged on user. Define.l Event, EventWindow, EventGadget, EventType, EventMenu These variables will receive details of GUI events as they occur in the program. Define.s Access, Attrib, Create, Folder, Modify, Msg, Num, Size And some working variables to make things happen. Enumeration #Folder #Files EndEnumeration Now we define a list of files using the structure previously specified. Enumeration #WindowFiles EndEnumeration This is an enumeration to identify controls which will appear on the window. ![]() Structure FILEITEMĮndStructure This is a constant to identify the window. The structure for file information as before. Managing GUI elements, using that gadget would defeat this object a bit. Note that PureBasic provides a far easier way of getting this particular job doneĪlready - the ExplorerListGadget() but, as the example is intended to introduce So let's revisit the file propertiesĮxample from previous items again and turn it into a GUI application. The creation of graphical user interfaces (GUI) too. In addition to the console window, PureBasic supports ![]() Code: Select all Define i.i, rcWind.Rect, rcClient.UserGuide - Building a graphical user interface (GUI)
0 Comments
Leave a Reply. |