|
Post by angelo2449 on Oct 12, 2020 13:50:09 GMT -5
Hi guys,
I wonder if it is possible to close a program written in LB when it is minimized.
I wrote a program in LB which is called in AutoCad with a Lisp program.
I would like to close the program in LB when, by clicking on Autocad, it goes to the Windows 10 Taskbar.
Thanks, Angelo
|
|
|
Post by Chris Iverson on Oct 12, 2020 14:45:30 GMT -5
There's two ways you can do it in LB; checking periodically with a timer to see if your window is minimized, and using the WMLiberty DLL to respond to the Windows event message that tells your window it's being minimized.
Using the timer:
open "test" for window as #test #test, "trapclose [quit]" timer 1000, [minCheck] wait
[minCheck] timer 0 if IsIconic(hwnd(#test)) then close #test end end if timer 1000, [minCheck] wait
[quit] close #test end
Function IsIconic(hWnd) CallDLL #user32, "IsIconic",_ hWnd as ulong,_ IsIconic as long End Function
This code uses the IsIconic() Win32 API to determine if the #test window is minimized. ("iconic" is an old name for "minimized", from before Windows 95 when "minimizing" meant "turning into an icon on the desktop", because there wasn't a taskbar yet.)
The following example uses Brent Thorn's WMLiberty DLL to trap the WM_SIZE message being sent to the window. This message is sent when the size of the window has changed in some way, to let it know the new position. We check if the wParam of the message is "SIZE_MINIMIZED", which is how the OS tells your window that it's been minimized.
If that's the event/message we get, we close the window.
Callback lpfnSize, SizeHandler( ULong, ULong, ULong, ULong ), Long
open "test" for window as #test #test, "trapclose [quit]"
open "wmliberty" for DLL as #WMLiberty
hWnd = hwnd(#test) callDLL #WMLiberty, "SetWMHandler",_ hWnd as ulong,_ _WM_SIZE as ulong,_ lpfnSize as ulong,_ 0 as long,_ ret as long
wait
[quit] close #test close #WMLiberty end
Function SizeHandler( hWnd, uMsg, wParam, lParam ) if wParam = _SIZE_MINIMIZED then SizeHandler = 0 close #test close #WMLiberty end else SizeHandler = 1 end if End Function
|
|
|
Post by angelo2449 on Oct 13, 2020 13:52:48 GMT -5
Thanks Chris While running I get this error :
Runtime error: Impossibile trovare il modulo specificato. ( OS error 16r7E )
Error(Exception)>>defaultAction Error(Exception)>>activateHandler: <anUndefinedObject> Error(Exception)>>handle Error(Exception)>>signal Error class(Exception class)>>signal: <'Impossibile trovare ...'> BasicProgram(Object)>>error: <'Impossibile trovare ...'> BasicProgram>>terminateRun: <anError> [] in BasicProgram>>errorHandlerBlock ExceptionHandler>>evaluateResponseBlock: <aBlockClosure> for: <anError> [] in ExceptionHandler>>handle: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>handle: <anError> ExceptionHandler>>findHandler: <anError> Error(Exception)>>activateHandler: <anExceptionHandler> Error(Exception)>>handle Error(Exception)>>signal Error class(Exception class)>>signal: <'Impossibile trovare ...'> DynamicLinkLibrary class(Object)>>osError: <126> DynamicLinkLibrary class(Object)>>osError DynamicLinkLibrary class>>open: <'wmliberty'> BasicDLL>>from: <'wmliberty'> mode: <'DLL'> handle: <'#WMLiberty'> BasicDLL class(BasicFile class)>>from: <'wmliberty'> mode: <'DLL'> handle: <'#WMLiberty'> owner: <aBasicProgram> length: <anUndefinedObject> [] in OpenCommand>>using: [] in BasicProgram>>begin ExceptionHandler>>evaluateProtectedBlock: <aBlockClosure> [] in ExceptionHandler>>activateDuring: ProtectedFrameMarker(BlockClosure)>>setUnwind: <aBlockClosure> BlockClosure>>invisibleEnsure: <aBlockClosure> ExceptionHandler>>activateDuring: <aBlockClosure> ExceptionHandler class>>handle: <anError class> with: <aBlockClosure> during: <aBlockClosure> BlockClosure>>on: <anError class> do: <aBlockClosure> BasicProgram>>begin BasicProgram>>run [] in BasicSourcePane>>run BasicCompiler class>>compileFromString: <'
Callback lpf...'> notify: <aBasicSourcePane> ifSuccess: <aBlockClosure> BasicSourcePane>>run BasicSourceWindow>>run BasicEditorModel>>run: <aToolbarButton> BasicEditorModel(Object)>>perform: <#run:> with: <aToolbarButton> ToolbarButton>>triggerClickedEvent Message>>perform NotificationManager>>runPendingEvents NotificationManager>>runEventLoop Message>>perform Message>>evaluate Process>>safelyEvaluate: <aMessage> Process>>evaluate: <aMessage>
|
|
|
Post by Chris Iverson on Oct 13, 2020 14:21:26 GMT -5
Sorry, it skipped my mind to explicitly link it last post. You need to download Brent Thorn's WMLiberty DLL and put it in the same place as where you're running the source code/program form. www.b6sw.com/forum/content.php?mode=site&p=659
|
|