C++ GUI - General Questions and Answers

Does somebody know where i can find any tutorials on GUI handling in c++ for windows mobile 6.1
My code is complete but i still have to code the interface, but i can't find anything on how to do this.
(made in vs 2008, c++ smart device application with SDK 6 pro)

Hy,
you can try mfc.
Greatz
mccoffein

yeah miniMFC is the other other wiciwigy interface for wm apart from .net
and it's slower then pure win32 where you have to build all guild in code by hand
but it's faster then .net

but why use mfc if its slower, i just need 1 input box 1 output box like a multi line textbox and a start button.
Just need 1 tutorial on how to do it, i messed around with the resources where i made a dialog but i can't do anything in the main window.

MFC is easier, as it provides classes for handling all this stuff, and it also wraps up the windows messages into convenient events to deal with.
If you want to do it the hard way, you will have to master the function CreateWindow() or CreateWindowEx()
Search for it in VS Help and make sure you select the CE version.
Buttons, textboxes, checkboxes, etc., are all child Windows, connected to/owned by, the main window of the application.
Search for 'Control Styles' to find what parameters to pass to to it, in order to create what you want.
Search VS help using 'Creating a Button' for some examples, and study them hard.
You will have to get to grips with all this before you can even start.

Aah well I have done my fair share of assembly guess i am lucky there.
I never knew that every item on a form was considered a window, however it does make sense if your looking around with spy++
I'll just check how fast it runs on MFC, because now it already takes 5 minutes to run in the worst case scenario (this however is inside the emulator).
Thanks for the information guys

Related

Language Advice

First off I’d like to acknowledge the many of you for really opening up my eyes to what these awesome devices can do. It really still does amaze me how some of you folks here at XDA can really create some truly incredible applications and programs. In fact many of you have inspired me to attempt to learn a little bit about programming myself and I have a few questions from the pros in here as to how I should start.
I do have some very basic, mostly self taught skills with SQL, Visual Basic 6.0, tcl (tool command language), UNIX, and a few other types of software but I’m not very skilled at all in any of them. I’m basically a small step above a ‘user’ but I learn fast, this stuff seems to come easily to me, and I have decent instincts on what to NOT try without consultation or research.
Anyway I’d like to become less dangerous (or more depending on how you look at it) and really learn one language on my own at first then maybe take some real classes. I’d like to gear or lean my learning towards a language that I can use to create PPC programs since that’s my main interest these days but I’m getting a little bit of conflicting info\recommendations. I’m being told to start playing with C and that I can then pretty much learn anything after that. I have someone else saying to just skip the C and start with C++ which is a little easier and has more ‘libraries’ so it isn’t as tedious to do certain things. I then have a guy who knows me and my capabilities somewhat well and said I should just jump right into .Net and the rest will fall into place.
So where would you start if you were basically a beginner and wanted to jump right in? I’d like to minimize the ‘curve’ on learning a new language and focus on one that will get me up and running and having fun fairly quickly and not have to learn one to learn another then a third which will get me where I want to be. I really appreciate all of your input in advance guys and gals!!
Dave
.Net is a great platform but you have to remember it is dependant on the .net framework. For this reason some people to use other languages such as c or c++
joel2009 said:
.Net is a great platform but you have to remember it is dependant on the .net framework. For this reason some people to use other languages such as c or c++
Click to expand...
Click to collapse
Thanks joel2009!! Looks like C++ is the way I'm going to go. I appreciate your help!!
Dave
You makes your choice........
If you need to use all the fancy .NET objects then it is C# or VB only. Don't bother with the .NET version of C++, as the type castings you have to use to get it to work makes the code hideously unreadable. Dont forget that the target version of the .NET runtime has to match that of the PPC it going to run on. What version is installed on your PPC ? Run \WINDOWS\CGACUTIL.EXE and it will cough up the results.
If it is a simple application use Embedded C++ and stick to the old WIN32 programming model. It is a bit of a pain to master, but your application will run like a bat out of hell. Respond to the WM_xxxxxxx messages sent by the OS to your app, and use the primitive HDC graphics routines to draw to the screen. It's a bit old hat these days but the compiled .EXE will run on nearly any PPC. (ARM compatable)

Creating a WM Application - Where to start ?

