[Q] Problems with manual text edit and calendar with conditional values - Zooper Widget General

I'd like to display my calendar events in the following format:
Date Day BeginningTime - EndTime | Event title, Event location
with conditional formating that if the event is an all-day event the BeginningTime and EndTime shouldn't be displayed.
So far the code i use is:
Code:
#C0SEEE# $#C0D#<1?#C0SHH:MM#-#C0ehh:MM# $| #C0TITLE# #C0LOC#
The problem is that if i use colon in the code the result is displayed as "#C0SHH" and "C0EHH" instead of actual beginning and ending time. Also, since i want to display multiple events i copy the code to the next line and make a paragraph (enter) between the two code lines. In the "Edit text manually" preview the code is displayed as it should be (each event in its own line), while on the widget itself all events are in the same line. So here are my questions:
1. How to display column between hour and minute values when using conditional formatting?
2. How to display each event in its own line?
3. What's the code to display event date (number value, ie. 26th)?

1. You can escape the colon character with \ for use inside conditionals. Thus, this would work: $#C0D#<1?#C0SHH\:mm#-#C0EHH\:mm# $
2. Use the "Rich Text" module instead of the "Text" module. Rich Text provides support for multiline elements. It also provides support for other things, which is necessary for...
3. [no]#...d#[/no]. So for event 0: [no]#C0Sd#[/no]
4. Watch your capitalization. In free dates, MM is not the same as mm, likewise for HH and hh, and so on.

Related

Launch app when new SMS arrives

