PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

ActiveX update! (Events are now supported!)

Hi,

Just to give you a very nice idea on how ActiveX events will be supported. Here is a little code sample I use to test with:

Code:
// ActiveX controls
#include "windows.ppl"
#include "console.ppl"

func WndProc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;

case (Msg$)

/*WM_PAINT:
global(a$);
struct(ps$, PAINTSTRUCT);
struct(rt$, RECT);
hdc$ = GetDC(hWnd$);
BeginPaint(hWnd$, &ps;$);
GetClientRect(hWnd$, &rt;$);
FillRect(hdc$, &rt;$, GetStockObject(WHITE_BRUSH));
if (a$)
ActiveXDraw(a$);
end;
EndPaint(hWnd$, &ps;$);
ReleaseDC(hWnd$, hdc$);
ok$ = false;*/

WM_CLOSE:
global(a$);
FreeActiveX(a$);
a$ = NULL;

end;

return (ok$);

end;

func ActiveXProc(hWnd$, Msg$, wParam$, lParam$, control$)
ok$ = true;

case (Msg$)

WM_LBUTTONDOWN:
Writeln("WM_LBUTTONDOWN(" + hWnd$ + "," + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_MOUSEMOVE:
Writeln("WM_MOUSEMOVE(" + hWnd$ + "," + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_LBUTTONUP:
Writeln("WM_LBUTTONUP(" + hWnd$ + "," + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");

end;

return (ok$);

end;

func winmain

h$ = newform({OLE}, {OLEClass}, &wndproc;);

InitConsole;
ShowConsole;

global(a$);
a$ = ActiveX(h$, "COMCTL.Slider.1", 10, 10, 400, 40, &ActiveXProc;);
o$ = ActiveXObject(a$);
SetProperty(o$, "Max", 100);
SetProperty(o$, "Value", 50);

b$ = ActiveX(h$, "COMCTL.Slider.1", 10, 100, 150, 120, &ActiveXProc;);

c$ = ActiveX(h$, "COMCTL.ProgCtrl.1", 10, 200, 150, 220, &ActiveXProc;);
o$ = ActiveXObject(c$);
SetProperty(o$, "Max", 100);
SetProperty(o$, "Value", 50);

d$ = ActiveX(h$, "COMCTL.TreeCtrl.1", 200, 100, 400, 300, &ActiveXProc;);

e$ = ActiveX(h$, "ComCtl2.UpDown.1", 10, 300, 24, 324, &ActiveXProc;);

f$ = ActiveX(h$, "QuickTime.QuickTime.4", 500, 200, 700, 400, &ActiveXProc;);
o$ = ActiveXObject(f$);
Invoke(o$, "SetURL", "c:\\download\\ceremony1_lo.mov");

ShowWindow(h$, SW_SHOW);

return (true);
end;


ActiveX's Events are caught by PPL and pass on to a PPL code just like a control's WndProc. There is one more parameter, the control$ which contains the activex PPL handle. Mouse and keyboard activex events are translated to regular WndProc event type, meaning you won't have to deal with activex's complexity. Other events for the control are passed in a special manner, the msg$ variable contains the activex's event id, wparam$ contains an array with the values for the event and lparam$ is the number of values in the array.

I hope you guys will like it!
Looks great!!

Also, I am so happy you finally listened to me and implimented "smiley-face code" into PPL! (line 80) PPL should run a lot faster now!
Hehe! Smiley faces gives a good 35% increase in speed to the compiler.

Glad to see you're back!
Here is the official ActiveX.ppl demo that will be included with the next release. It works on the PC and the PPC.

Code:
// ActiveX controls
#include "windows.ppl"
#include "console.ppl"
#include "ole.ppl"

func WndProc(hWnd$, Msg$, wParam$, lParam$)
ok$ = true;

case (Msg$)
WM_CLOSE:
FreeActiveX(a$);
end;

return (ok$);

end;

func ActiveXProc(hWnd$, Msg$, wParam$, lParam$, control$)
ok$ = true;

write("Event #" + Msg$ + " hWnd:" + hWnd$ + " ActiveX Handle:" + Control$ + " ");

case (Msg$)

WM_MOUSEMOVE:
Writeln("WM_MOUSEMOVE (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_LBUTTONDOWN:
Writeln("WM_LBUTTONDOWN (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_LBUTTONUP:
Writeln("WM_LBUTTONUP (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_RBUTTONDOWN:
Writeln("WM_RBUTTONDOWN (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_RBUTTONUP:
Writeln("WM_RBUTTONUP (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_MBUTTONDOWN:
Writeln("WM_MBUTTONDOWN (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_MBUTTONUP:
Writeln("WM_MBUTTONUP (" + LoWord(lParam$) + "," + HiWord(lParam$) + "," + wParam$ + ")");
WM_KEYDOWN:
Writeln("WM_KEYDOWN (" + wParam$ + "," + lParam$ + ")");
WM_KEYUP:
Writeln("WM_KEYUP (" + wParam$ + "," + lParam$ + ")");
WM_KEYPRESS:
dim(p$, lParam$);
&p$ = wParam$;
Writeln("WM_KEYPRESS (" + chr(p$[0]) + ")");
WM_CLICK:
Writeln("WM_CLICK");
WM_DBLCLICK:
Writeln("WM_DBLCLICK");

default:
if (lParam$ > 0)
Write("(");
dim(p$, lParam$);
&p$ = wParam$;
for (i$, 0, lParam$ - 1)
Write(p$[i$]);
if (i$ < lParam$ - 1)
Write(",");
end;
end;
Write(")");
end;
Writeln("");
end;

return (ok$);

end;

func winmain

h$ = newform({OLE}, {OLEClass}, &wndproc);

InitConsole;
ConsoleUpdate$ = False;
ShowConsole;

COMObjects(objects$, 1);
Writeln("\nActiveX Objects:\n\n" + ListToStr(objects$, #13#10, "", "") + "\n");
COMObjects(objects$, 0);
Writeln("\nCOM Objects:\n\n" + ListToStr(objects$, #13#10, "", "") + "\n");

global(a$);
#ifdef _WIN32_WCE
a$ = ActiveX(h$, "GridCtrl.GridCtrl.1", 10, 10, 200, 200, &ActiveXProc);
#else
a$ = ActiveX(h$, "COMCTL.Slider.1", 10, 10, 200, 40, &ActiveXProc);
#endif
if (a$)
o$ = ActiveXObject(a$);
#ifdef _WIN32_WCE
SetProperty(o$, "Cols", 5);
SetProperty(o$, "Rows", 5);
#else
SetProperty(o$, "Max", 20);
SetProperty(o$, "Value", 10);
#endif

// Get list of properties
ComProperties(o$, l$);
Writeln("\nProperties:\n\n" + ListToStr(l$, #13#10, "", ""));

// Get list of methods
ComMethods(o$, l$);
Writeln("\nMethods:\n");
foreach (l$)
struct(data$, COMINFOSTRUCT);
ComInfo(o$, l$, data$, paramtypes$);
Writeln(l$ + " ID:" + data.DispId$ + " Flag:" + data.Flag$ + " OutType:" + data.OutType$ + " ParamCount:" + data.ParamCount$ + " [" + ListToStr(paramtypes$, ",", "", "") + "]");
free(data$);
end;

// Get list of event methods
e$ = ActiveXEvents(a$);
ComMethods(e$, l$);
Writeln("\nEvents:\n");
foreach (l$)
struct(data$, COMINFOSTRUCT);
ComInfo(e$, l$, data$, paramtypes$);
Writeln(l$ + " ID:" + data.DispId$ + " Flag:" + data.Flag$ + " OutType:" + data.OutType$ + " ParamCount:" + data.ParamCount$ + " [" + ListToStr(paramtypes$, ",", "", "") + "]");
free(data$);
end;
Writeln("\n");
end;

ShowWindow(h$, SW_SHOW);
SetForeGroundWindow(h$);

return (true);
end;


This should give you an idea that COM/ActiveX controls are supported in details.