I hope this is the right place to put this, if not, mods, feel free to remove and/or delete it. I've dabbled a bit with C before, but that's about the extent of my programming experience. I'd like to create a program that will parse the information from a website and display it... I don't imagine something like that would be hard to do, but I have no idea what tools I would even need to start writing a PPC application.
Kitco (a website that gives live quotes of precious metals) recently came out with an application for the iphone that neatly formats all this information:
http://www.kitco.com/images/banners/KitcoiPhone/iphone.html
I'd like to basically create a PPC version of this application.
Is this something that an individual with next to no experience could hope to achieve ? I'd have to create a GUI, initialize the internet, connect and retrieve a webpage and remove the relevent information before displaying it.
Any help would be greatly appreciated. I've always wanted to become more familiar with these sorts of things and figured this project would be a great way of learning it.
Thanks!
ThreadMoved
Next to no experience? I dont think so. You have to have a little under your belt first and the only way to achieve that is to start readin right here!
I'm also interested in the expert answers to this question.
My very non-expert understanding is as follows:
VS 2005 (microsoft visual studio) can create executables for WM devices using a SDK (low level) or .Net CF (medium level) interface. You want to use .Net CF (compact framework) because it is supposed to make things easier. I think you have to use C++ to use the SDK but you can use C++, C#, or Visual Basic and write to .NET CF.
VS 2005 is an IDE (integrated development environment). It contains features to edit, compile, and even test your program using simulator/debugger. I think there are some non-microsoft IDE's that can also generate Windows Mobile code -- there is a market for cross-platform environments (e.g. programmers write code using a special library instead of the windows SDK or .NET function and the same source code can be compiled to run on Blackberry, iPhone, S60, Windows Mobile, etc...)
Instead of writing to the phone hardware (or .NET abstraction) directly, you can write your application using Java. You would use some Java compatible IDE (like Eclipse, Jbuilder, or NetBeans) to create Java applets that you download to your phone. You'd have to install a Java VM (virtual machine) on your phone to run these applets. I think the downloadable games for phones are Java applets.
Disclaimer: I haven't worn my "programming cap" since 2001 and hopefully things have gotten simpler. In my previous life I designed operating systems for mainframe computers.

Developing a Portal application in C#

I am wanting to develop a portal application in C# for Windows Mobile 6.0. I have installed the .net Compact Framework 3.5 on my device and have the necessary tools on the PC to develop for Windows Mobile. I am using Visual Studio 2005 to develop this application.
I am not a programmer, I have little experience with .net technologies but have for past assignments used VB.net to create small applications for assignments at uni.
I am now in my third and final year at uni and I decided to take on a project that is titled Human Computer Interaction of Mobile Devices. As part of my project I am required to produce an application, though designing various menu systems in itself will be quite a job, not to mention the documentation of it all.
The application I want to create now, is not necessarily part of my project, though it may influence me later on and should go some way to helping me. I have had the intentions of creating an application in Flash up to now.
Anyway, this application, its what I would call a portal. It has 4 tabs, Websites, Television, Radio and Programs. The Programs tab page has been designed much like the iPhone interface with either same or somewhat similar buttons. These buttons do not do anything at the moment.
I started the other week in designing an application in vb.net and run the debug exe as standalone on PC and linking to application that are on the PC will actually run when clicking on the picturebox as that is what I am using rather than buttons.
I put a Try Catch in and the error message comes up on the Mobile. If I take the Try Catch away then FileExceptionNotFound error message comes up and forces the program to close.
In C#, I have created much the same application, it does nothing whatsoever at the moment other than allowing me to flick from one tab to another. I am wanting to link pictureboxes in the programs tab to programs stored on the phone such as \Windows\Opera9.exe and \Windows\tmail.exe and so on.
I would like Radio Stations and Television channels to load up in a program specified in code if a default one does not start so I realise that I would need to call the link of the radio station (same with television channels) and then tell it to load up in specified program.
The other thing I am not sure about it how I would tell the phone to connect to the internet.
I didn't really want to be asking for help on here with this, as its probably not too difficult to create something like this, seeing as what some people (geniuses) on here have been able to develop. If nobody is able to help, then maybe pointing me in the right direction of some good reliable resources would be an idea. I have done much searching on Google etc for help with this and MSDN but my programming skills have never been up to much if I'm honest.
Any help would be much appreciated.
A few things then
For Visual Studio download and isntall the Windows Mobile SDK's (Version 6, standard and Pro).
Then when you create a new Mobile Device application you have everything you need. There should be a Toolbar in Visual Studio that allows you to select where your device will be run in Debug Mode (either the Emulator or on your device). This is the easiest way to debug your apps; also using MyMoblier will help.
Starting an App in C# is as easy as System.Diagnostics.Process.Start() method.
Connecting to the net is a little harder, I have written my own based on what I found using google. Basically it centers around 3 API calls:
Code:
[DllImport("CellCore.dll")]
static extern int ConnMgrEstablishConnectionSync(ConnMgrConnectionInfo connectionInfo, ref IntPtr connectionHandle, uint dwTimeout, ref ConnMgrStatus dwStatus);
[DllImport("CellCore.dll")]
static extern int ConnMgrMapURL(string url, ref Guid networkGuid, int passZero);
[DllImport("CellCore.dll")]
static extern int ConnMgrReleaseConnection(IntPtr connectionHandle, int cache);
Hope this helps
EDIT:
Also moved to Q&A to avoid upsetting them
Ta
Dave
Thanks for the advice. I have already downloaded Windows Mobile 6 SDK but I for some reason don't seem to be able to access the ROMS from WM6 inside of Visual Studio. I might be able work that issue out though. I will see how I get on with it and post back if I have any further problems.
Connecting to the internet.
I have found that the .net object WebRequest will open the connection if is not already open.
Stream ResponseStream = WebRequest.Create("yourURLgoesinhere").GetResponse().GetResponseStream() will return a stream to read to get the object.
If there is an active WiFi connection the phone will use it, or it will use an active GPRS connection, or fire up the default GPRS connection as a last resort.
The bottom line is - let the machine do all the hard work.