hi,
i am trying to put together my own sms triggered workflow. for that reason i am looking desperately for an sms-trigger which does not appear in the tray bar.
i have been intensively searching for this for ages and tried all of the apps i was able to find (smstrigger, rk-sms, mortring) but they either do not work or hook into the tray bar.
i hope that somebody can help me out.
What exactly do You want to happen when sms arrive ?
I can make a simple soft not visible in traybar,
BUT it IS visible in Taskbar.
It can f.ex fetch msg-body+Timestamp+Phonenumber from sender.
And perform Shell commands if needed.
hi eurocrypt!
first of all thanks for your help - i really appreciate that.
the minimum what i need is purely to start an exe file as i could do the rest with other utilities.
but what would really help is the following:
set the following flag to the registry
HKCU\System\State\Messages\vmail\Unread\Count = 1
if the sender's number is "#####" or the sender's name is "xxxxx" (if the number is stored as "xxxxx" in contacts)
that's it.
furthermore it would be great to delete exactly this sms with a different parameter perhaps.
My Idea is as follows:
I will make it possible to start the soft with Arguments
\SMSLaunch.exe aaa bbb ccc ddd eee fff ggg
Where
------------------------------------------------------
aaa= The Phone-number/name to trigger SMSLaunch
(Will be filter function, Name or Number Uppercase and removed Spaces and '-')
Like:
Mike Willson As contact Will be triggered if MIKE is Arg.
MIKE as arg will trigger Any Mike calling.
012-123 00 00 As Incoming Nr will be triggered if 01212 is arg.
073 as arg will trigger ANY number beginning with 073.
------------------------------------------------------
bbb= Shellcommand to run (Start app)
------------------------------------------------------
ccc= Arg for above shellcommand
------------------------------------------------------
ddd= Registry-Editing-Entry
------------------------------------------------------
eee= value to set for Registry.
( 1 is static, +1 increase by one, -1 decrease by one)
------------------------------------------------------
fff= Number to reply SMS to
------------------------------------------------------
Number of Arg's will be exact, and must be set by f.ex "X" to indicate
no Action for this Arg.
If needed I can make EDit function fromSoft if Started without Arg,
Textboxes to set ARgs and then Possibility to create A Shortcut with buildin Args.
I´m a bit buzy, so it may take some time to complete this,
hope You have time to wait.
WOW. GREAT!
sure i have time. i have been searching for weeks. so take all the time you need.
i am happy with command line based tool.
instead of textboxes (which might be cool for v2) something like
SMSLaunch.exe aaa /d
to delete the sms would be great.
background for what i use this tool:
i am using homescreen ++ as the only today-plugin. many of the provider in germany do not send a vmail-notice anymore. instead you receive an sms (this can not be changed in your mailbox account settings).
your tool will work as an sms-splitter to seperate vmail-sms from the rest. the process will be to set a registry value to "1" and delete the vmail-sms. homescreen++ will display an icon instead.
i am sure that some more users will be interested in this, too.
A Q!
Is this Reg entry correct ?
HKCU\System\State\Messages\vmail\Unread\Count = 1
I have like this
HKCU\System\State\Messages\vmail\xxxxxx\Unread\Count = 1
where xxxxxx has 4 different entries
Line1
Line2
Total
VoIP
Same in both Omnia and HTC Cruise
I use "Line1" when testing my tool now,
and looks like working OK.
But what about Value, Count=1
Is it automatically go down to Count=0
when listening to Your V-Mails ?
Eurocrypt said:
Is this Reg entry correct ?
HKCU\System\State\Messages\vmail\Unread\Count = 1
I have like this
HKCU\System\State\Messages\vmail\xxxxxx\Unread\Count = 1
where xxxxxx has 4 different entries
Line1
Line2
Total
VoIP
Same in both Omnia and HTC Cruise
I use "Line1" when testing my tool now,
and looks like working OK.
Click to expand...
Click to collapse
reg key same to me.
basically it does not matter which regkey.
you could also use hkcu\software\eurocrypt\vmail
if you want to
Eurocrypt said:
But what about Value, Count=1
Is it automatically go down to Count=0
when listening to Your V-Mails ?
Click to expand...
Click to collapse
superb!
yeah. count =1 if vmail arrives.
can you really do that - vmail to go down to 0 if calling mailbox?
how does the prog know that i am calling my mailbox?
maybe we need to put the number into a special regkey?
if it takes too much time, it is ok to leave vmail=1
i could also reset the value with mortscript.
Progress so far:
I have added possibility to use a SMSLauncher.ini in
same folder as EXE where settings can be specified.
(Easier to config for common guys)
But still possible to use Commandline.
IF SMSLauncher.ini exist, Commandline-Args will be skipped.
It is all working right now exactly as I want it
Though it is not compiled Yet, at work
and coding this toy in my HTC Cruise
Will make a working exe tonight to let You try it.
Also ok now to set VMAIL-Count to 0 if calling Your VMail-nr.
(Using a Phone-object)
Program also checking in SMS.Text for specified Trigger
if not Number/Contact trigged it.
To make it possible to send SMS to do some action
depending on SMS-Text.
Maybe I will add possibility to add sveral Trigger-entries in SMSLauncher.ini
to make it possible to send SMS to make different tasks in Phone.
..................................................................................
Exampel of SMSLauncher.ini
(Use 1 line in SMSLauncher.ini like the one below)
467;X;X;HKCU;System\State\Messages\vmail\Line1\Unread;Count;1;076-11223344;133
====== SYNTAX SMSLauncher.ini ==========
aa;bb;cc;dd;ee;ff;gg;hh;ii
aa= SMS.Number/SMS.Body to trigg SMSLauncher actions
bb= Path to EXE for Shell Command
cc= Argument for Shellcommand
dd= Root For Registry writing
ee= Path to Registry Entry
ff= Registry ENtry Name
gg= Value to set
(1= Allways set to 1)
(+1= Add 1 to existing value)
(-1= Subtract 1 from existing value)
hh= A number to reply Incoming SMS to
ii= Number to Your V-MAIL
(If this is set, Reg-Count will be set to 0)
All positions (9 Pos) must be set,
if no action will be used, set Upper case X
-------------------------------------------------------------------------------
Exampel only Reg change trigged on 123456 and removed Reg-Count on V-Mail number 133
123456;X;X;HKCU;System\State\Messages\vmail\Line1\Unread;Count;1;X;133
-------------------------------------------------------------------------------
When use Commandline instead of SMSLauncher.ini,
use same syntax but replace ';' with a space ' '
in commandline. like this
\Windows\SMSLauncher.exe 123456 X X HKCU System\State\Messages\vmail\Line1\Unread Count 1 X 133
understood. everything is clear. well done.
i have already written my ini-file, directory has been created and everything is prepared to start testing.
this app will eliminate lots of screen tappings.
Hopefully a working version
Read Readme-FIle for exact syntax in SMSLauncher.ini
(9 entries must be inside it, set as Upper Case X
if nothing to do in some section)
2 DLL's must be in same foldeer as EXE-file
Phone.dll + Outlook.dll
It will start with Form Shown,
You have to Minimize it Yourself,
either by getting menu and pick on "Today Scrreen"
or any other available way to do it.
does not work at the moment.
my ini looks like this:
5500;X;X;HKCU;System\State\Messages\sms\Unread;vmail;1;X;5500
have also tried it with
Mailbox;X;X;HKCU;System\State\Messages\sms\Unread;vmail;1;X;5500
sms comes in and regkey still stays at 0
on the other hand your app has started to send out continuously my last sms i have been sending out 6 hours ago
Looks like Your Reg-Path is wrong,
try this
5500;X;X;HKCU;System\State\Messages\vmail\Line1\Unread;Count;1;X;5500
(WATCH OUT! NO SPACES IN MY LINE ABOVE UNREAD with No Space inside)
It is working perfectly for me
Is 5500 the number You call to Your Voicemail ?
Is it also the number from where You got sms to tell You got VMAIL ?
yes 5500 is the number from where i receive the sms from and which is my voicebox number.
i think it is not a good idea to use the reg key above as the os is using this key as well.
if you set the value to 1 you will see a vmail-icon appearing in your taskbar.
just to be sure: it should work with any other reg key, shouldn't it?
Hmm I must have totally missed You :-(
I thought You wanted the soft to make your phone
show You got VMail even though You only have a common
SMS from Your Provider telling You have VMail.
I thought problem was You didn't get
Your Phone to "understand" it was Vmail.
Anyway,
Soft can run any app in your phone (with or without Argument)
trigged upon Incoming Phone-Nr or keyword in SMS.Body.
It can reply Incoming SMS.Body+Nr to
Phone-Number of Your Choice.
It can also set Registry-Key of Your Choice
Same Reg-Key can be set to 0 if You call Nr of Your Choice.
no, you understood me totally right. the only "difference" might be that i am using homescreen++ to handle sms and email notifications. i have even disabled the notification bubbles as they annoy me...
bottom line: great work and support! will test it out tonight
Additional Info ...
If You use SMS.Text for triggering,
Word/Words are Case Sensitive
rgds Eurocrypt
Ideas:
Is there need for more functions..
Also Trigg it on incoming PhoneCall ?
Multiple Lines/Triggers in SMSLauncher.ini
to do different tasks depending on Number/SMS.Text ?
Send SMS to change Parameters ?
(<password:..new config..assword>)
Any other ideas are welcome .
I´m hobbyist Just started to play with this,
so to complex tasks are not possible for me to handle.
i would do the following:
possible to run smslauncher in background, i.e. hidden app so that it does not appear in the task manager (i have configured my device to close all apps when locking screen). in this case we need an extra switch to close smslauncher.
another function might be to delete the sms where smslauncher is set to beactivated. i.e. if sms from 5500 activates smslauncher, your app should execute the command line or set the registry value AND (if an optional switch /d is set) instantly delete the sms.
you could also think about, what you proposed, to make text and sender's name available in a registry key.
a lot of people here e.g those who have put together their own manila style GUI, will thank you for this as there is currently no easy way to display sms/email information on the todayscreen.

How make HELLO WORLD on the WM6.1 ???

Who can write Step by Step instruction by C++/VisualStudio 2008 ? for writing Hello World apps And simple actions of work with forms???
You can start here...http://www.hitmill.com/programming/cpp/helloWorld.htm
Remember a search engine is your friend.
Hope that I have help you.
In C++ you have the choice of WIN 32, ATL and MFC programming models. They are all different.
If you are using standard windows forms items ie buttons, editboxes, dropdowns etc. C# is a LOT easier.
stephj said:
If you are using standard windows forms items ie buttons, editboxes, dropdowns etc. C# is a LOT easier.
Click to expand...
Click to collapse
It is indeed much easier for "Hello World" type applications. For more complicated things, poor performance and lack of direct access to the native API begins to add up.
The original poster probably has some specific problem, the solution to which he hopes to find in a step-by-step tutorial. If he still has not been able to solve it, it might help to describe it to us.
O.K........
Over the next few posts, (Rome wasn't built in a day!), this will build into a step by step tutorial in how to create a basic WIN32 application. As a start we will use the C# .Net solution I wrote in reply to this post:
http://forum.xda-developers.com/showthread.php?t=1435629
The original request was for an application that calculates the check digit for an intermodal container number. For the uninitiated, intermodal containers are the ubiquitous 20ft and 40ft metal boxes that dominate the shipping industry.
All containers have an eleven digit serial number of the form:
ABCD 123456 7
Where ABC is the code for the container's owner, and D is the Category Identifier, almost always a 'U'. 123456 is the serial number of the box and the final number '7' is the checksum digit which is calculated from the previous 10 characters. When keying in container numbers into computer systems etc, it can be used to quickly check whether the container number is valid before further processing is done. The same thing applies to the last digit of your credit card number, it is calculated from the previous 15 numbers.
Container numbers conform to ISO6346 and more can be read here http://en.wikipedia.org/wiki/ISO_6346
We will build a WIN32 C++ Mobile 6 application to calculate the check digit from those given in a text box on the screen.
Validation will be minimal, if the user enters anything but characters of the form AAAA999999 in the textbox, nothing appears in the check digit box. When valid, the checkdigit magically appears.
You will need:- Visual Studio Professional 2008, not the express version, and an installed Windows Mobile 6.0 SDK
The Express version of VS cannot target mobile devices. VS 2003/5 can also be used, as well as earlier or later versions of the SDK, but you will encounter slight differences in VS or the SDK, that you will have to fight your way through yourself.
The finished application will look something like the attached image.
Under Win32, there is no drag and drop toolbox, all controls have to be created from scratch. All good fun, so roll up your sleeves, break out the birch twigs and let the self-flagellation begin.......
Right!.....Let's go............
From VS2008 select
File -> New -> Project
Select C++, Smart Device and Win32 Smart Device Project. Select the destination for the project and name it IS06346. See image 01.
Click OK
On the Platforms submenu of the next screen add the Windows Mobile 6.0 SDK to the project and remove the others. See image 02
........and, on the 'Application Settings' submenu, make sure the Windows Application radio button is on, and all others are off. See image 03
Click Finish. The VS wizard will create all the basic files we need under the directory given above.
In fact, pressing F5 should build this project and run it in the emulator. The application does very little at this stage, nothing to be precise, but it should work........... See 04
The main program is ISO3486.cpp This shell program is some 250 lines of code, most of it is needed for a "do nothing" program, but it boils down into five main functions.
WinMain() The entry point of the program, where the operating system will call it on initial load. Leave it alone.
InitInstance() Called immediately by WinMain and where the program creates its initial window etc. We will add a few bits of extra initialization here.
MyRegisterClass() Called by InitInstance to register the window class, just before the initial window is created. Leave it alone unless you really know what you are doing.
WndProc() The message processing loop for the main/parent window. Any windows event will be fired at this function as a Windows Message, it is up to us to process the ones we need. A few variables will go in here. All the original WM2003 "Hello World" program did, in the EVC based SDK, was to intercept the WM_PAINT message, find the client area of the screen, and draw the text "Hello World" in the middle of it.
About() The message processing loop for the About dialog box. We will be quite happy with the default action so we'll leave it alone.
To Do:
1.) Add reference to <string.h>
2.) Create two text boxes and display them. Limit the entry to 10 characters on the main edit box and disable input on the second check digit box.
3) Draw an "Enter container number:" text label above the edit boxes in response to the WM_PAINT message. The edit boxes will draw themselves when required.
4.) Intercept the EN_CHANGE message from the main edit box. If the length of the text in the box is 10 characters long, uppercase it, and if it is valid, generate the checksum and display it in the checksum box, otherwise clear the checksum box. Replace the textbox text with its uppercase value, but do not respond the the EN_CHANGE message generated by this change, as this will trigger an infinite shower of EN_CHANGE messages.
When this is done, we will have a working application.
To be continued.....................
Next...........
Let’s work our way down the TODO: list above.
1.) Add reference to “string.h”:
Later on we are going to use a call to towupper() to convert the input into uppercase. It is defined in string.h, so we have to add this to the source file.
At the top of the ISO6346.CPP after the line
Code:
#include "ISO6346.h"
Add the line:
Code:
#include "string.h"
2.) Create two text boxes and display them......
We will create two windows as text boxes, but we will save their handles as global variables as they are referenced from more than one function. While we are at it we also need a global Boolean variable to prevent the uppercased replacement from causing the runaway reaction mentioned above.
After:
Code:
HINSTANCE g_hInst; // current instance
HWND g_hWndMenuBar; // menu bar handle
Add:
Code:
HWND g_hWndText,g_hWndCheck;
bool g_Updating;
Now let’s create the text edit boxes. You may already know this, or this may be an eye opener, but all edit controls are actually windows in their own right, albeit that they are child windows of the main form.
In InitInstance() after:
Code:
if (!hWnd)
{
return FALSE;
}
add:
Code:
g_hWndText= CreateWindow(TEXT("EDIT"),NULL,WS_CHILD | WS_BORDER,40,50,110,20,hWnd,NULL,hInstance,NULL);
g_hWndCheck=CreateWindow(TEXT("EDIT"),NULL,WS_CHILD | WS_BORDER, 160,50,20,20,hWnd,NULL,hInstance,NULL);
This creates the text edit boxes. As yet they won’t be displayed, but we have to tweak them first. We want to disable the checkdigit box, so that the user cannot type anything into it as we will set it with the correct value when a valid container number is entered in the text box. We will disable it by calling the EnableWindow() function.
We also need to set the size of the text edit window to 10 characters. Under MFC and .NET this is a hoot, as it already a property of the edit control object, which has been conveniently wrappered for us, and we can just set that property. Here in the world of Win32, it is not quite so simple. We have to fire an EM_SETLIMITTEXT message at the window, to tell it that that is what we want. While we are at it, let's set the global g_Updating variable to be false, ready for use later, and here is as good a place as any to do it.
After the CreateWindow() lines we have just added, add the next three lines to do the above.
Code:
SendMessage(g_hWndText,EM_SETLIMITTEXT,10,0);
EnableWindow(g_hWndCheck,false);
g_Updating=false;
Now the windows exist as we want them, all we have to do is display them. At the bottom of the InitInstance() function after
Code:
ShowWindow(hWnd, nCmdShow);
add
Code:
ShowWindow(g_hWndText, nCmdShow);
ShowWindow(g_hWndCheck, nCmdShow);
The main window will now look after them and control them as required. Marvellous!
3) Draw an "Enter container number:" text label............
Now we need a label above the two boxes to tell the user to type a valid container number number into the text box. From the resource view of the project, open the String Table folder in ISO6346ppc.rc then open the String Table object. Click in the blank entry at the bottom and change the ID to IDS_ENTER and the Caption to "Enter container number:" Don't worry about the what the value is, if it is not '3', as the IDE will take care of it.
To get it drawn on the form, we will have to add it to the WM_PAINT event of the main window. We'll need a RECT structure to describe where we want the text to go, a buffer to store the string and while we are here let's add the function variables we are going to need later. At the top of the WndProc() function:
After:
Code:
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
add
Code:
TCHAR c,szBuffer[MAX_LOADSTRING];
RECT rt;
int i,j,k;
bool valid;
i,j and k are general variables for calculating the check digit. szBuffer is used to hold the "Enter container number:" string in WM_PAINT, and also for the contents of the edit box when it changes. As these two events will not occur at the same time, we can get away with it having a dual personality. Variable 'c' is used to read the string one character at a time and 'valid' is set to false if the the container number is not in the correct format.
Replace the TODO: line in the WM_PAINT handler
Code:
// TODO: Add any drawing code here...
with:
Code:
rt.top=20;
rt.bottom=40;
rt.left=40;
rt.right=180;
LoadString(g_hInst,IDS_ENTER,szBuffer,MAX_LOADSTRING);
DrawText(hdc,szBuffer,wcslen(szBuffer),&rt,0);
Now when the form is drawn, the label will appear in the right place.
4.) Intercept the EN_CHANGE message from the main edit box..........
There is no easy way to do the next bit step-by-step, so we will just do it, I'll explain later.........
Replace the standard code for the response to the WM_COMMAND message:
Code:
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, About);
break;
case IDM_OK:
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
with this:
Code:
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(g_hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDOK:
SendMessage (hWnd, WM_CLOSE, 0, 0);
break;
}
switch (wmEvent)
{
case EN_CHANGE:
if(g_hWndText == (HWND) lParam && !g_Updating)
{
GetWindowText(g_hWndText, szBuffer,MAX_LOADSTRING);
if(wcslen(szBuffer)==10)
{
k=0;
valid=true;
for(i=0; i<10; i++)
{
c=szBuffer[i]=towupper(szBuffer[i]);
if((i<4 && (c<'A' || c>'Z')) || (i>3 && (c<'0' || c>'9')))
valid = false;
j=int(c);
if (j > 64 && j < 91)
k += ((j - 55) + (j - 56) / 10) << i;
else
k += (j - 48) << i;
}
if(valid)
{
// Calculate final check digit
k = ((k % 11) % 10);
// Do not process the following update
g_Updating = true;
SetWindowText(g_hWndText,szBuffer);
g_Updating = false;
// Set check window to correct value
szBuffer[0]='0'+k;
szBuffer[1]='\0';
SetWindowText(g_hWndCheck,szBuffer);
// Position cursor at end of edit field.
SendMessage(g_hWndText,EM_SETSEL,10,10);
}
else
SetWindowText(g_hWndCheck,TEXT(""));
}
else
SetWindowText(g_hWndCheck,TEXT(""));
}
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
When the text edit box contents are changed, a EN_CHANGE message arrives at the parent window. It appears as a WM_COMMAND message with the wmEvent parameter containing the EN_CHANGE identifier, together with the handle of the window that generated the message. That is why the second 'switch' code exists to trap the EN_CHANGE event message.
If the EN_CHANGE message came from the Text edit window, not the Checksum window, then get the text within it. If the length is 10 characters long, then process the string. The variable k is used as a running total for the checksum. If after processing all 10 characters, the string is still valid, it is converted modulo 11 and then modulo 10 into the final checksum number. The checksum edit box is then updated with this value. The contents of the Edit box are replaced with its uppercase value. In doing so, we will cause another EN_CHANGE message to be sent to the parent window, which would cause this function to be executed again, and so on and so forth, causing an infinite shower of messages. To prevent this, we set the global variable g_Updating to true before making the change, and then setting it to false immediately afterwards. The test in the first line of the EN_CHANGE processing code, does not execute at all if g_Updating is true, thereby preventing this problem.
Build the final program, and test it in the emulator. Switch the build to 'Release' and the target to Windows Mobile Device, and run the executable on your device.
The complete ISO6346.cpp file is included in the attached zip file.
Here endeth the lesson...........
As a continuation, we will build the whole thing again from scratch, but next time using the Microsoft Foundation Class, MFC.
Watch this space..................
Don Reba said:
It is indeed much easier for "Hello World" type applications. For more complicated things, poor performance and lack of direct access to the native API begins to add up.
Click to expand...
Click to collapse
I totally agree with this! And worst thing is you can neither use a resource hacker tool nor a dependency walker tool, if you want to inspect a .NET CF application.
Using MFC......
From VS2008 as before select File->New->Project then select Visual C++, Smart Device, and MFC Smart Device Application.
Name it ISO6346 as before, and click OK. See image 01
On the platforms submenu select the Windows Mobile 6.0 SDK as before. See image 02
On the Application Type submenu, select the "Dialog Based" and "Use MFC in a static Library" radio buttons. See Image 03
By default the application comes with two dialog boxes for portrait and landscape but in our case this is complete overkill. We will get rid of the Landscape (Wide) dialog box.
In the Dialog folder of the resource view of ISO6346ppc.rc, delete the IDD_ISO6346_DIALOG_WIDE entry. See image 04.
To get this past the compiler, we will have to tidy it up a bit. In ISO6346Dlg.cpp delete the following sections of code.
Code:
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
void CISO6346Dlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
{
if (AfxIsDRAEnabled())
{
DRA::RelayoutDialog(
AfxGetResourceHandle(),
this->m_hWnd,
DRA::GetDisplayMode() != DRA::Portrait ?
MAKEINTRESOURCE(IDD_ISO6346_DIALOG_WIDE) :
MAKEINTRESOURCE(IDD_ISO6346_DIALOG));
}
}
#endif
and also:
Code:
#if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
ON_WM_SIZE()
#endif
Double Click in the IDD_ISO6346_DIALOG entry to open it up in the main window. Click on the "TODO: Place dialog controls here" label and change its caption to "Enter container number:", and position it near the top of the dialog box. From the Toolbox view, drop two edit controls on to the dialog box, under the above label. See image 05. Right click on the first box and select Add Variable. Name the first box edtText and click Finish. See image 06. Do the same for the second box and name it edtCheck. Notice that the wizard has added entries for the DoDataExchange(CDataExchange* pDX) function.
In OnInitDialog() after the line
Code:
// TODO: Add extra initialization here
Add:
Code:
Updating=false;
edtText.LimitText(10);
edtCheck.SetReadOnly();
Note that an Edit Control has more useful methods to call than the Win32 method above, where setting the text limit of the control has to be done by sending windows messages to it.
Right click on the Text Edit Box control and select "Add event handler..." select the EN_CHANGE message, take the default event handler function name, and click the "Add and Edit" button. See image 07 In ISO6346Dlg.h notice that the wizard has added the two edit boxes at the bottom of the file, and also added the message map thus:
Code:
public:
CEdit edtText;
CEdit edtCheck;
afx_msg void OnEnChangeEdit1();
In the //Implementation section of the same file after
Code:
HICON m_hIcon;
add:
Code:
bool Updating;
This will be used as before to prevent an infinite cascade of messages.
In the OnChangeEdit1() function add the following code:
Code:
int i,j,k;
wchar_t c;
bool valid;
CString strText,strCheck;
if(!Updating)
{
if(edtText.LineLength(0)==10)
{
edtText.GetLine(0,strText.GetBuffer(10),10);
strText.ReleaseBuffer(-1);
strText.MakeUpper();
k=0;
valid = true;
// Check the contents are of the form ABCD123456
for(i=0; i<10; i++)
{
c=strText.GetAt(i);
j=int(c);
if((i<4 && (c<'A' || c>'Z')) || (i>3 && (c<'0' || c>'9')))
valid = false;
if (j > 64 && j < 91)
k += ((j - 55) + (j - 56) / 10) << i;
else
k += (j - 48) << i;
}
if(valid)
{
// Calculate final check digit
k = ((k % 11) % 10);
strCheck.GetBufferSetLength(1);
strCheck.SetAt(0,'0'+k);
strCheck.ReleaseBuffer(-1);
edtCheck.SetWindowTextW(strCheck);
Updating = true;
// Do not process the following update
edtText.SetWindowTextW(strText);
Updating = false;
// Position cursor at end of edit field.
edtText.SetSel(10,10,0);
}
else //Invalid Not ABCD123456 - clear the check digit field
edtCheck.SetWindowTextW(TEXT(""));
}
else // Invalid - Not 10 char long - clear the check digit field
edtCheck.SetWindowTextW(TEXT(""));
}
This time we use CString objects to get/set the contents of the edit controls.
Right! That's it. Compile it and run it, either in the emulator or on the device.
See image 08. Notice that as this a dialog application, there are no menu buttons. When the [X] button is pressed the program terminates.
As another interesting point, compare the sizes of the two release executables. The Win32 version is around 8.5kb, that of the MFC version is around 167kb, both launch pretty damned quickly. Compare that with the . NET C# executable from the original post. That is around 9kb in size, but it takes your device around three seconds to shove it through the JiT compiler in order to able to run it, and that is for only a tiny .NET program.

[GUIDE] Create a syncing ToDo list with Zooper and Tasker

How to creating a To Do list that syncs across devices using Tasker, Zooper widget pro and a dropsync-like app.
What this does is looks at a text file on your device and splits the variables up by lines, so if you just create a text file and have each of your tasks on a separate line, this process will split them up into separate variables and list them in your zooper widget. all you need to do is find a nice text editor to do your editing. I use the Dropbox text editor as it works nicely for my needs, but you could use any app you like that does the job.
Here are the steps:
Set up a folder pair with your dropsync or foldersync or whatever app you prefer.
In that folder, create a text file e.g. ToDoList.txt
In Tasker: create a new task e.g. ZTODO that includes:
Variable Set:
Name = %newline
To = (press the enter key so that it’s a carriage return) <don’t just type this text like a moron.
Read File:
File = (press search button and locate text file)
To Var = %TODO
Variable Split:
Name = %TODO
Splitter = %newline
Zooper widget Pro Variable:
Config = ZW var: TODO1 | ZW text: %TODO1
If = %TODO1 Is Set
Zooper widget Pro Variable:
i. Config = ZW var: TODO1 | ZW text: (Press space bar)
ii. If = %TODO1 Isn’t Set
Zooper widget Pro Variable:
i. Config = ZW var: TODO2 | ZW text: %TODO2
ii. If = %TODO2 Is Set
Zooper widget Pro Variable:
Config = ZW var: TODO2 | ZW text: (Press space bar)
If = %TODO2 Isn’t Set
Repeat Steps 4-5 for however many lines you generally have in your to do list increasing the numbers accordingly. I have up to TODO8
Create another task in Tasker e.g. Open TODO
Open file:
i. File = (press search button and locate text file)
In Zooper: Create a new widget
Add a Rich Text element
Edit text manually to:
i. TO Do:
#TTODO1#
#TTODO2#
#TTODO3#
#TTODO4#
Etc until you have them all in there.
Create a module OnTap action linked to the Tasker Task created in 4 above.
You’re done. Choose your favourite text editor to do the editing and the changes should sync across you devices.
If you have any questions or can think of a better way to do this comment below.
[Update] You'll also need to trigger the initial task in a tasker profile. I have one that essentially just runs it every 30 minutes to update the widget.
Cheers
this..

[Q] Need help restricting text length, Margins in Rich Text aren't working

Firstly, I *love* ZWP and have been using it religiously.
With my new Nexus 5, however, I decided to make a new widget to match the current phone instead of my previous setup. I like having my next 3-4 calendar appointments shown in a list with dates and times and the heading, in the #C0SEEE dd - HH:mm# #C0TITLE# format. Some appointments though have longer titles and interfere with other items I have entered into the widget.
I tried using the new Rich Text feature and setting margins to various lengths and setting lines to 1, but a long appointment title still bleeds over into the next portion of my layout.
What am I missing?
Zanthany said:
Firstly, I *love* ZWP and have been using it religiously.
With my new Nexus 5, however, I decided to make a new widget to match the current phone instead of my previous setup. I like having my next 3-4 calendar appointments shown in a list with dates and times and the heading, in the #C0SEEE dd - HH:mm# #C0TITLE# format. Some appointments though have longer titles and interfere with other items I have entered into the widget.
I tried using the new Rich Text feature and setting margins to various lengths and setting lines to 1, but a long appointment title still bleeds over into the next portion of my layout.
What am I missing?
Click to expand...
Click to collapse
You should consider using the [tr]-tags to limit your field to a certain amount of characters. Usage example in your case would be
Code:
#C0SEEE dd - HH:mm# [tr=30]#C0TITLE#[/tr]
This would limit the output of the title to 30 characters and put three dots at the end to indicate the string is longer than what is displayed. You'll have to play around a bit to find the right limit for your particular setup though.
For future references, you can find all the available tags for Rich Text Modules here.
Hope this helps you out

Rich text multiple lines

Is there a way to force a new line in rich text?
I have code like below bit it all appears on 1 line?
#C0TITLE#
#C0SHH:mm# | #C0LOC#
Second question.
I'd like a conditional along the lines of:
IF next calendar entry = tomorrow THEN
show calendar entry
ELSE
Show "nothing for tomorrow"
How can I achieve this?

Categories

Resources