📜 ⬆️ ⬇️

Programming under Windows CE in C ++ using Embedded Visual C ++, Part 4 (epigraph)

Programming under Windows CE in C ++ using Embedded Visual C ++, Part 4 (epigraph).

Since articles 1 , 2 , 3 caused such interest, I decided to add some more thoughts and material.


WinCE has pop-up warnings that are useful for background applications. An icon may appear on the taskbar, clicking on which sends you WM_NOTIFY and if you do not respond as expected, a floating window opens with your HTML. This HTML can contain links that WM_COMMAND sends to your application. On different devices, the appearance of these windows is different, but the functionality is the same.
')
#ifdef UNDER_CE

static const GUID guid =
{0x90a71709, 0x9247, 0x4819, {0xac, 0xc8, 0xc7, 0x95, 0xa3, 0x90, 0x1d, 0xb8}};

void BaloonNotify ( const TCHAR * html, const TCHAR * title, int cmd = 1)
{
SHNOTIFICATIONDATA n;

memset (& n, 0, sizeof (SHNOTIFICATIONDATA));
n.dwID = cmd;
n.clsid = guid;
n.npPriority = SHNP_INFORM;
n.csDuration = 12;
n.hwndSink = Application-> MainForm? Application-> MainForm-> hwnd: 0;
n.pszHTML = html;
n.hicon = Application-> icon;
n.cbStruct = sizeof (SHNOTIFICATIONDATA);
n.pszTitle = title;
n.grfFlags = cmd <100? SHNF_STRAIGHTTOTRAY | SHNF_SILENT: 0;

SHNotificationAdd (& n);
}

void RemoveBaloon ( int cmd = 1)
{
SHNotificationRemove (& guid, cmd);
}

#endif



In the simplest case, when you want to bring the application back to the fore, your html might look like this:

<html> <body> <a href='cmd:1'> Activate <b> My Stray </ b>. </a> </ body> </ html>

In this case, the system will send a WM_COMMAND to the window when it clicks the link and puts 1 in lParam.

Just in case: how to check that our window is now hanging in the foreground:

bool ApplicationIsForeground ()
{
HWND hwnd = GetForegroundWindow ();
DWORD my_pid = 0; GetWindowThreadProcessId (Application-> MainForm-> hwnd, & my_pid);
DWORD pid = 0; GetWindowThreadProcessId (hwnd, & pid);
return pid == my_pid;
}


Working with the menu on WinCE is different from that on Win32. Here is an example of loading a ready-made menu from a resource on these platforms:

void TWinControl :: CreateMenu (unsigned menu_res_id)
{
if (menu_hwnd! = 0) throw _T ( "Menu already created." );
#ifdef UNDER_CE
SHMENUBARINFO mbi;
memset (& mbi, 0, sizeof (SHMENUBARINFO));
mbi.cbSize = sizeof (SHMENUBARINFO);
mbi.hwndParent = hwnd;
mbi.dwFlags = SHCMBF_HMENU;
mbi.nToolBarId = menu_res_id;
mbi.hInstRes = Instance-> Handle;
if (SHCreateMenuBar (& mbi))
menu_hwnd = mbi.hwndMB;
else
menu_hwnd = 0;
AdjustFormToDesktop ();
#else
menu_hwnd = LoadMenu (Instance-> Handle, MAKEINTRESOURCE (menu_res_id));
SetMenu (hwnd, menu_hwnd);
#endif
}

* This source code was highlighted with Source Code Highlighter .

Finally, general considerations.

As a rule, on Win CE devices, the top-level menu may contain two items, each of which has its own button on the device. Count on more is not worth it.

Do not forget about the joystick, which occurs quite often. Try to use all of its keys, as this is the easiest way for a user to enter something into your application.

Since the PDA screen is small, it is reasonable to design the application according to the principle “active window on the whole screen”, use elements like PageControl, which select a little space, but allow you to quickly switch to the desired tab and are intuitively understandable to users.

It will be reasonable to prompt the user to select the font size that displays the entire application and to remember this choice. Some like the fine print, and some have poor eyesight. Of course, this will require additional efforts from you in fitting the font height controls. Without a block that performs a quality layout control on the form it is meaningless.

It is convenient for left-handers to work with tables when the scroll bar is to the left of the table. Unfortunately, the Windows Mobile platform itself does not provide the ability to switch to a left-handed person, but in its controls it is easy to foresee.

Of great importance in applications for PDAs is their unobtrusiveness. People often work with PDAs on the go, so do not ask too many questions. One example of this behavior is local Excel, which, when closed, does not ask questions, but carefully puts the file in the right place. Here, the principle of "do not annoy the user with idiotic questions, but rather give the opportunity to roll back any action."

Landscape orientation is a handy thing for displaying, for example, graphs. But to force the switch force - moveton.

Entering data on a PDA takes a lot of strength and energy. No wonder then you want it so much ... Oh, that is, in short, remember - the PDA is not for stenographers! Minimize text input.

Good luck!

Source: https://habr.com/ru/post/40088/


All Articles