HELP!!!!!!! PLZ!!! HELP ME!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by XuMuk.
If OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
CreateGadgetList(WindowID())
Time$ = FormatDate("%hh:%ii:%ss", Date())
TextGadget(1, 10, 8, 200, 20, Time$)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
This was my program... I just wanted to erite SIMPLE clocks, but i can't! Can someone help me? Please!!! Whats Wrong?
Plz send working proggy to [url]mailto:mail.to@rambler.ru[/url] or leave it here.... Thank U beforehand!
If OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
CreateGadgetList(WindowID())
Time$ = FormatDate("%hh:%ii:%ss", Date())
TextGadget(1, 10, 8, 200, 20, Time$)
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
This was my program... I just wanted to erite SIMPLE clocks, but i can't! Can someone help me? Please!!! Whats Wrong?
Plz send working proggy to [url]mailto:mail.to@rambler.ru[/url] or leave it here.... Thank U beforehand!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by OlliB.
Sorry for my bad English...
My way to show a clock:
A Procedure Refresh, to check the time and give it to Gadget 1.
And WindowEvent, because WaitWIndowEvent waits for an event... and the clock doesn't refresh.
Sorry for my bad English...
My way to show a clock:
A Procedure Refresh, to check the time and give it to Gadget 1.
And WindowEvent, because WaitWIndowEvent waits for an event... and the clock doesn't refresh.
Code: Select all
Global time.s
Global oldtime.s
Procedure Refresh()
Time = FormatDate("%hh:%ii:%ss", Date())
If timeoldtime
SetGadgetText(1,time)
oldtime=time
EndIf
EndProcedure
If OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
If CreateGadgetList(WindowID())
TextGadget(1, 10, 8, 200, 20, "")
EndIf
Repeat
Refresh()
EventID.l = WindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tranquil.
this part of code:
Repeat
Refresh()
EventID.l = WindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
Need 100% of your CPU Time!! Why not use a windows timer to fire an event gadget?
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
this part of code:
Repeat
Refresh()
EventID.l = WindowEvent()
If EventID = #PB_Event_CloseWindow
Quit = 1
EndIf
Until Quit = 1
EndIf
Need 100% of your CPU Time!! Why not use a windows timer to fire an event gadget?
Mike
Tranquilizer/ Secretly!
http://www.secretly.de
Registred PureBasic User
System: Windows 2000 Server, 512 MB Ram, GeForce4200 TI 128 MB DDR, Hercules Theater 6.1 DTS Sound
System 2: Mobile Pentium 4 2.4GHz 512 MB DDR GeForce4 420-32, Windows XP Home
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Here's another version using a timer to update the clock... The timer is set to update every 1000 millisecond i.e. every second.. Code is perhaps a bit advanced if you're just starting out. If you're using the demo version of PureBasic this code may perhaps not work because of the Win API calls (i.e. SetTimer_() and KillTimer_()), don't know how restricted the demo really is.
Here's another version using a timer to update the clock... The timer is set to update every 1000 millisecond i.e. every second.. Code is perhaps a bit advanced if you're just starting out. If you're using the demo version of PureBasic this code may perhaps not work because of the Win API calls (i.e. SetTimer_() and KillTimer_()), don't know how restricted the demo really is.
Code: Select all
Global hWindow.l, hTimer.l
Procedure.l MyCallback(WindowID.l, Message.l, wParam.l, lParam.l)
Result.l = #PB_ProcessPureBasicEvents
If WindowID = hWindow And Message = #WM_TIMER
Result = 0
SetGadgetText(1,FormatDate("%hh:%ii:%ss", Date()))
EndIf
ProcedureReturn Result
EndProcedure
hWindow.l = OpenWindow(0, 300, 100, 195, 260, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "PureBasic Window")
If hWindow = 0
End
EndIf
If CreateGadgetList(WindowID())
TextGadget(1, 10, 8, 200, 20, FormatDate("%hh:%ii:%ss", Date()))
EndIf
SetWindowCallback(@MyCallBack())
hTimer.l = SetTimer_(hWindow, 1, 1000, 0)
If hTimer = 0
End
EndIf
Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
KillTimer_(hWindow, hTimer)
End
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Umrof.

Pupils way is more elegant...
@Xumuk
"oldtime" memorize the time. When the time is changed, (if oldtimetime) refresh the time. So the time is only refreshed, when the time really changed.
From PB Help:
Global allows the variables to be used as global, ie: they can be accessed inside a procedure.

Olli
That's right, but I want to use XuMuk's Code, to show what the Problem in His own Code is.Need 100% of your CPU Time!! Why not use a windows timer to fire an event gadget?
Pupils way is more elegant...
@Xumuk
"oldtime" memorize the time. When the time is changed, (if oldtimetime) refresh the time. So the time is only refreshed, when the time really changed.
From PB Help:
Global allows the variables to be used as global, ie: they can be accessed inside a procedure.
Olli
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by XuMuk.
cool... I begin to understand what functions and variables are... Than u all... very much... reallly this forum is the only place where i managed to ask questions about PBasic... What i like in PBasic is that it supports tcp/ip... and I need this function very much.. thank u dor help once more
cool... I begin to understand what functions and variables are... Than u all... very much... reallly this forum is the only place where i managed to ask questions about PBasic... What i like in PBasic is that it supports tcp/ip... and I need this function very much.. thank u dor help once more
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by geoff.
Do I have to free up memory and bitmaps etc before exit?
This bit of code from Pupil raises a question for me. Is the KillTimer needed here of does PureBasic clean up all the Windows stuff at program exit?Repeat
EventID.l = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
KillTimer_(hWindow, hTimer)
End
Do I have to free up memory and bitmaps etc before exit?
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Kale.
XuMuk i would just spend a little time reading through the manual that comes with PureBasic, it would provide a good background, and maybe answer some of your questions. If you are still stuck by all means post here
There are also many good examples of code here:
http://www.reelmediaproductions.com/pb/
--Kale
Getting used to PureBasic and falling in Love!
XuMuk i would just spend a little time reading through the manual that comes with PureBasic, it would provide a good background, and maybe answer some of your questions. If you are still stuck by all means post here
http://www.reelmediaproductions.com/pb/
--Kale
Getting used to PureBasic and falling in Love!
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fred.
Fred - AlphaSND
All is cleaned by PureBasic at end. You can assume that. All free functions are here to dynamically free the objects at runtime (needed of course).Originally posted by geoff
This bit of code from Pupil raises a question for me. Is the KillTimer needed here of does PureBasic clean up all the Windows stuff at program exit?
Do I have to free up memory and bitmaps etc before exit?
Fred - AlphaSND