Maximizing Photo-Paint's workarea from script

If you want to set Photo-Paint to "Maximize Workarea" mode, you'll need to use this code. Automation interface doesn't offer such command, so we need to use this "hack". What this script does is just send a Windows message to the application window as if you were clicking the corresponding button on the toolbar. First it uses Windows API function FindWindow to locate Photo-Paint's main window and then it sends the Windows WM_COMMAND message to it:

DECLARE SUB SendMessage LIB "user32" \\
	(BYVAL hWnd&,BYVAL Msg&,BYVAL wParam&,BYVAL lParam&) ALIAS "SendMessageA"
DECLARE FUNCTION FindWindow LIB "user32" \\
	(BYVAL Class$,BYVAL Name&) AS LONG ALIAS "FindWindowA"

WITHOBJECT "CorelPhotoPaint.Automation.9"
	.SetVisible TRUE ' Ensure that the application is visible
	hWnd&=FindWindow("PhotoPaint",0)
	IF hWnd<>0 THEN
		SendMessage hWnd,&H111,&h1834F,0
	ELSE
		Message "Unable to find Photo-Paint"
	END IF
END WITHOBJECT

To ensure that the application is running and its main window is visible, WITHOBJECT is used along with SetVisible command. However you can launch Photo-Paint yourself as described in the following example: Launching an application from script.


[ CorelSCRIPT Tips&Tricks | Learning CorelSCRIPT | Oberon Home Page ]

Copyright 2000 by Alex Vakulenko. All rights reserved.
This page was last revised on 03/14/00.