; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=3534&highlight= ; Author: Stefan Moebius (updated for PB 4.00 by Andre) ; Date: 25. January 2004 ; OS: Windows ; Demo: No !extrn _PB_DirectX_ScreenWidth !extrn _PB_DirectX_ScreenHeight !extrn _PB_DirectX_WindowedMode !extrn _PB_DirectX_PrimaryBuffer !extrn _PB_DirectX_BackBuffer !extrn _PB_DDrawBase Procedure ScreenRequesterCB(hWnd,Msg,wParam,lParam) Addr=GetWindowLong_(hWnd,#GWL_USERDATA) If Addr Result=CallWindowProc_(PeekL(Addr),hWnd,Msg,wParam,lParam) If Msg=#WM_DESTROY GlobalFree_(Addr) SetWindowLong_(hWnd,#GWL_USERDATA,0) EndIf If Msg=#WM_PAINT Or Msg=#WM_MOVING Or Msg=#WM_MOVE Or Msg=#WM_ERASEBKGND DC=GetDC_(ScreenID()) BitBlt_(DC,0,0,PeekL(Addr+8),PeekL(Addr+12),PeekL(Addr+4),0,0,#SRCCOPY) ReleaseDC_(ScreenID(),DC) EndIf Else Result=DefWindowProc_(hWnd,Msg,wParam,lParam) EndIf ProcedureReturn Result EndProcedure Procedure.s ScreenOpenFileRequester(Title$,Path$,Pattern$) Global ScreenWidth,ScreenHeight,Windowed,DDrawBase.IDirectDraw7,FrontDDS.IDirectDrawSurface7,BackDDS.IDirectDrawSurface7 !MOV Eax,[_PB_DirectX_WindowedMode] !MOV [v_Windowed],Eax !MOV Eax,[_PB_DirectX_ScreenWidth] !MOV [v_ScreenWidth],Eax !MOV Eax,[_PB_DirectX_ScreenHeight] !MOV [v_ScreenHeight],Eax If Windowed=0 !MOV Eax,[_PB_DDrawBase] !MOV [v_DDrawBase],Eax !MOV Eax,[_PB_DirectX_BackBuffer] !MOV [v_BackDDS],Eax !MOV Eax,[_PB_DirectX_PrimaryBuffer] !MOV [v_FrontDDS],Eax DDrawBase\GetGDISurface(@GDI_DDS.IDirectDrawSurface7) If GDI_DDS=BackDDS BackDDS\BltFast(0,0,FrontDDS,0,0) FlipBuffers() EndIf EndIf ShowCursor_(-1) DC=GetDC_(ScreenID()) MemDC=CreateCompatibleDC_(DC) hBmp=CreateCompatibleBitmap_(DC,ScreenWidth,ScreenHeight) oldBmp=SelectObject_(MemDC,hBmp) BitBlt_(MemDC,0,0,ScreenWidth,ScreenHeight,DC,0,0,#SRCCOPY) ReleaseDC_(ScreenID(),DC) Flags=#PB_Window_ScreenCentered|#PB_Window_TitleBar OpenWindow(1000,0,0,450,280,title$,Flags) CreateGadgetList(WindowID(1000)) If Path$="" Path$=Space(255) GetCurrentDirectory_(255,@Path$) EndIf If Right(Path$,1)<>"\":Path$+"\":EndIf ExplorerComboGadget(1,0,0,300,180,Path$) ExplorerListGadget(2,0,25,450,200,Path$+Pattern$,#PB_Explorer_AlwaysShowSelection) ChangeListIconGadgetDisplay(2,2) TextGadget(3,30,247,30,20,"File:") StringGadget(4,60,245,280,20,"") ButtonGadget(5,360,230,75,20,"&Open") ButtonGadget(6,360,255,75,20,"&Cancel") OldCB=SetWindowLong_(WindowID(1000),#GWL_WNDPROC,@ScreenRequesterCB()) Addr=GlobalAlloc_(#GMEM_FIXED,16) PokeL(Addr,OldCB) PokeL(Addr+4,MemDC) PokeL(Addr+8,ScreenWidth) PokeL(Addr+12,ScreenHeight) SetWindowLong_(WindowID(1000),#GWL_USERDATA,Addr) SetWindowPos_(WindowID(1000),#HWND_TOPMOST,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE) Quit=0 Repeat Event=WaitWindowEvent() If EventType()=#PB_EventType_Change And EventGadget()=2 Pf$=GetGadgetText(2) SetGadgetText(1,Pf$) For M=0 To CountGadgetItems(2) If GetGadgetItemState(2,M)=#PB_Explorer_Selected|#PB_Explorer_File:Name$=GetGadgetItemText(2,M,0):EndIf Next SetGadgetText(4,Name$) For M=0 To 50 WindowEvent() Next EndIf If EventType()=#PB_EventType_LeftClick And EventGadget()=1 Pf$=GetGadgetText(1) SetGadgetText(2,Pf$) For M=0 To 50 WindowEvent() Next EndIf If EventGadget()=5 And Event=#PB_Event_Gadget And GetGadgetText(4)<>"":Quit=1:EndIf If EventGadget()=6 And Event=#PB_Event_Gadget:Quit=2:EndIf Until Quit Name$=GetGadgetText(4) Result.s="" If Quit=1:Result.s=Pf$+Name$:EndIf Repeat:Until WindowEvent()=0 ShowCursor_(0) SetWindowPos_(ScreenID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE) CloseWindow(1000) SetWindowPos_(ScreenID(),#HWND_NOTOPMOST,0,0,0,0,#SWP_NOSIZE|#SWP_NOMOVE) DC=GetDC_(ScreenID()) BitBlt_(DC,0,0,ScreenWidth,ScreenHeight,MemDC,0,0,#SRCCOPY) ReleaseDC_(ScreenID(),DC) SelectObject_(MemDC,oldBmp) DeleteObject_(hBmp) DeleteDC_(MemDC) ProcedureReturn Result.s EndProcedure ;Beispiel: InitKeyboard() InitSprite() InitMouse() OpenScreen(800,600,16,"ScreenOpenFileRequester") ;OpenWindow(1,0,0,800,600,1,"ScreenOpenFileRequester") ;OpenWindowedScreen(WindowID(),0,0,800,600,1,0,0) CreateSprite(1,800,600) StartDrawing(SpriteOutput(1)) LineXY(0,0,800,600,#Red) LineXY(800,0,0,600,#Red) StopDrawing() S=GetTickCount_() Repeat DisplaySprite(1,0,0) FlipBuffers() If GetTickCount_()-S>2500 Result.s=ScreenOpenFileRequester("Open","","*.pb") If Result="":End:EndIf S=GetTickCount_() EndIf ForEver ; IDE Options = PureBasic v4.02 (Windows - x86) ; Folding = -