Is it possible to Position a saveFileRequester in the foreground ?
Thanks for your help

Code: Select all
;====================================================================
; Demo: Position a Requester
; Author: Lloyd Gallant (netmaestro)
; Date: January 2, 2008
; Target OS: Microsoft Windows All
; Target Compiler: PureBasic 4.0 and later
; Applies to: Any requester or messagebox of dialog class
;====================================================================
Global hook
Procedure CbtProc(nCode, wParam, lParam)
Select nCode
Case #HCBT_CREATEWND
hWnd = wParam
*pcbt.CBT_CREATEWND = lParam
*pcs.CREATESTRUCT = *pcbt\lpcs
If *pcs\lpszClass = 32770
w = GetSystemMetrics_(#SM_CXSCREEN)
h = GetSystemMetrics_(#SM_CYSCREEN)
*pcs\x = w/2 -*pcs\cx /2
*pcs\y = h/2 -*pcs\cy /2
UnhookWindowsHookEx_(hook)
EndIf
EndSelect
ProcedureReturn CallNextHookEx_(hook, nCode, wParam, lParam)
EndProcedure
; This code, all except for one line (SetWindowsHookEx..[..]) is the PB doc example for SaveFileRequester:
StandardFile$ = "C:\autoexec.bat" ; set initial file+path to display
; With next string we will set the search patterns ("|" as separator) for file displaying:
; 1st: "Text (*.txt)" as name, ".txt" and ".bat" as allowed extension
; 2nd: "PureBasic (*.pb)" as name, ".pb" as allowed extension
; 3rd: "All files (*.*) as name, "*.*" as allowed extension, valid for all files
Pattern$ = "Text (*.txt)|*.txt;*.bat|PureBasic (*.pb)|*.pb|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
hook = SetWindowsHookEx_(#WH_CBT, @CbtProc(), #Null, GetCurrentThreadId_())
File$ = SaveFileRequester("Please choose file to save", StandardFile$, Pattern$, Pattern)
If File$
MessageRequester("Information", "You have selected following file:"+Chr(10)+File$, 0)
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
I mean "au premier plan" in frenchI'm assuming by "foreground" you mean screencentered. If not then I missed the boat.
Code: Select all
;====================================================================
; Demo: Position a Requester
; Author: Lloyd Gallant (netmaestro)
; Date: January 2, 2008
; Target OS: Microsoft Windows All
; Target Compiler: PureBasic 4.0 and later
; Applies to: Any requester or messagebox of dialog class
;====================================================================
#Form = 1
#ImagePressePapier = 10
Global hook
Global Encodeur
Global Extension.s
Procedure CbtProc(nCode, wParam, lParam)
Select nCode
Case #HCBT_CREATEWND
hWnd = wParam
*pcbt.CBT_CREATEWND = lParam
*pcs.CREATESTRUCT = *pcbt\lpcs
If *pcs\lpszClass = 32770
w = GetSystemMetrics_(#SM_CXSCREEN)
h = GetSystemMetrics_(#SM_CYSCREEN)
*pcs\x = w/2 -*pcs\cx /2
*pcs\y = h/2 -*pcs\cy /2
UnhookWindowsHookEx_(hook)
EndIf
EndSelect
ProcedureReturn CallNextHookEx_(hook, nCode, wParam, lParam)
EndProcedure
hook = SetWindowsHookEx_(#WH_CBT, @CbtProc(), #Null, GetCurrentThreadId_())
Hwnd = OpenWindow(#Form, 10000, 10000, 640, 480, "")
Repeat
Delay(100)
If GetClipboardImage(#ImagePressePapier)
Fichier$ = SaveFileRequester("Please choose file to save", "c:\", "Image Jpg|*.jpg|Image BitMap|*.bmp", 0)
ExtensionChoisie = SelectedFilePattern()
If Trim(Fichier$) <> ""
Select ExtensionChoisie
Case 0
UseJPEGImageEncoder()
Encodeur = #PB_ImagePlugin_JPEG
Extension = ".jpg"
Case 1
Encodeur = #PB_ImagePlugin_BMP
Extension = ".bmp"
EndSelect
If Right(LCase(Fichier$), 4) <> LCase(Extension)
Fichier$ + Extension
EndIf
SaveImage(#ImagePressePapier,Fichier$, Encodeur)
EndIf
ClearClipboard()
Break
EndIf
ForEver
End
Code: Select all
;====================================================================
; Demo: Position a Requester
; Author: Lloyd Gallant (netmaestro)
; Date: January 2, 2008
; Target OS: Microsoft Windows All
; Target Compiler: PureBasic 4.0 and later
; Applies to: Any requester or messagebox of dialog class
;====================================================================
#Form = 1
#ImagePressePapier = 10
Global hook
Global Encodeur
Global Extension.s
Procedure CbtProc(nCode, wParam, lParam)
Select nCode
Case #HCBT_CREATEWND
hWnd = wParam
*pcbt.CBT_CREATEWND = lParam
*pcs.CREATESTRUCT = *pcbt\lpcs
If *pcs\lpszClass = 32770
w = GetSystemMetrics_(#SM_CXSCREEN)
h = GetSystemMetrics_(#SM_CYSCREEN)
*pcs\x = w/2 -*pcs\cx /2
*pcs\y = h/2 -*pcs\cy /2
UnhookWindowsHookEx_(hook)
EndIf
EndSelect
ProcedureReturn CallNextHookEx_(hook, nCode, wParam, lParam)
EndProcedure
Hwnd = OpenWindow(#Form, 1000, 1000, 640, 480, "")
; give ourselves a handle to grab the application by
wHotkey.w = 593 ; CTRL + Q
SendMessage_(WindowID(#Form), #WM_SETHOTKEY, wHotkey, 0)
Repeat
WaitWindowEvent(1)
If GetClipboardImage(#ImagePressePapier)
; give this application keyboard focus
keybd_event_(#VK_CONTROL, 0,0,0)
keybd_event_(#VK_Q, 0,0,0)
keybd_event_(#VK_CONTROL, 0,#KEYEVENTF_KEYUP,0)
keybd_event_(#VK_Q, 0,#KEYEVENTF_KEYUP,0)
hook = SetWindowsHookEx_(#WH_CBT, @CbtProc(), #Null, GetCurrentThreadId_())
Fichier$ = SaveFileRequester("Please choose file to save", "c:\", "Image Jpg|*.jpg|Image BitMap|*.bmp", 0)
ExtensionChoisie = SelectedFilePattern()
If Trim(Fichier$) <> ""
Select ExtensionChoisie
Case 0
UseJPEGImageEncoder()
Encodeur = #PB_ImagePlugin_JPEG
Extension = ".jpg"
Case 1
Encodeur = #PB_ImagePlugin_BMP
Extension = ".bmp"
EndSelect
If Right(LCase(Fichier$), 4) <> LCase(Extension)
Fichier$ + Extension
EndIf
SaveImage(#ImagePressePapier,Fichier$, Encodeur)
EndIf
ClearClipboard()
Break
EndIf
ForEver
End