Advice on a new hobbyist phone?

Hello XDA-dev community
For the past couple of months i've been thinking about getting a Pocket PC for a new phone instead of a Symbian Nokia [ah my old 6630, may she rest in pieces...]. Anywho, I think i've decided on the HTC Touch Pro / Raphael. At ~AU$600 it's the highest I was trying not to pay (i'm not rich), however it seems to be a pretty powerful and full featured device.
I do have a few questions I hope some of the kind experts/veterans here might be able to answer for me though
1) I written a few things in Java and PHP and other even-more-basic languages, but am interested in learning a new language with hopes to create software for both Windows PC and Windows Mobile. What choices do we as end-users have here? .NET is an obvious one [I own a copy of Visual Studio 2008 Pro], but are there any other languages of note?
2) From the Raphael specs on the Wiki here, it lists it as an ARMv6 architecture-based processor. This comes from the ARM11 family, which is the successor (I think) to the XScale family (ARMv5TE). Are these ARMv6 processors backwards compatible with 'XScale accelerated' binary builds of software? I.E., a PPC application has two versions for download/purchase - a 'Generic ARM Release' and an 'XScale optimized release' - would the Raphael ARMv6-based device be compatible with these XScale-optimized binaries? Or do ARM do things differently and ARMv6 is not backwards compatible?
3) Has anybody ever heard any rumors or made any talks about porting Android to the Raphael? Just curious. I'd prefer a Windows Mobile device (not a Linux user) but I can see all this OpenSource stuff does have a future... EDIT: Nevermind, I found the page at http://wiki.xda-developers.com/index.php?pagename=RaphaelLinux
4) How does the device perform with 3D-heavy applications? Does it make use of any sort of acceleration (I assume no, not like the iPhone for example).
OK thats all... thanks a lot for your replies, if there's anything else you think is worth mentioning to a soon-to-be-first-time owner of a Windows Mobile device, please do say so Cheers.
In reply to 2) VS 2005 Pro onwards targets code at ARMv4I, basically generic ARM processors also capable of running the Thumb (16 bit) instruction set. Thumb represents a limited set of ARM 32 bit instructions coded as 16 bit instructions. It allows much smaller code sections, but with megabytes of memory available these days who cares? If you code in .NET none of this matters anyway, as the code is created as IL byte code, the .NET runtime sorts it out.
If you code in Embedded Visual C++ 3 or 4 the target chipset is ARMv4. When you use the IDE to create the code on a WinMo 5/6 machine it complains that the target machine cannot run the code. It's lying, what it really means is it does not recognize the processor class. As it is ARM 32bit code only it will work.
It is not worth targetting the code for a specific, (read non generic), ARM chipset. You are just making a rod for your own back when it won't work on something else.
Thanks for the reply stephj. There will indeed be a bit of research for me to do as to which language and/or IDE I decide to choose to train myself in then it seems. Specifically though...
stephj said:
It is not worth targetting the code for a specific, (read non generic), ARM chipset. You are just making a rod for your own back when it won't work on something else.
Click to expand...
Click to collapse
...what I was referring to is - I've seen some freeware PPC software, mainly emulators, that have two versions - a 'generic ARM' one and an 'XScale Compatible' alternative version. On the ARMv6 based phones, assuming the software was released back when XScale was the newest ARM family, would both work on the Raphael? If so, which would be faster?
Obviously though, for a developer, creating the most compatible/generic code to work on the widest range of devices is the main focus - later possibly implementing optimiziations or hacks that are specific to a certain platform - but I'm just wondering if these already built, older 'specifically optimized' builds are compatible with the succeeded chipsets.
P.S. Do you know where I could find some resources on choosing between Visual C++ or .NET? I.e. pros and cons of each?
Thanks a lot!
jonusc said:
Hello XDA-dev community
...
1) I written a few things in Java and PHP and other even-more-basic languages, but am interested in learning a new language with hopes to create software for both Windows PC and Windows Mobile. What choices do we as end-users have here? .NET is an obvious one [I own a copy of Visual Studio 2008 Pro], but are there any other languages of note?
...
Click to expand...
Click to collapse
Since you have VS2008Pro, C++/win32 if you want fast and lightweight applications
"P.S. Do you know where I could find some resources on choosing between Visual C++ or .NET? I.e. pros and cons of each?"
.net pros
easy to get something running fast even if one is a n00b
got a lot of components meaning less time to develop
can be programmed with c# and c++ and even eeeeewww basic
.net con
slow as in sloooooowww
require one to install the framework if the app
require a newer version then what ones phone came with and the framework is pretty big
and people don't seem to have success with installing it on sd cards
compact framework is also limited in features vs. .net on pc so apps don't just port always
limited in features unless one do unmanaged code
c++ pro
fast
require no extre stuff
small in size and again fast
have access to every feature in the phone
c++ con
one have to do everything and that mean msg loop
and a lot of leg work just to get a dialog with a button
steaper learning curve
more risks of mem leaking
harder to debug as stacktrace is not just there
like on .net
Very nice, thanks for the replies guys
So from what I can gather, a basic .NET application would be ideal for RAD (quick and dirty), particularly GUI-centric applications, but tend to be bulky; whereas C(++) is a more native / low-level language and is thus faster, but very hardcore as most functions need to be done from scratch.
I should have assumed it's pretty much the same as a Windows PC
What about C++ versus C#? And does VS2008 have a decent API/IDE set for mobile development i.e. does it have many libraries for C(++/#) already included or are more easily available?
Thanks again for the answers guys... it's obvious i'm keen to learn about it, but i'm a little worried that someone like me going from stuff like PHP and VB to C might be biting off more than I could chew....? Ah well if .NET is gonna cause problems down the line, then I guess I have no choice
Don't bother with the C++ version of .NET, the casts that you have to make, to get it to work makes the code very hard to read, and besides it only compiles to the IL level anyway, it's just not worth the effort.
So, under .NET use C#, or VB if you prefer, there is not much difference between them, but in my opinion, C# is a bit more elegant.
Under C++ you have the choices of WIN32, ATL (Active Template Library), or MFC (Microsoft Foundation Classes), programming models.
WIN32 is the simplist but the hardest to code, the other two add progressively more objects to make things easier, but you need to distribute the run time libraries with them. A simple WIN32 app can be distributed as a single .EXE if the DLLs it already uses are part of the CE/PPC operating system.
PS When it comes to running code compiled for a specific ARM class on your device, just give it a go. If the CPU hits an instruction it can't run, it will throw an exception and stop anyway.
stephj said:
Don't bother with the C++ version of .NET, the casts that you have to make, to get it to work makes the code very hard to read, and besides it only compiles to the IL level anyway, it's just not worth the effort.
Click to expand...
Click to collapse
Fair enough. So C++ in VS2008 is a bad idea
stephj said:
So, under .NET use C#, or VB if you prefer, there is not much difference between them, but in my opinion, C# is a bit more elegant.
Click to expand...
Click to collapse
I thought VB was dead? Wasn't VB6 the last one they made? Or is VB just what they call generic/common .NET Framework apps? Anyway, yeah i've read good things about C#, especially compared to .NET in general. EDIT: Oh, .NET is not the program language but VB is *facepalm* I get it, nevermind
stephj said:
Under C++ you have the choices of WIN32, ATL (Active Template Library), or MFC (Microsoft Foundation Classes), programming models.
WIN32 is the simplist but the hardest to code, the other two add progressively more objects to make things easier, but you need to distribute the run time libraries with them. A simple WIN32 app can be distributed as a single .EXE if the DLLs it already uses are part of the CE/PPC operating system.
Click to expand...
Click to collapse
Ah, same as a Windows PC. That makes sense.
Thanks for the answers I think I might take a look at C sharp.
C++ in VS2008 is fine, use the smart device WIN32 ,ATL, or MFC models take your pick.
Sorry my mistake, the C++ .NET version is not available for smart devices. Its the three models above only.
After additional research, I don't really want to be tied down with the proprietary C# system. So is VS2008 a decent IDE for WIN32 C++ development on Windows Mobile? Or are there better alternatives?
VS 2005/2008 Pro takes some beating. After you have installed about 3 CD's worth of MSDN libraries all the help is on tap. The IDE also looks at MSDN online if you have an internet connection to see if there are any forums on the same topic you are inquiring about.
The code is generated as ARMv4I and can be tested/debugged on the images provided by the WinMo 5 or 6 SDK. The emulators are that good you only put it on your phone when you have tested it to death on the emulator.
EVC 3 and 4 use a previous method where the emulators run a x86 version of the code. I still use EVC 4 for code that has to run on anything, Windows Mobile 2003 for example.
It's all pretty proprietory, when it comes down to it, but I guess we're stuck with it.

