I have written an application to program some hardware via the serial port (using MVCOM) and it works well and is crash free in the hands of inexpert users, except... on some machines... programming fails and has to be re-started...
When the window is moved it hogs sufficient resources to introduce some timing errors. Is there a neat way to force the window to the front, keep it there and prevent it being dragged while the time critical functions are being carried out, then return to normal operation after programming is finished?
RichardL
Stopping A Window Moving
-
gnozal
- PureBasic Expert

- Posts: 4229
- Joined: Sat Apr 26, 2003 8:27 am
- Location: Strasbourg / France
- Contact:
To lock a window
Easy way :
Or :
Check #WM_WINDOWPOSCHANGING message in callback
Easy way :
Code: Select all
PureRESIZE_SetWindowMonitoring(WindowNumber.l, Flag.l) ; Monitor a window [forbids moving or resizing]Check #WM_WINDOWPOSCHANGING message in callback
Code: Select all
Procedure myWindowCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_WINDOWPOSCHANGING
If hwnd = WindowID(0)
*WinPos.WINDOWPOS = lParam
*WinPos\flags = #SWP_NOMOVE | #SWP_NOSIZE ; delete this line and it will move ...
result = #False
EndIf
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 200, 200, 200, "Locked Window", #PB_Window_SystemMenu) And CreateGadgetList(WindowID(0))
SetWindowCallback(@myWindowCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIfFor free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
- netmaestro
- PureBasic Bullfrog

- Posts: 8452
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Something else you might consider is putting the programming function in a thread and giving it "Time Critical" priority, which will cause the OS to give all the resources to it while it runs. If moving a window can make it crash it's an option I'd be looking at quite seriously. (assuming the programming is accomplished in a reasonably short time)
BERESHEIT
The timing problem that started this thread was very specific to the hardware that was being programmed via the RS232 port.
Genearally the serial comms are very reliable and have sufficient buffering to cater for most things. For example, on a USB interface I wrote, which used RS232 comms to tell remote hardware which packets to send via USB, I could scrub a half screen window around as much as I liked, the transfer just slowed down.
However, in the current case there are some absolute timings that the peripheral imposes and these were causing the problem. I'm going to try Gnozal's library as a solution... the next cut of the software is due next month and I will see if that fixes the problem.
Thanks guys.
Genearally the serial comms are very reliable and have sufficient buffering to cater for most things. For example, on a USB interface I wrote, which used RS232 comms to tell remote hardware which packets to send via USB, I could scrub a half screen window around as much as I liked, the transfer just slowed down.
However, in the current case there are some absolute timings that the peripheral imposes and these were causing the problem. I'm going to try Gnozal's library as a solution... the next cut of the software is due next month and I will see if that fixes the problem.
Thanks guys.

