; German forum: http://www.purebasic.fr/german/archive/viewtopic.php?t=3472&highlight= ; Author: Stefan Moebius (updated for PB 4.00 by Deeem2031) ; Date: 18. January 2004 ; OS: Windows ; Demo: No !extrn _PB_Screen_Width !extrn _PB_Screen_Height !extrn _PB_Screen_Windowed !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 ScreenAlertBox(Title.s,Text.s,Buttons.s) Global ScreenWidth,ScreenHeight,Windowed,DDrawBase.IDirectDraw7,BackDDS.IDirectDrawSurface7 !MOV Eax,[_PB_Screen_Windowed] !MOV [v_Windowed],Eax !MOV Eax,[_PB_Screen_Width] !MOV [v_ScreenWidth],Eax !MOV Eax,[_PB_Screen_Height] !MOV [v_ScreenHeight],Eax If Windowed=0 !MOV Eax,[_PB_DDrawBase] !MOV [v_DDrawBase],Eax !MOV Eax,[_PB_DirectX_BackBuffer] !MOV [v_BackDDS],Eax DDrawBase\GetGDISurface(@GDI_DDS.IDirectDrawSurface7) If GDI_DDS=BackDDS BackDDS\BltFast(0,0,GDI_DDS,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) If Font=0:Font=GetStockObject_(#SYSTEM_FONT):EndIf Structure Button Text.s Width.l EndStructure Dim Button.Button(100) Buttons+"|" Text+Chr(13) TmpDC=CreateCompatibleDC_(0) SelectObject_(TmpDC,Font) For M=1 To Len(Buttons) If Mid(Buttons,M,1)="|" GetTextExtentPoint32_(MemDC,@Str$,Len(Str$),sz.size) Button(ButtonAnz)\Width=sz\cx+10 Button(ButtonAnz)\Text=Str$ If sz\cy+5>ButtonHeight:ButtonHeight=sz\cy+5:EndIf GesButtonWidth=GesButtonWidth+sz\cx+10 Str$="" ButtonAnz+1 Else Str$=Str$+Mid(Buttons,M,1) EndIf Next For M=1 To Len(Text) If Mid(Text,M,1)=Chr(13) GetTextExtentPoint32_(MemDC,@Str$,Len(Str$),sz.size) TextHeight+sz\cy If sz\cx+10>TextWidth:TextWidth=sz\cx+10:EndIf Str$="" Else Str$=Str$+Mid(Text,M,1) EndIf Next DeleteDC_(TmpDC) WindowWidth=GesButtonWidth+10 If WindowWidth<150:WindowWidth=150:EndIf If WindowWidth=2 And Gadget2500 Text$="This is a text"+Chr(13) Text$+"This is a text"+Chr(13) Text$+"This is a text"+Chr(13) Text$+"This is a text"+Chr(13) ScreenInputRequester("ScreenInputRequester",Text$,"Text") If ScreenAlertBox("ScreenAlertBox",Text$+"Quit ?","&Yes|&No")=1:Quit=1:EndIf S=GetTickCount_() EndIf Until Quit ; IDE Options = PureBasic v4.00 (Windows - x86) ; Folding = - ; DisableDebugger