Few questions

Discussion about the open-source Phalanger [?] project.

Few questions

Postby r0swell@codeplex » September 3rd, 2006, 11:04 am

Hello,

I'm new to .Net
Before i was using php with Winbinder to create winapps

-Is phalanger speed the same if the app would hath been written in c# or VB?

- How to add items to an contextMenuStrip? I checked with creating a form in a C# App

wich shows
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.testToolStripMenuItem});

But how to do the same in phalanger as the ToolStripItem[] { } doesnt seem valid in php

- I created a form wich works but the notifyIcon doesnt show

import namespace System;
import namespace System:::Windows:::Forms;
import namespace System:::Drawing;
import namespace EQvoice;

namespace EQvoice
{
class mainForm extends Form
{
public function __construct()
{
$this->InitializeComponent();
}

private function InitializeComponent()
{
$this->notifyIcon = new NotifyIcon;
$this->SuspendLayout();

// notifyIcon
$this->notifyIcon->Icon = "EQvoice.ico";
$this->notifyIcon->Text = "notifyIcon";
$this->notifyIcon->Visible = true;


// Form

$this->ClientSize = new Size(292, 266);
$this->Name = "Form1";
$this->Text = "Form1";
$this->ResumeLayout(false);

}
}
}

Basicly i'm trying to make the mainWindow to have a systemTray icon and with a popupmenu. And the window itself to be invisible


Thnx


r0swell@codeplex
 
Posts: 1
Joined: January 7th, 2012, 8:58 pm

RE: Few questions

Postby Lada Prosek » September 3rd, 2006, 4:02 pm

Hello,

> Is phalanger speed the same if the app would hath been written in c# or VB?

No. It is substantially slower. Some preliminary performance measurements have shown that the Personal Web Site starter kit app is 3 times slower when PHP (via Phalanger) is used as the code-behind language compared to the C# case. Basically this is the price you have to pay for dynamism of the PHP language. Consider this:

function foo($x)
{
return $x->GetBar();
}

At compile time we do not have any information about the $x. It can be anything that has a method called "GetBar" on it. No common base type or interface is given. In C#, on the other hand, the parameter must always have a type which enables the compiler to generate much more efficient code.

Having said that, you may wonder why the Personal Web Site exhibits such a poor performance when it does not contain these dynamic constructs (we have just recoded the strongly typed C# version to PHP). Well, that's because our compiler is not perfect. Personally I think that we can get very close to the performance of C# or VB.NET by employing sophisticated optimizations - static analysis etc.


> How to add items to an contextMenuStrip?

C#:
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.testToolStripMenuItem});

Can be equivalently expressed in PHP like this:

$this->contextMenuStrip1->Items->AddRange(array($this->testToolStripMenuItem));

array() is a standard PHP construct that creates a universal associative array. It is automatically cast to the correct type when passed to AddRange (a nice example of dynamism, by the way; notice that we save you from "typing the obvious").

id in php


> I created a form wich works but the notifyIcon doesnt show

You need to do:

$this->notifyIcon->Icon = new Icon("EQvoice.ico");

instead of just

$this->notifyIcon->Icon = "EQvoice.ico";

We do not go that far as to realize that the Icon property is of Icon type and there is constructor in Icon that takes a string. This can actually be considered as our bug that we do not report any warning. I'm adding a work item, thanks.


> Basicly i'm trying to make the mainWindow to have a system Tray icon and with a popupmenu. And the window itself to be invisible

Just a remark: you do not need an invisible form for this. In Win32 you need a window that owns the tray icon, but there is no such requirement in WinForms. See this thread for a minimalistic tray icon app:
http://www.codeplex.com/Project/DisplayThread.aspx?ProjectName=Phalanger&ForumId=267&ThreadId=721
Lada Prosek
 
Posts: 47
Joined: January 7th, 2012, 8:52 pm


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 21 guests

cron

User Control Panel

Login

Who is online

In total there are 21 users online :: 0 registered, 0 hidden and 21 guests (based on users active over the past 5 minutes)
Most users ever online was 297 on March 29th, 2024, 7:06 am

Users browsing this forum: No registered users and 21 guests