Title: Control POV-Ray 3.5
Question: This article is about POV-Ray manipulation from delphi using
API funs.
Answer:
{
This article describe POVRay manipulation from delphi using API functions.
Maybe you know povray, it's very good renderer and it's free to download.
Thanks to Pov-Team for POVRay, but for us - programmers is important how to
control povray from.There are many 3d apps that uses povray as rendering
engine.These applications uses communication dll, probably it's better solution, but I think my solution could be also useful, and if not,it's at least
my first article.
I wrote this when I was 16, now I'm 17 and Iam bored-in fact this
is a reason why I write it :-)
}
// first, we have to know control names:
const
cP = 'Pov35MainWinClass';
A = 'ReBarWindow32';
B = 'ComboBox';
C = 'ToolbarWindow32';
D = 'Edit';
E = 'tooltips_class32';
F = 'Pov35RenderAnimWinClass';
G = '001801B3';
K = 'TParentForm';
L = 'TTabControl';
M = 'TCPanel';
N = 'TCodeMax';
O = 'TParentForm';
P = 'ComboLBox';
Q = 'TThreadWindow';
R = 'TPUtilWindow';
S = 'TPanel';
T = 'Pov35MessageWinClass';
U = 'msctls_statusbar32';
{this procedure converts hex string to cardinal (due to wParam and lParam)}
function HexToClr(const HexStr: string): Cardinal;
var
I: Integer;
C: Char;
begin
Result := 0;
for I := 1 to Length(HexStr) do
begin
C := HexStr[I];
case C of
'0'..'9': Result := Int64(16) * Result + (Ord(C) - $30);
'A'..'F': Result := Int64(16) * Result + (Ord(C) - $37);
'a'..'f': Result := Int64(16) * Result + (Ord(C) - $57);
else
raise EConvertError.Create('Illegal character in hex string');
end;
end;
end;
{this procedure executes any file,in our case-povray executable...and don't
forget to add "ShellApi"}
Procedure ExecuteFile(filename:String);
begin
ShellExecute(HANDLE_FLAG_INHERIT,'open',pChar(filename),nil,nil,SW_NORMAL);
end;
{=======================================================================}
{it simply returns true if povray is running else it returns false}
Function isPovrayRunning: boolean;
Var H: THandle;
begin
H := FindWindow(cp, nil);
if H 0 then result := true else result := false;
end;
{Finally, this procedure start rendering}
Procedure SS_POVRAY_DO_RENDER(SSparam: string);
Var H, H2, H3, H4, H5, H6, H7, H9, H10, H11, H12, H13, H14, H15, H16, H17: THandle;
begin
if ispovrayrunning = false then ExecuteFile(SSParam);
H := FindWindow(cP,nil); // handle to Main Form of the Application POV-Ray
H2 := FindWindowEx(H, 0, K, nil); // Handle of "TParentForm"
H3 := FindWindowEx(H2, 0, L, nil); // Handle of TTabControl
H4 := FindWindowEx(H3, 0, M, nil); // handle of TCPanel
H5 := FindWindowEx(H4, 0, N, nil); // handle of TCodeMax
H6 := FindWindowEx(H, 0, A, nil); // Handle of ReBarWindow32
H7 := FindWindowEx(H6, 0, C, nil); // Handle of ToolbarWindow32
// H8 := FindWindowEx(H6, 0, E, nil); // Handle of tooltips_class32
H9 := FindWindowEx(H6, 0, B, nil); // Handle of Resolution ComboBox
H10 := FindWindowEx(H6, 0, D, nil); // Handle of command line
H11 := FindWindow(P, nil); // Handle of ComboLBox
H12 := FindWindow(Q, nil); // Handle of TThreadWindow
H13 := FindWindow(R, nil); // Handle of TPUtilWindow
H14 := FindWindowEx(H3, 0, S, nil); // Handle of TPanel
H15 := FindWindowEx(H14, 0, T, nil); // Handle of POVRAY Message Tab
H16 := FindWindowEx(H, 0, U, nil); // handle of the statusBar of the Povray
H17 := FindWindowEx(H6, 0, F, nil); // handle of the pov35renderanimwinclass32
PostMessage(H6, WM_PARENTNOTIFY ,HexToClr('00000201'),HexToClr('002801B7'));
PostMessage(H , WM_PARENTNOTIFY ,HexToClr('00000201'),HexToClr('002A01B7'));
PostMessage(H7, WM_MOUSEACTIVATE ,HexToClr('00070160'),HexToClr('02010001'));
PostMessage(H6, WM_MOUSEACTIVATE ,HexToClr('00070160'),HexToClr('02010001'));
PostMessage(H , WM_MOUSEACTIVATE ,HexToClr('00070160'),HexToClr('02010001'));
PostMessage(H , WM_WINDOWPOSCHANGING , 0 , HexToClr('0012FD08'));
PostMessage(H , WM_NCPAINT , HexToClr('00000001') , 0);
PostMessage(H , WM_GETTEXT ,HexToClr('000001FE'),HexToClr('0012E298'));
PostMessage(H , WM_WINDOWPOSCHANGED ,0,HexToClr('0012FD08'));
PostMessage(H , WM_MOUSEACTIVATE ,HexToClr('00070160'),HexToClr('02010001'));
PostMessage(H11, WM_ACTIVATEAPP ,HexToClr('00000001'),0);
PostMessage(H , WM_ACTIVATEAPP ,HexToClr('00000001'), 0);
PostMessage(H12, WM_ACTIVATEAPP ,HexToClr('00000001'), 0);
PostMessage(H13, WM_ACTIVATEAPP ,HexToClr('00000001'), 0);
PostMessage(H13, WM_ACTIVATEAPP ,HexToClr('00000001'), 0);
PostMessage(H , WM_NCACTIVATE ,HexToClr('00000001'), 0);
PostMessage(H , WM_ACTIVATE ,HexToClr('00000002'), 0);
PostMessage(H , WM_SETFOCUS ,0 , 0);
PostMessage(H , WM_KILLFOCUS ,HexToClr('000302DA'), 0);
PostMessage(H5, WM_SETFOCUS ,HexToClr('00070160'), 0);
PostMessage(H7, WM_LBUTTONDOWN ,HexToClr('00000001'), HexToClr('002601AE'));
PostMessage(H7, WM_NCPAINT ,HexToClr('55040315'), 0);
PostMessage(H2, WM_NCPAINT ,HexToClr('59040315'), 0);
PostMessage(H3, WM_NCPAINT ,HexToClr('5C040315'), 0);
PostMessage(H4, WM_NCPAINT ,HexToClr('5F040315'), 0);
PostMessage(H5, WM_NCPAINT ,HexToClr('62040315'), HexToClr('00000001'));
// THIS PLACE : scrollbar - ignore
PostMessage(H5, WM_CTLCOLORSCROLLBAR ,HexToClr('14010215'), HexToClr('000302D0'));
PostMessage(H6, WM_NCPAINT ,HexToClr('68040315'), 0);
// PostMessage(H7, WM_LBUTTONDOWN ,HexToClr('00000001'), HexToClr('00000001'));
PostMessage(H10 , WM_NCPAINT ,HexToClr('6B040315'), 0);
// PostMessage(H7, WM_LBUTTONDOWN ,HexToClr('00000001'), HexToClr('00000001'));
PostMessage(H6, WM_CTLCOLOREDIT ,HexToClr('0901038C'), HexToClr('000302F8'));
PostMessage(H6, WM_CTLCOLOREDIT ,HexToClr('0901038C'), HexToClr('000302F8'));
PostMessage(H9, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H6, WM_CTLCOLOREDIT ,HexToClr('01010057'), HexToClr('000302FE'));
PostMessage(H6, WM_CTLCOLOREDIT ,HexToClr('01010057'), HexToClr('000302FE'));
// PostMessage(H7, WM_LBUTTONUP ,0 , HexToClr('002501AE'));
PostMessage(H7, WM_CAPTURECHANGED ,0, 0);
PostMessage(H6, WM_COMMAND ,HexToClr('00000802'), HexToClr('00030304'));
// PostMessage(H , WM_COMMAND ,HexToClr('00000802'), HexToClr('00030304')); //
PostMessage(H7, DM_SETDEFID ,HexToClr('000007EE'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000007DF'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000009BA'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000852'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A28'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A29'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2A'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2B'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2C'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2D'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2E'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A2F'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A30'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A31'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A32'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A33'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A34'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A35'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A36'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000A37'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000839'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000007E4'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000007E9'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('00000807'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('0000097E'), 0);
PostMessage(H7, DM_REPOSITION ,HexToClr('0000097E'), 0);
PostMessage(H7, TB_HIDEBUTTON ,HexToClr('00000802'), HexToClr('00000001'));
PostMessage(H7, TB_HIDEBUTTON ,HexToClr('00000803'), 0); //
PostMessage(H10, WM_CANCELMODE ,0, 0);
PostMessage(H10, WM_ENABLE ,0, 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000007EE'), 0);
PostMessage(H , WM_WINDOWPOSCHANGING ,0, HexToClr('0012E7B4'));
PostMessage(H , WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E788'));
PostMessage(H , WM_NCPAINT ,HexToClr('44040339'), 0);
PostMessage(H , WM_GETTEXT ,HexToClr('000001FE'), HexToClr('0012CD44'));
PostMessage(H , WM_WINDOWPOSCHANGED ,0, HexToClr('0012E7B4'));
PostMessage(H7, DM_SETDEFID ,HexToClr('000007EE'), 0);
PostMessage(H7, DM_SETDEFID ,HexToClr('000007EE'), HexToClr('00000001'));
PostMessage(H9, CB_GETCURSEL ,0, 0);
PostMessage(H9, CB_GETLBTEXTLEN ,HexToClr('00000003'), 0);
PostMessage(H9, CB_GETLBTEXT ,HexToClr('00000003'), HexToClr('0012DF44'));
PostMessage(H9, CB_GETCURSEL ,0, 0);
PostMessage(H9, CB_GETITEMDATA ,HexToClr('00000003'), 0);
PostMessage(H11, LB_GETITEMDATA ,HexToClr('00000003'), 0);
PostMessage(H , WM_WINDOWPOSCHANGING ,0, HexToClr('0012E7CC'));
PostMessage(H , WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E7A0'));
PostMessage(H , WM_NCPAINT ,HexToClr('90040710'), 0);
PostMessage(H , WM_GETTEXT ,HexToClr('000001FE'), HexToClr('0012CD5C'));
PostMessage(H , WM_WINDOWPOSCHANGED ,0, HexToClr('0012E7CC'));
PostMessage(H14, WM_WINDOWPOSCHANGING ,0 , HexToClr('0012E568'));
PostMessage(H14, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H14, WM_WINDOWPOSCHANGED ,0, HexToClr('0012E568'));
PostMessage(H4 , WM_WINDOWPOSCHANGING ,0 , HexToClr('0012E5F4'));
PostMessage(H4 , WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E5C8'));
PostMessage(H14, WM_NCPAINT ,HexToClr('82040315'), 0);
PostMessage(H15, WM_NCPAINT ,HexToClr('83040315'), 0);
PostMessage(H4, WM_WINDOWPOSCHANGED ,0, HexToClr('0012E5F4'));
PostMessage(H4, WM_SIZE ,0 , HexToClr('020A340D'));
PostMessage(H5, WM_WINDOWPOSCHANGING ,0, HexToClr('0012DDAC'));
PostMessage(H5, WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012DD80'));
PostMessage(H5, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H5, WM_WINDOWPOSCHANGED ,0, HexToClr('0012DDAC'));
PostMessage(H5, WM_SIZE ,0, HexToClr('0208034B'));
PostMessage(H5, WM_CTLCOLORSCROLLBAR ,HexToClr('14010215'), HexToClr('000302D0'));
PostMessage(H14, WM_WINDOWPOSCHANGING ,0, HexToClr('0012E4DC'));
PostMessage(H14, WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E4B0'));
PostMessage(H14, WM_WINDOWPOSCHANGED ,0 , HexToClr('0012E4DC'));
PostMessage(H14, WM_MOVE ,0, HexToClr('02250004'));
PostMessage(H14, WM_SIZE ,0, HexToClr('004B034D'));
PostMessage(H14, WM_WINDOWPOSCHANGING ,0 , HexToClr('0012E5F4'));
PostMessage(H14, WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E5C8'));
PostMessage(H14, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H15, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H14, WM_WINDOWPOSCHANGED ,0 , HexToClr('0012E5F4'));
PostMessage(H14, WM_MOVE ,0 , HexToClr('022A0004'));
PostMessage(H14, WM_SIZE ,0 , HexToClr('0046034D'));
PostMessage(H15, WM_WINDOWPOSCHANGING ,0, HexToClr('0012E480'));
PostMessage(H15, WM_NCCALCSIZE ,HexToClr('00000001'), HexToClr('0012E454'));
PostMessage(H15, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H15, WM_WINDOWPOSCHANGED ,0 , HexToClr('0012E480'));
PostMessage(H15, WM_SIZE ,0 , HexToClr('00320339'));
PostMessage(H14, WM_WINDOWPOSCHANGING ,0 , HexToClr('0012E630'));
PostMessage(H14, WM_CHILDACTIVATE ,0, 0);
PostMessage(H5 , WM_CTLCOLORSCROLLBAR,HexToClr('12010261'), HexToClr('000302D0'));
PostMessage(H6, WM_CTLCOLORSTATIC ,HexToClr('0901038C'), HexToClr('000302F8'));
PostMessage(H6, WM_CTLCOLORSTATIC ,HexToClr('0901038C'), HexToClr('000302F8'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000005'), HexToClr('0012CBA4'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000006'), HexToClr('0060292C'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000005'), HexToClr('058FFB54'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000006'), HexToClr('00646E10'));
PostMessage(H17, WM_GETMINMAXINFO ,0 , HexToClr('0012D434'));
PostMessage(H17, WM_NCCREATE ,0 , HexToClr('0012D410'));
PostMessage(H17, WM_NCCALCSIZE ,0, HexToClr('0012D454'));
PostMessage(H17, WM_CREATE ,0, HexToClr('0012D3FC'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('000007EE'), 0);
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000893'), HexToClr('00000001'));
PostMessage(H7 , TB_HIDEBUTTON ,HexToClr('000007EE'), HexToClr('00000001'));
PostMessage(H7 , TB_HIDEBUTTON ,HexToClr('00000893'), 0);
PostMessage(H17, WM_WINDOWPOSCHANGING ,0, HexToClr('0012D53C'));
PostMessage(H , WM_WINDOWPOSCHANGING ,0, HexToClr('0012D53C'));
PostMessage(H , WM_NCACTIVATE ,0 , HexToClr('00D3027A'));
PostMessage(H , WM_ACTIVATE ,0 , HexToClr('00D3027A'));
PostMessage(H17, WM_WINDOWPOSCHANGING ,0 , HexToClr('0012D53C'));
PostMessage(H , WM_WINDOWPOSCHANGING ,0 , HexToClr('0012D53C'));
PostMessage(H17, WM_NCACTIVATE ,HexToClr('00000001'), HexToClr('0070160'));
PostMessage(H17, WM_ACTIVATE ,HexToClr('00000001'), HexToClr('0070160'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000006'), HexToClr('00646E10'));
PostMessage(H5 , WM_KILLFOCUS ,HexToClr('00D3027A'), 0);
PostMessage(H17, WM_SETFOCUS ,HexToClr('000302DA'), 0);
PostMessage(H17, WM_NCPAINT ,HexToClr('00000001'), 0);
PostMessage(H17, WM_WINDOWPOSCHANGED ,0 , HexToClr('0012D53C'));
PostMessage(H , WM_SETTEXT ,0 , HexToClr('0012E770'));
PostMessage(H16, DM_SETDEFID ,0 , HexToClr('006298C0'));
PostMessage(H16, DM_SETDEFID ,0 , HexToClr('006298C0'));
PostMessage(H16, DM_SETDEFID ,0 , HexToClr('006298C0'));
PostMessage(H16, DM_SETDEFID ,0 , HexToClr('006298C0'));
PostMessage(H16, DM_SETDEFID ,0 , HexToClr('006298C0'));
PostMessage(H16, DM_SETDEFID ,HexToClr('00000006') , HexToClr('0060292C'));//
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000852') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('000007DF') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('000009BA') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('000007E9') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('000007EB') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A28') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A29') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2A') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2B') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2C') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2D') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2E') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A2F') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A30') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A31') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A32') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A33') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A34') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A35') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A36') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000A37') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000839') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000807') , HexToClr('00000001'));
PostMessage(H7 , DM_SETDEFID ,HexToClr('0000097E') , 0); //
PostMessage(H7 , DM_REPOSITION ,HexToClr('0000097E') , 0);
PostMessage(H7 , TB_HIDEBUTTON ,HexToClr('00000802') , 0);
PostMessage(H7 , TB_HIDEBUTTON ,HexToClr('00000803') , HexToClr('00000001'));
PostMessage(H10 , WM_ENABLE ,HexToClr('00000001') , 0);
PostMessage(H7 , DM_SETDEFID ,HexToClr('000007EE') , 0);
PostMessage(H7 , DM_SETDEFID ,HexToClr('00000852') , HexToClr('00000001'));
end;
(*
I don't know if you using povray or no,I wrote it to my own 3d app,and I think
it could be useful for some people....so why not..
If you'd like to have code, please send me e-mail...
*)
Ivan Sivak
@Sizesoft