I'm looking for a way to pause a program and monitor the keyboard or mouse.
The program I have kludged up allows me to select a directory of images and display the Landscape pictures on my 2560 x 1440 display, and the Portrait pictures on my second 1440 x 2560 display.
The only way I can find to pause the execution is using MessageRequester, which appears in the middle of the display- on top of the image.
I'm hoping that the experienced PB people can assist me, as I haven't written programs since my Apple ][ days.
I'd prefer as OS agnostic solution, as I'd like to run it on my Mac or my PC.
Thanks in advance.
Code: Select all
Declare loopdiraf(path.s)
UseJPEGImageDecoder()
UseTGAImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseGIFImageDecoder()
Monitor0Width.i=1440
Monitor0Height.i=2560
Monitor1Width.i=2560
Monitor1Height.i=1440
MonitorPad = 0
Procedure MoveWindowToDesktop(Window.i, Desktop.i, x.i, y.i, Flags.i=0)
If IsWindow(Window)
If ExamineDesktops() > Desktop
If Flags = #PB_Window_ScreenCentered
x = (DesktopWidth(Desktop) - WindowWidth(Window)) / 2
y = (DesktopHeight(Desktop) - WindowHeight(Window)) / 2
EndIf
ResizeWindow(Window, DesktopX(Desktop) + x, DesktopY(Desktop) + y, #PB_Ignore, #PB_Ignore)
EndIf
EndIf
EndProcedure
InitPath$ = "minim1" ; here change to your Root Lan machine name
Path$ = PathRequester("Choose a directory", InitPath$)
If Path$
;MessageRequester("Information", "You choose :"+Chr(10)+Path$, 0)
Else
MessageRequester("Information", "Canceled.", 0)
EndIf
Global Directory$ = Path$
; MAINPROGRAM
;=================
Global n
MaxPix = 150
Global Dim FileNames$(MaxPix)
loopdiraf(Directory$)
SortArray(FileNames$(),#PB_Sort_Ascending )
For n=0 To MaxPix
If FileNames$(n) <> ""
LoadImage(0, FileNames$(n))
imgW.f = ImageWidth(0)
imgH.f = ImageHeight(0)
imagsize$= "W "+StrF(imgW) + " H "+ StrF(imgH)
If imgW > imgH
;LANDSCAPE
INewWidth.f = imgW / (imgH/Monitor1Height )
INewHeight.f = Monitor1Height
ResizeImage(0, INewWidth, INewHeight)
Result$ = StrF(INewWidth)+" "+StrF(INewHeight)
OpenWindow(0, 0, 0, INewWidth, INewHeight, Result$, #PB_Window_BorderLess )
MoveWindowToDesktop(0, 1, 0, 0)
ImageGadget(#PB_Any, 0, 0, INewWidth, INewWidth, ImageID(0), #PB_Window_BorderLess )
Else
;PORTRAIT
INewWidth.f = Monitor0Width
INewHeight.f = (ImgH- MonitorPad) / (imgW/Monitor0Width)
ResizeImage(0, INewWidth, INewHeight)
Result$ = StrF(INewWidth)+" "+StrF(INewHeight)
OpenWindow(0, 0, 0, INewWidth, INewHeight, Result$, #PB_Window_BorderLess )
MoveWindowToDesktop(0, 0, 0, 0)
ImageGadget(#PB_Any, 0, 0, INewWidth, INewHeight, ImageID(0), #PB_Window_BorderLess )
EndIf
;
Result = MessageRequester("Title", "Please make your input:", #PB_MessageRequester_YesNo)
a$ = "Result of the requester was: "
If Result = #PB_MessageRequester_Yes ; pressed Yes button
a$ + "Yes"
Else ; pressed No button
a$ + "No"
End
EndIf
EndIf
Next
End
Procedure loopdiraf(path.s) ; this must be a recursive routine
Define.i Id
Id = ExamineDirectory(#PB_Any, path, "*.*")
n=0
If Id
While NextDirectoryEntry(Id)
If DirectoryEntryName(Id) = "." : Continue : EndIf
If DirectoryEntryName(Id) = ".." : Continue : EndIf
If DirectoryEntryType(Id) = #PB_DirectoryEntry_File
;Type$ = " [File] "
;Debug path + "\" + DirectoryEntryName(Id) + Type$ + " " + Str(DirectoryEntrySize(Id))
;Else
; Type$ = " [Sub-Dir] "
;Debug path + "\" + DirectoryEntryName(Id) + Type$ +Str(n)
;FileNames$(n)= path + "/" + DirectoryEntryName(Id) ; extra / ...?
FileNames$(n)= path + DirectoryEntryName(Id)
; Debug FileNames$(n)
; loopdiNextaf(path + "\" + DirectoryEntryName(Id))
n =n + 1
EndIf
Wend
FinishDirectory(Id)
EndIf
EndProcedure

