473,244 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,244 software developers and data experts.

Sharing Code between Window Forms and Windows Mobile

I'm embarking on a project that will have both a desktop application and a
Pocket PC application. It seems logical to have as much code as possible
sitting in a shared project, which would be referenced and utilized by both
the Windows Forms application and the Mobile Device application.

Are there any "gotchas" (ie. warnings) that anyone knows about in following
this approach?

Robert W.
Vancouver, BC

Nov 17 '05 #1
3 2825
My suggestion would be to only share code that is non-UI related and if you
really want to share assemblies make sure that the code conforms to the
lowest common denominator by compiling against the Compact Framework.

--
Tim Wilson
..Net Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
I'm embarking on a project that will have both a desktop application and a
Pocket PC application. It seems logical to have as much code as possible
sitting in a shared project, which would be referenced and utilized by both the Windows Forms application and the Mobile Device application.

Are there any "gotchas" (ie. warnings) that anyone knows about in following this approach?

Robert W.
Vancouver, BC

Nov 17 '05 #2
Hi Tim,

Thanks for this. Have you personally run into problems sharing code as I
described?

I also immediately thought about avoiding sharing code that involves
controls. But today I noticed that both a Windows.Forms form and a Mobile
Device form each have the identical 'using' statement at the top:

using System.Windows.Forms;

It'll be interesting to see if a DataLibrary with the above 'using'
statement would support code as follows for both platforms:

private void GetAllControls(Control.ControlCollection parent, ArrayList
container)
{
foreach(Control c in parent)
{
if(c.HasChildren)
{
GetAllControls(c.Controls,container);
}
container.Add(c);
}
}
I definitely need to do some tests, but added my post on here to tap into
the experiences of others who have tried this.

Robert


"Tim Wilson" wrote:
My suggestion would be to only share code that is non-UI related and if you
really want to share assemblies make sure that the code conforms to the
lowest common denominator by compiling against the Compact Framework.

--
Tim Wilson
..Net Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
I'm embarking on a project that will have both a desktop application and a
Pocket PC application. It seems logical to have as much code as possible
sitting in a shared project, which would be referenced and utilized by

both
the Windows Forms application and the Mobile Device application.

Are there any "gotchas" (ie. warnings) that anyone knows about in

following
this approach?

Robert W.
Vancouver, BC


Nov 17 '05 #3
> Have you personally run into problems sharing code
as I described? No. But then again I haven't really had a whole lot of need to do this.

The CF (Compact Framework) team modeled the namespaces, classes, etc. to
mimic the FF (Full Framework). So you'll notice lots of similarities between
the FF and CF. This was absolutely by design. This allows devs to leverage
their knowledge between the two frameworks. But keep in mind that the CF
emphasizes the word "compact". So the CF is a subset of the FF. If you look
at the documentation you'll notice the statement "supported by the .NET
Compact Framework" on certain members (now I must warn you that the docs are
not 100% accurate, particularly with the event members). This gives you an
idea of what you can and cannot use between CF and FF. So in your code
example, the "HasChildren" property would not compile against the CF since
it's not supported. But you could always just check the Count of the
Controls collection. So there are usually work arounds. You'll just need to
find the combination that works for both the CF and FF and then compile that
in a project against the CF.

The reason that I implied that it's best not to share UI related code is
mostly for two reasons:
(1) The form factor of a device (like a Pocket PC or Smartphone) is
drastically different from a typical desktop computer display. So the UI is
pretty much a rewrite anyways.
(2) Through the designer, the generated resx files for Forms are not
compatible between FF and CF projects.

So there's nothing wrong with having utility methods to perform tasks on
controls, but you'll want to ensure that you have different projects, one
for the FF and one for the CF, so that you can more easily define proper
UI's.

--
Tim Wilson
..Net Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.com... Hi Tim,

Thanks for this. Have you personally run into problems sharing code as I
described?

I also immediately thought about avoiding sharing code that involves
controls. But today I noticed that both a Windows.Forms form and a Mobile
Device form each have the identical 'using' statement at the top:

using System.Windows.Forms;

It'll be interesting to see if a DataLibrary with the above 'using'
statement would support code as follows for both platforms:

private void GetAllControls(Control.ControlCollection parent, ArrayList
container)
{
foreach(Control c in parent)
{
if(c.HasChildren)
{
GetAllControls(c.Controls,container);
}
container.Add(c);
}
}
I definitely need to do some tests, but added my post on here to tap into
the experiences of others who have tried this.

Robert


"Tim Wilson" wrote:
My suggestion would be to only share code that is non-UI related and if you really want to share assemblies make sure that the code conforms to the
lowest common denominator by compiling against the Compact Framework.

--
Tim Wilson
..Net Compact Framework MVP

"Robert W." <Ro*****@discussions.microsoft.com> wrote in message
news:26**********************************@microsof t.com...
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be referenced and utilized by

both
the Windows Forms application and the Mobile Device application.

Are there any "gotchas" (ie. warnings) that anyone knows about in

following
this approach?

Robert W.
Vancouver, BC


Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Matt Warner | last post by:
Hi guys, A couple of people have already posted questions about similar issues but haven't had any response. Occasionally, sometimes after running the app for a few hours, it bombs out saying...
3
by: Pete | last post by:
Is there any possiblity of writing an Access or Visual Basic application that provides a method of sharing the window focus between Access and the Shell application? i.e....
1
by: Dave Harris | last post by:
We have a bit of a situation where Windows.Forms.MessageBox is somehow causing a specific window created in native C++ to get an NC_DESTROY message. The windows share a common great-grandparent and...
22
by: Colin McGuire | last post by:
I apologize for posting yet another scrollbar question. Here is my code. All I want is for a diagonal line to appear from coordinates (0,0) to (width,height) in a usercontrol regardless of whether...
1
by: Angus Lepper | last post by:
I'm writing a stock ticker for a stock market simulation, and can load the data into the xmlreader in the first place, but can't figure out how to refresh/update the data in it. Any ideas? Code:...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
5
by: Sebastian | last post by:
Hello, I am attempting to share forms authentication between two applications but running into problems. The documentation I've been able to dig up says (to summarize) if the the Web.Config...
2
by: justin | last post by:
Hello, recently I was working on a project where I needed to automate PDF generation. I found two open source libraries that I liked, but the best one required the Windows.Forms class to be used in...
4
by: =?Utf-8?B?am9obmY=?= | last post by:
Trying to get a see windows messages using IMessageFilter interface however it does not seem to get all window messages. Specifically I am looking for the WM_POWERBROADCAST. I override wndproc...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.