473,769 Members | 1,803 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2851
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*****@discus sions.microsoft .com> wrote in message
news:26******** *************** ***********@mic rosoft.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.Control Collection parent, ArrayList
container)
{
foreach(Control c in parent)
{
if(c.HasChildre n)
{
GetAllControls( c.Controls,cont ainer);
}
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*****@discus sions.microsoft .com> wrote in message
news:26******** *************** ***********@mic rosoft.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 "HasChildre n" 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*****@discus sions.microsoft .com> wrote in message
news:C3******** *************** ***********@mic rosoft.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.Control Collection parent, ArrayList
container)
{
foreach(Control c in parent)
{
if(c.HasChildre n)
{
GetAllControls( c.Controls,cont ainer);
}
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*****@discus sions.microsoft .com> wrote in message
news:26******** *************** ***********@mic rosoft.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
600
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 that it could not create a windows handle. On one machine the stacktrace is this:
3
2554
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. Shell("c:\windows\calculator.exe", vbNormalNoFocus) In other words are there Win2000/XP api's that would allow you to control the functionality of the calculator. I'm just using the calculator application as an example I am actually trying to control a main frame app...
1
1872
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 I believe are on the same thread. The window being destroyed is a modeless window that is a grandchild of the parent window passed into the messagebox. Here is the middle of the call stack. Somehow it is getting the ParkingWindow (whatever the...
22
2357
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 the user autoscrolls the usercontrol (other things that are on the usercontrol I want to scroll, but haven't included any here). Here are the steps to reproduce my problem. 1. Launch Visual Studio and create a new Windows application with...
1
2314
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: Public Class Form1 Inherits System.Windows.Forms.Form
11
2780
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. Once that is opened one (or more) properties forms can be opened. What is the best method for sharing data between the properties forms and the main child form? I need to alert the main child form when a value is modified in a properties form so I...
5
1521
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 settings are the same between the apps they should work happily together. The only difference I have between the apps Web.Config settings is their <forms> loginUrl, which isn't supposed to make a difference. App1 Web.Config: <authentication...
2
1345
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 the C# code-behind. When I tested the library, this worked fine in Visual Studio 05. What I was wondering was, are there performance concerns or security concerns in using the Windows.Forms library in an ASP.NET website? Will using it impact...
4
3760
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 which shows the msg successfully but nothing shows up when using IMessageFilter. Am i misunderstanding something? Here is sample code: public class MyFilter : IMessageFilter { const int WM_POWERBROADCAST = 0x0218; public bool...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.