WM Programming-Pascal and C console programs

Hi everyone!
I'm studying Turbo Pascal and C programming languages at school,I write console programs from "add 2 numbers and print the result" to something more complex.
I was wondering...is there any way to get these simple console programs to work on my HTC Touch PRO 2 (WM 6.1)?
Hope you can help me...
Thanks!
I 2nd this, I'd like to know too.
Or otherwise I'm also interested in writing a basic app for WM just to try it.
Jason
easy to do with c using embedded visual c++ which you can google and it's free and c++ is always backward compatible with ansi c
doubt you will have much luck with pascal because the best bet would have been borlans options and they quit the whole market with their delphi pascal options
nailing the last nail in the coffin of pascal
For Pascal, use FreePascal/Lazarus combo. It's a ***** to set up, though.
Rudegar said:
easy to do with c using embedded visual c++ which you can google and it's free and c++ is always backward compatible with ansi c
doubt you will have much luck with pascal because the best bet would have been borlans options and they quit the whole market with their delphi pascal options
nailing the last nail in the coffin of pascal
Click to expand...
Click to collapse
Can I write console applications with it,or they have to have a GUI?
Chainfire said:
For Pascal, use FreePascal/Lazarus combo. It's a ***** to set up, though.
Click to expand...
Click to collapse
Yeah,i tried that,but i can't make it work...I followed the guide but i can't do anything that works on WM
"Can I write console applications with it,or they have to have a GUI?"
both a lot easier to make console apps though
Thank you,I'll give it a try
The problem you will encounter with console applications is the fact that there is no console as such.
printf() will not work as there is no output window on which to write anything. There is also no way of reading user input direct from the 'keyboard' or keypad.
When the exe is run it starts as a windowless application, the WinMain() function is called and when this ends it is terminated. You can open and close files, read and write to and from them, anything you like, as long as it requires no user input, and does not display anything. Pretty restrictive! The only thing the user will see is the hourglass/busy icon, until the app finishes.
Even C# console applications are subject to the same restrictions.
To do anything 'smart' it will have to be a PPC (GUI) application.
there are plenty of free console apps one can download for free
stephj said:
The problem you will encounter with console applications is the fact that there is no console as such.
printf() will not work as there is no output window on which to write anything. There is also no way of reading user input direct from the 'keyboard' or keypad.
When the exe is run it starts as a windowless application, the WinMain() function is called and when this ends it is terminated. You can open and close files, read and write to and from them, anything you like, as long as it requires no user input, and does not display anything. Pretty restrictive! The only thing the user will see is the hourglass/busy icon, until the app finishes.
Even C# console applications are subject to the same restrictions.
To do anything 'smart' it will have to be a PPC (GUI) application.
Click to expand...
Click to collapse
What if I use Pocket Console,or something like that? Would they run correctly?
Can't really say, as I haven't used them. The console stuff I have written, drags objects from over the net, then writes the data out in a format I can use to a file on the device. No user input required.
All I can suggest is to try the classic
printf("Hello World!\n")
and see what happens. Good Luck!
C programing
Hello,
yes, you can. Just use pocketdos. An emulator for DOS and you can use your simple compilers
Search for Pocketdos.com
xdawis said:
Hello,
yes, you can. Just use pocketdos. An emulator for DOS and you can use your simple compilers
Search for Pocketdos.com
Click to expand...
Click to collapse
Thank you! They work now! PocketDos is great!

Categories

Resources