View Full Version : How to create an interactive form
Kobus
02-22-2009, 01:55 PM
Hello,
What is the code to create a simple interactive form?
I found this sample on internet and think that it could be a nice PPL example for absolute beginners, like myself.
I know VB, PHP and mysql, but didn't find any example to get me on the right track :confused:
Guess a number between 1 and 100.
The number is random.
The input has to be a valid number, not a letter, sign or above 100
Message if the systems number is higher
Message if it's lower
Message it it's the correct number and if you want to play again.
If not, close the application.
Thank you in advance!
Helen
Nicknack
02-22-2009, 03:18 PM
here is a quick help to get started:
1. create a new button and text edit in the visual form builder.
2. give background a new oncreate event and insert following in the event code:
global(number$);
number$=random(101);
2. add onclick event to the button and add in this event code:
temp$=gettext(edit$);
if(number$<temp$)
showmessage("Number too high");
else if(number$>temp$)
showmessage("Number too low");
else
showmessage("You win");
number$=random(101);
end;
Kobus
02-22-2009, 04:10 PM
Hello Nicknack,
Thank you :D. This is a nice beginning for me and I can write a tut for other noobs.
If that's completed I have a next little project. Getting the date and time from the built in GPS and set it in the CE environment.
I haven't seen any info about gps here yet, so I will be back for asking help.
Thanks again!
Helen.
Mike Halliday
02-23-2009, 07:58 AM
Hi Kobus
Not sure if this is any help to you?
Found it on the web a while ago, but have not had a chance to check it out.
Cheers
Mike
Kobus
02-23-2009, 10:00 AM
Hi Mike,
Thanks. I already found that one, together with loads of other GPS appl. The funny thing was that my search for a working GPS appl. brought me here.
I think :confused: that the problem is that most applications are written for WM and not for CE devices and that the menu causes the error.
For WM the menu is below and for CE it has to be up, which is very simple with PIDE.
Some other questions:
-How come that the .exe file sizes are sooooo large?
-What am I doing wrong (or is it just stupidity :p) that I can't find the answers in the manual.
E.g. focus.; I want that the input field gets the focus every time the command button is pushed to check the number.
-How to close an application from a showmessage, a yes/no.
Thanks as always
Helen
Nicknack
02-23-2009, 11:23 AM
hi Helen,
sadly the actual manual isn't up-to-date, the reason for this is logic, ppl 2.0 comes with a completly new manual in near future.
so I have searched here in forum for focus and behold (http://forums.arianesoft.ca/showthread.php?t=1315&highlight=focus). simply like settext: sefocus(edit$);
exit() is also easy, you can find it with it's cronies in help file ;)
about two other points I don't know currently: how to create a yes/no message and how to select text in a edit automatically.
maybe Mike has any idea?
Nicknack
02-23-2009, 11:30 AM
found this code in the source code of the pide: :D
i$ = MessageBox(NULL, "Do you want to restart?", "Question", MB_YESNOCANCEL);
if (i$ == 6) // YES
showmessage("yes");
else if (i$ == 7) // NO
showmessage("no");
else if (i$ == 2) // CANCEL
showmessage("cancel");
end;
Mike Halliday
02-23-2009, 11:47 AM
I have searched the code for the Field data selection and found this;
x$ = FindString(SearchStr$, s$, FindPosition$, MatchCaseFlag$, WholeWordFlag$);
SetFocus(MainEditCtl$);
if (x$ <> -1)
SendMessage(MainEditCtl$, EM_SETSEL, x$, x$ + length(SearchStr$));
end;
Looks like you have to set EM_SETSEL with start char and length?
Dont know if this is easy for you to implement?
Mike.
Mike Halliday
02-23-2009, 11:48 AM
File size;
The binary file size is large because you have not selected 'use compressed exe' option when you compile your code;
This will reduce the size of the exe significantly!
Mike.
Nicknack
02-23-2009, 11:57 AM
this way it also works:
SetFocus(edit$);
SendMessage(edit$, EM_SETSEL, 0,length(gettext(edit$)));
Kobus
02-23-2009, 12:22 PM
Hi,
It's great to get help from your neighbours :D
Thank you both for your info on these questions. I will start with it and, be sure, come back with new questions.
Helen.
Kobus
02-23-2009, 06:15 PM
Hello,
Thanks to the two of you I now have the following code:
func cmdCheck_OnClick(hWnd$, Msg$, wParam$, lParam$)
HandleEventParms
temp$=gettext(inpNumber$);
if(number$<temp$)
showmessage("My number is lower");
else if(number$>temp$)
showmessage("My number is higher");
else
i$ = MessageBox(NULL, "Yes, this was my number. Do you want to restart?", "Congratulations", MB_YESNO);
if (i$ == 6) // YES
number$=random(101);
else if (i$ == 7) // NO
exit;
end;
end;
SetFocus(inpNumber$);
Edit_SelectAll(inpNumber$); // This selects the previous input
return (true);
end;
Just to make things clear, the red colored line I found all by myself :eek:
First I was using the manual from the site -- > support and couldn't find anything. The help manual in PIDE is making things clearer, bit by bit.
Now I am going to try to make the form fit the screen(s).
From what I red version 2.0 is something to look forward to.
I really appreciate your help.
Helen.
Kobus
02-24-2009, 07:07 PM
Hello,
It might be a good time for my next questions.
How to validate the input --> I found "ValidInt", but can't find the right code :o
The full screen --> I found #declare SHFullScreen "aygshell.dll" SHFullScreen 2 1
in windows.ppl and have no idea were to place a #declare and which code to use.
My device has a 480x272 screen and I hope it's possible that it will fit in more screen sizes, preferably portrait mode.
I really searched the forum ..............
Thanks very much in advance.
Helen.
Nicknack
02-24-2009, 08:00 PM
and here comes an answer:
1. you could use: if(vartype(foobar$)==0)
2. take a look here here (msdn.microsoft.com/en-us/library/aa453694.aspx) ;)
msdn is a good resource if you search for methods from m$. sometimes it's a bit confusing, especially if you are a beginner, but you'll get used to it (if not ask).
3. you can place #declares and #defines anywhere in your code. since windows.ppl is already included in your code you don't need to declare shfullscreen again.
..and thx for selectall :D
Kobus
02-24-2009, 08:57 PM
Hello Nicknack,
What would I do without you :) (and Mike of course).
Ohhhh, msdn is a piece of the puzzle as well, starting to understand more and more
I have been looking at C#, but got devestated of m$, the dead links and all the extra downloads for vs, etc. etc.
Viele dank - thank you!
Helen.
Kobus
02-27-2009, 06:39 PM
Hello,
I feel soooooo stupid (after searching for two days) about: clear the input in the Edit box.
If you want to start another guess game, the last input should be cleared, so you start again with an empty Edit box. Refresh, reload form??
Found "fresh" in an old post, can't find it in the Help.
Thanks in advance, as always.
Helen.
Nicknack
02-27-2009, 07:03 PM
why so complicated? a simple SETTEXT(edit$,"") should be enough :D
Kobus
02-27-2009, 07:19 PM
Nicknack,
Used your code and my head went up with a big Ohhhhhh.
A big virtual THANK YOU!
Helen.
Kobus
03-01-2009, 11:50 AM
Hello,
Finally finished my Guess form. The last issue is the screen size and orientation.
I changed the form size to 800 x 800 and on my device (480x272) it fills the screen perfectly in landscape mode. When I change into portrait it's ok as well.
Is that the correct way?? I don't have another device (yet) to test it on.
Will it be useful if I make a tut of this?
Bye, bye,
Helen.
Leginus
03-01-2009, 02:23 PM
Hi Helen.
Thats a nice start. Although I didin't manage to guess the number :o
Well Done. Sharing source code or tutorials is always a good thing, so yes, definitley share the source if you wish to :)
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.