;########################## ;WindowsDialoge ;########################## ;Andreas Miethe * Juni 2002 ;########################## Global HInstance.l Procedure IsNT() os.OSVERSIONINFO os\dwOSVersionInfoSize = SizeOf(OSVERSIONINFO) GetVersionEx_(@os) If os\dwPlatformId = #VER_PLATFORM_WIN32_NT Retval = 1 Else Retval = 0 EndIf ProcedureReturn Retval EndProcedure Procedure IsXP() os.OSVERSIONINFO os\dwOSVersionInfoSize = SizeOf(OSVERSIONINFO) GetVersionEx_(@os) If os\dwPlatformId = #VER_PLATFORM_WIN32_NT If os\dwMinorVersion = 1 retval = 1 EndIf Else Retval = 0 EndIf ProcedureReturn Retval EndProcedure Procedure PickIconEx(x.l,y.l) UseWindow(0) Library = OpenLibrary(0,"shell32") Funktion = GetProcAddress_(Library,62);Funktionsadresse ermitteln Buffer$ = Space(128) GetSystemDirectory_(@Buffer$,128);Systemordner ermitteln IconFile$ = Buffer$+"\shell32.dll";IconFile anhaengen IconIndex = -1 ;wenn NT If IsNT() ; Unter NT WideStrings benutzen FileLen = Len(Iconfile$) BufferLen = Len(IconFile$) * 2 AllocateMemory(0,256,0) *Pointer = MemoryID() CopyMemoryString(IconFile$,@*Pointer);Filename in Memory MultiByteToWideChar_(1,1,@IconFile$,FileLen,MemoryID(),BufferLen) CallFunctionFast(Funktion,WindowID(),MemoryID(),@MaxFile,@IconIndex) WideCharToMultibyte_(0,0,MemoryID(),BufferLen,@IconFile$,FileLen,0,0) Else CallFunctionFast(Funktion,Dummy,IconFile$,@MaxFile,@IconIndex) EndIf ;Icon ins Fenster zeichnen Icon = ExtractIcon_(HInstance,IconFile$,IconIndex) StartDrawing(WindowOutput()) DrawIcon_(GetDC_(WindowID()),x,y,Icon) StopDrawing() FreeMemory(0) DestroyWindow_(Dummy) EndProcedure Procedure Winstart(p.s) Library = OpenLibrary(0,"Shell32.dll") Funktion = GetProcAddress_(Library,59) ;wenn NT If IsXP() Or IsNT() ; Unter NT WideStrings benutzen F = Len(p) B = Len(p) * 2 AllocateMemory(0,256,0) *Pointer = MemoryID() CopyMemoryString(p,@*Pointer);Filename in Memory MultiByteToWideChar_(1,1,@p,F,MemoryID(),B) Ret = CallFunctionFast(Funktion,WindowID(),MemoryID(),66) Else Ret = CallFunctionFast(Funktion,WindowID(),p,66) EndIf ;If IsXP() ;Neustart mit XP ;Schalter : ;-i ruft einen Dialog auf. ;-l meldet den aktuellen Benutzer ab ;-r Neustart ;-s Runterfahren ;-t xx wartet xx Sekunden bis zum Runterfahren ;-f schliesst geoeffnete Anwendungen ;-c ''Textmeldung'' ;-a Abbruch ; If ret = 6 ; RunProgram("shutdown.exe","-t 0 -f -r",2) ; EndIf ;EndIf FreeMemory(0) CloseLibrary(0) EndProcedure Procedure WinEnd() Library = OpenLibrary(0,"Shell32.dll") Funktion = GetProcAddress_(Library,60) CallFunctionFast(Funktion,WindowID()) CloseLibrary(0) EndProcedure Procedure Runfile() Library = OpenLibrary(0,"Shell32.dll") Funktion = GetProcAddress_(Library,61) Icon = ExtractIcon_(HInstance,"Windlg.exe",0) Dummy = OpenWindow(1, 0, GetSystemMetrics_(#SM_CYSCREEN), 0, 0, #PB_Window_Invisible,"") CallFunctionFast(Funktion,dummy,Icon,0,0,0,0) CloseLibrary(0) DestroyWindow_(Dummy) EndProcedure HWND = OpenWindow(0, 10, 10, 640, 480, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window") If HWND HInstance = GetModuleHandle_(0) If CreateGadgetList(WindowID()) ButtonGadget(1001, 10,140, 80,24,"PickIcon") ButtonGadget(1002, 10,170, 80,24,"WinStart") ButtonGadget(1003, 10,200, 80,24,"WinEnd") ButtonGadget(1004, 10,230, 80,24,"RunFile") EndIf Repeat EventID.l = WaitWindowEvent() If EventID = #PB_EventGadget If EventGadgetID() = 1001 PickIconEx(10,40) ElseIf EventGadgetID() = 1002 Winstart("Hier die dummen Bemerkungen"+Chr(13)) ElseIf EventGadgetID() = 1003 WinEnd() ElseIf EventGadgetID() = 1004 RunFile() EndIf ElseIf EventID = #PB_Event_CloseWindow Quit = 1 EndIf Until Quit =1 EndIf End ; ExecutableFormat=Windows ; UseIcon=K:\Pure-Basic\NOTE03.ICO ; Executable=K:\Pure-Basic\Windlg.exe ; DisableDebugger ; EOF