Forum | | | | - Page 1 - |
| Jac de Lad | Hm, I know none, where I begin should...
my trouble is the following: I have one Program, that next to the normalen term too The whole Time (once per second updated) The Uhrzeit and the Speicherverbrauch in the Statusbar Show should. I habs yet with the Thread.pcu made. but iF rät of it ex, zurecht. Gaaaaanz seldom comes it to, that at terminate to a Error Message comes, because the benötigte Memory-Variable faster disposed becomes as the Thread terminates (very said becomes each second a Message created, The then whom Bilschirm fill).
so, now has the iF said, that The PCU superfluously is, there it Yes in XProfan 11 Subclassing gives. and he's itself too any trouble given me the To explain, but I habs not understood. therefore times the question: has someone Perhaps an example for a Program, the either in the Waitinput stick (to that example one anklickbarer Button) and over 2 functions something outputs or another?
Jac |
| | | Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 03/27/08 ▲ |
| |
| | | | | - Page 1 - |
| Andreas Miethe
| IntervalProc coming To late
already ready with the example.
Statement moreover. it go 2 Files needed, once the eigentliche Program, to that others the what whom Loop contains. The Loop-Program must compiled his. the Hauptprogramm launch itself simply yourself with Parameters (Loop-Program) new. the whole functions only if both programs compiled are !
is Perhaps yet verbesserungswürdig, functions but first !
Loop-Program ( as timer.prf Save and kompilieren ) CompileMarkSeparation Hauptprogramm CompileMarkSeparation#########################################
Thread started, pausieren let, terminate
Andreas Miethe 28.03.2008
#########################################
BEACHTE : started as EXE or STRG+F8
#########################################
$IFDEF Compiler
$H windows.ph
$H Structs.ph
$H Messages.ph
Struct StartupInfo = ~STARTUPINFO
Struct ProcessInfo = ~PROCESS_INFORMATION
Struct MEMORYSTATUS = ~MEMORYSTATUS
Var Ende& = 0
cls ~GetSysColor(~COLOR_BTNFACE)
Declare ProcessHandle&,Processhandle1&
Declare ThreadHandle&,Threadhandle1&
Proc CreateThread
Parameters Param$
Declare StartupInfo#,CommandString$,ProcessInfo#
Declare Retval&,Processhandle&,ThreadHandle&
CommandString$ = Par$(0) + + Param$
Dim StartupInfo#,StartupInfo
Clear StartupInfo#
StartupInfo#.cb& = SizeOf(StartupInfo#)
Dim ProcessInfo#,ProcessInfo
Clear ProcessInfo#
~CreateProcess(0,Addr(CommandString$),0,0,0,0,0,0,StartupInfo#,ProcessInfo#)
ProcessHandle& = ProcessInfo#.hProcess&
ThreadHandle& = ProcessInfo#.hThread&
Dispose StartupInfo#
Dispose ProcessInfo#
Return Str $(ProcessHandle&)+,+Str $(ThreadHandle&)
ENDPROC
Proc TerminateThread
Parameters ProcessHandle&
Declare ExitCode&
~GetExitCodeProcess(Processhandle&,Addr(ExitCode&))
~TerminateProcess(Processhandle&,ExitCode&)
ENDPROC
Proc PauseThread
Parameters Threadhandle&
~SuspendThread(Threadhandle&)
ENDPROC
Proc ResumeThread
Parameters Threadhandle&
~ResumeThread(Threadhandle&)
ENDPROC
Var Handles$ =
Var Start& = Create(Button,%hwnd,Start,10,10,80,24)
Var Pause& = Create(Button,%hwnd,interval,10,40,80,24)
Var Resume& = Create(Button,%hwnd,continue,10,70,80,24)
Var Terminate& = Create(Button,%hwnd,end,10,100,80,24)
Var Empfang& = Create(TEXT,%hwnd,,10,130,80,24)
SendMessage(Start&,~WM_SETFONT,~GetStockObject(~ANSI_VAR_FONT),1)
SendMessage(Pause&,~WM_SETFONT,~GetStockObject(~ANSI_VAR_FONT),1)
SendMessage(Resume&,~WM_SETFONT,~GetStockObject(~ANSI_VAR_FONT),1)
SendMessage(Terminate&,~WM_SETFONT,~GetStockObject(~ANSI_VAR_FONT),1)
SendMessage(Empfang&,~WM_SETFONT,~GetStockObject(~ANSI_VAR_FONT),1)
EnableWindow Pause&,0
EnableWindow Resume&,0
EnableWindow Terminate&,0
Var Statusbar& = Create(Status Window,%hwnd,)
UpdateStatus(Statusbar&)
SubClass StatusBar&,1SubClassing on
~SetTimer(StatusBar&,1,1000,0)Timer on The Statusbar hang
SubClass %hwnd,1SubClassing on
User Messages ~wm_close
WhileNot Ende&
Waitinput
If Clicked(Start&)
The Exe launch itself yourself yet once with Parameters
the Parameter, the here expects becomes is one one Compilations ( PRC-File )
Handles$ = CreateThread(Timer.prc +st$(Empfang&))
ProcessHandle1& = Val(Substr$(Handles$,1,,))
ThreadHandle1& = Val(Substr$(Handles$,2,,))
EnableWindow Pause&,1
EnableWindow Terminate&,1
EnableWindow Start&,0
Elseif Clicked(Pause&)
PauseThread(ThreadHandle1&)
EnableWindow Pause&,0
EnableWindow Resume&,1
ElseIf Clicked(Resume&)
ResumeThread(ThreadHandle1&)
EnableWindow Pause&,1
EnableWindow Resume&,0
ElseIf Clicked(Terminate&)
EnableWindow Pause&,0
EnableWindow Resume&,0
EnableWindow Terminate&,0
EnableWindow Start&,1
TerminateThread(ProcessHandle1&)
Endif
If %Umessage = ~wm_close
if TerminateThread() not with End of program called becomes,
runs the 2.Program moreover !
TerminateThread(ProcessHandle1&)
Ende& = 1
Endif
EndWhile
SubClass StatusBar&,0
SubClass %hwnd,0
end
Proc UpdateStatus
Parameters Statusbar&
Declare MemStatus#
Dim Memstatus#,MEMORYSTATUS
MemStatus#.dwLength& = SizeOf(MemStatus#)
~Global memory status(MemStatus#)
SetText Statusbar&,now : +time$(0)+:+Left$(time$(1),2)+ - Speicherverbrauch : +Str $(MemStatus#.dwMemoryLoad&)+%
Dispose MemStatus#
ENDPROC
SubClassProc
If SubClassMessage(%hwnd, ~WM_SIZE)
SetWindowPos Statusbar& = 0,0-0,0
ElseIf SubClassMessage(Statusbar&, ~WM_TIMER)
UpdateStatus(&sWnd)
Endif
ENDPROC
|
| | | Gruss Andreas ________ ________ ________ ________ _ Profan 3.3 - XProfanX2 Win 95,98,ME,2000,XP,Vista - Win 7 32 / 64 Bit ASUS X93S - Intel Core I7-NVIDIA GForce 540M 8GB Arbeitsspeicher Homepage : [...] | 03/28/08 ▲ |
| |
| | | | - Page 2 - |
| | Jac de Lad | but here go 2 programs needed, this is Mist. |
| | | Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 03/28/08 ▲ |
| |
| | | but Perhaps is it grade therefore again one Denkanstoß the one truer 2. Thread for your think about (alike How verpackt) simply uneffizient is, time independent of it the Andreas there a super Prozessverpackung vormacht The copies to Codesnippets heard! |
| | | | |
| | Jac de Lad | say wirs time so: I see the one. Aaaaaaber, I can in my Prog not 500 SetStatus() install. |
| | | Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 03/28/08 ▲ |
| |
| | Jörg Sellmeyer | From Uwe Pascal Niemeyer (or wars Sebastian king?) there were time an example, in the with Assembler a watch in the Statusbar gesteuert becomes. I habs now not parat, but Perhaps can You Yes time on its HP search. |
| | | Windows XP SP2 XProfan X4... und hier mal was ganz anderes als Profan ... | 03/28/08 ▲ |
| |
| | Frank Abbing |
From Uwe Pascal Niemeyer (or wars Sebastian king?) there were time an example, in the with Assembler a watch in the Statusbar gesteuert becomes. I habs now not parat, but Perhaps can You Yes time on its HP search.
there becomes by Assembler one Thread launched. therein can but no Profancode run out. Jac, something like is with XPIA very simply possible. |
| | | | |
| | Jac de Lad | Hm...I seh here nothing around through...I mean I lasses, is To tricky only for ne watch and ne Speicheranzeige... |
| | | Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 03/29/08 ▲ |
| |
| | Frank Abbing | Hm, straight this example Permanente watch is still with XPIA thereby... CompileMarkSeparation {$iq}
Declare dh&,x&,y&,z&,thread&
Cls
If 0
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AsmStart StartClock(x&)
.data
hwnd dd 0
vthread dd 0
.data?
uhrtext db 24 dup(?)
.code
m2m hwnd,para1
jmp start
thread:
szText komm, - eine permanente Uhr.
.while 1
invoke GetTimeFormat,0,0,0,0,addr uhrtext,20
invoke lstrcat,addr uhrtext,addr komm
invoke SendMessage,hwnd,WM_SETTEXT,0,addr uhrtext
invoke Sleep,1000
.endw
start:
invoke CreateThread,0,0,addr thread,0,0,addr vthread
AsmEnd
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AsmStart StopClock(x&)
invoke TerminateThread,para1,STILL_ACTIVE
AsmEnd
EndIf
thread&=Call(xpia_getprocaddressm(xpia_hmodule&,StartClock),%hwnd)
Print %hwnd
Whileloop 20000
Print Int(Rnd(100000))
EndWhile
Call(xpia_getprocaddressm(xpia_hmodule&,StopClock),thread&)
Print
Demo Ende.
Waitinput
f='./../../Function-References/XProfan/end/'>End
|
| | | | |
| | Frank Abbing | the same in reinem Profan, only with TimerProc in lieu of one own Threads: CompileMarkSeparationDEF SetATimer(4) !USER32,SetTimer
DEF KillATimer(2) !USER32,KillTimer
DEF GetTimeFormat(6) !KERNEL32,GetTimeFormatA
Proc timerproc
Declare text$
text$=Space$(20)
GetTimeFormat(0,0,0,0,Addr(text$),20)
text$=Uhrzeit: +text$
SetText %hwnd,text$
EndProc
Cls
SetATimer(%hwnd,1,1000,ProcAddr(timerproc,0))
Whileloop 20000
Print Int(Rnd(100000))
EndWhile
Print
Demo Ende.
Waitinput
KillATimer(%hwnd,1)
End
|
| | | | |
| | Jac de Lad | very something like Have I sought. |
| | | Profan² 2.6 bis XProfan 11.1+XPSE+XPIA+XPRR (und irgendwann XIDE) Core2Duo E8500/T2250, 8192/1024 MB, Radeon HD4850/Radeon XPress 1250, Vista64/XP | 03/30/08 ▲ |
| |
| | | Jac
very something like Have I sought.
very something like becomes you sure plenty joy bring! |
| | | | |
| | |
| | | | |
|
AnswerThemeninformationenthis Topic has 5 subscriber: |