Windows CE development FAQ

Source: Internet
Author: User
Tags bmp image mdb database

1. How can I enable the keyboard when a control obtains focus?

For example, after an editbox obtains the focus, the soft keyboard is automatically opened at this time, which makes it easy for users to enter some parameters in -- sipinfo, shsipinfo, sipsetinfo, and sipgetinfo.

// Hide the Input Panel
Bool lowersip ()
{
Bool Fres = false;
Sipinfo Si;
Memset (& Si, 0, sizeof (SI ));
Si. cbsize = sizeof (SI );
If (shsipinfo (spi_getsipinfo, 0, & Si, 0 ))
{
Si. fdwflags & = ~ Sipf_on;
Fres = shsipinfo (spi_setsipinfo, 0, & Si, 0 );
}
Return Fres;
}

// Raise the Input Panel
Bool raisesip (void)
{
Bool Fres = false;
Sipinfo Si;
Memset (& Si, 0, sizeof (SI ));
Si. cbsize = sizeof (SI );
If (shsipinfo (spi_getsipinfo, 0, & Si, 0 ))
{
Si. fdwflags | = sipf_on;
Fres = shsipinfo (spi_setsipinfo, 0, & Si, 0 );
}
Return Fres;
}
Try the following:
// Shsippreference (m_hwnd, sip_up); // The Input Panel is displayed.
// Shsippreference (m_hwnd, sip_down); // hide the Input Panel (with a latency)
// Shsippreference (m_hwnd, sip_forcedown); // hide the Input Panel (now)
// Shsippreference (m_hwnd, sip_unchanged );
// Generally, this command is invalid only when sip_down is called.

--------------------------------------------------------------------------------

2. String-number conversion in wince!

After the # include <stdlib. h> and # include <stdio. h> files are included in vc6.0, there is no problem with the following code,
Cstring str1, str2;
Str1 = "123 ";
Str2 = "123.4 ";
Int I;
Float J;
I = atoi (str1 );
J = atof (str2 );
However, in evc3.0, a problem occurs: the prompt atof is not defined, and atoi cannot be converted normally.

Wcstoi, wcstof, wcstol and wcstod

--------------------------------------------------------------------------------

3. I have a new Pocket PC and compiled several programs, but I found that the dialog box can only be displayed in full screen. Why?

Generally, all the dialog boxes in the Pocket PC are displayed in full screen mode, which is defined by the operating system. However, if you use the system-defined information prompt box, it is not displayed in full screen. For example, this is the case in the prompt box inspired by afxmessagebox.
You can reload wm_initdialog messages.
Msdn:
The dialogbox macro uses the create‑wex function to create the dialog box. dialogbox then sends a wm_initdialog message to the dialog box procedure. the function displays the dialog box (regardless of whether the template specifies the ws_visible style), disables the owner window, and starts its own message loop to retrieve and dispatch messages for the dialog box.

After the dialog box is created, a wm_initdialog message is sent. You only need to process the message in your window message processing function.
For example:

Case wm_initdialog:
// Create a done button and size it.
Shidi. dwmask = shidim_flags;
Shidi. dwflags = shidif_donebutton | shidif_sipdown | shidif_sizedlgfullscreen;
Shidi. hdlg = hdlg;
Shinitdialog (& Shidi );
Initoptiondlg (hdlg );
Return true;

Modify Shidi. dwflags to see how to process the messages in the about window.
Supplement: shinitdlginfo Shidi;
Shinitdlginfo Shidi;
The method mentioned above is in a pure API Program
For the dialog program created by MFC, you can do this:

Bool cxxxdlg: oninitdialog ()
{

Shinitdlginfo Shidi;
Hwnd hdlg = m_hwnd;
// Create a done button and size it.
Shidi. dwmask = shidim_flags;
Shidi. dwflags = shidif_sipdown;
Shidi. hdlg = hdlg;
Shinitdialog (& Shidi );
// Initoptiondlg (hdlg );
// Cdialog: oninitdialog ();
......

}

--------------------------------------------------------------------------------

4. How to hide the toolbar bar in the evc mfc-based program

Hide a toolbar:
First, if you use the MFC Wizard to create a project, the toolbar is generated by default. What I want to say is, kill it! Create it by yourself. :)
First, declare the ctoolbar member variable:
Ctoolbar * d_ptoolbar2;
Then ......
Static uint based_code toolbar2buttons [] =
{
// Below is the menu ID corresponding to the toolbar, And the toolbar icon is a bitmap that I get, and its ID is idr_add_toolbar
Id_file_new,
Id_file_open,
Id_file_save,
Id_separator,
Id_edit_cut,
Id_edit_copy,
Id_edit_paste,
Id_separator,
Id_trans_dict,
Id_toolbar_show, // This is a newly added menu item. Click "Hide toolbar" and click "show toolbar ".
};
Then ......
Add the following to oncreate () of cmainframe:
Ontoolbarcreate ();
Then ......
Void cmainframe: ontoolbarcreate ()
{
// Shocould only get here if we don't have a toolbar.
Assert (d_ptoolbar2 = 0 );
// Create C ++ object and winapi window.
D_ptoolbar2 = new ctoolbar ();
D_ptoolbar2-> Create (this, ws_child | cbrs_bottom |
Cbrs_size_fixed | cbrs_floating,
0x9100 );
// Get bitmap and connect to tool items.
D_ptoolbar2-> loadbitmap (idr_add_toolbar );
D_ptoolbar2-> setbuttons (toolbar2buttons,
Sizeof (toolbar2buttons)/sizeof (uint ));
// Make toolbar dockable.
D_ptoolbar2-> enabledocking (cbrs_align_any );
Enabledocking (cbrs_align_any );
Dockcontrolbar (d_ptoolbar2 );
}
Then ......
Void cmainframe: ontoolbarshow ()
{
Assert (d_ptoolbar2! = 0 );

// Query current visibility.
Bool bvisible = (d_ptoolbar2-> getstyle () & ws_visible );

// Show or hide.
Int nshow = (bvisible )? Sw_hide: sw_shownormal;
D_ptoolbar2-> showwindow (nshow );

// Reconfigure remaining toolbar items.
Recalclayout ();

// Store visibility state for later.
D_btoolbarvisible = (! Bvisible );
}

Void cmainframe: onupdatemedilbarshow (ccmdui * pcmdui)
{
// This function is signed for checking the menu 'edit | show toolbar'
Pcmdui-> enable (d_ptoolbar2! = 0 );
Int ncheck = (d_btoolbarvisible )? 1: 0;
Pcmdui-> setcheck (ncheck );
}

OK. By default, the toolbar is hidden. Click the newly added hide/display toolbar command in the menu to switch back and forth.

--------------------------------------------------------------------------------

5. How do I create an installer in a Pocket PC?

An example of C:/Windows CE tools/wce300/MS Pocket PC/support/ActiveSync/Windows CE application installation is given below.
There are other third-party installation tools, such as InstallShield.

--------------------------------------------------------------------------------

6. How to display an image on the main interface

I made a small program and wanted to display an image on the main interface. My image is in. jpg format. What tools should I use if I want to convert it?

Convert a jpg image into a BMP image. There are many such programs on the Internet.
Then, use loadbitmap, SelectObject, stretchblt, and other statements to display the BMP image to the view.

--------------------------------------------------------------------------------

7. Could you tell me how to intercept all mouse and keyboard messages under wince?

Only three hooks can be used in wince.
# Define wh_journalrecord 0
# Define wh_journalplayback 1
# Define wh_keyboard_ll 20

--------------------------------------------------------------------------------

8. Can I create a dialog box using EVC in a Pocket PC that is not full screen?

In MFC

M_bfullscreen = false;

--------------------------------------------------------------------------------

9. How can I convert a char-type Chinese string to a unicode string?

Multibytetowidechar, which is invalid in the simulator; you can also use other methods; Use the wcsprintf Function

--------------------------------------------------------------------------------

10. In the EVC single document interface, there is always a "new" on the left of the menu. How can I remove it?

Find this in oncreate of mainfrm:
M_wndcommandbar.m_bshowsharednewbutton = true;
Change true to false.

--------------------------------------------------------------------------------

11. Why is context menu in edit?

Recently, I have read the NPP in the sample in the SDK. One of the features is that the context menu appears on the edit interface. However, when I add this function to my project, that is, add control "", idc_static, "sippref", not ws_visible,-10,-10, 6, and 6 to the resource, which is normal in the simulator, however, the dialog box containing edit cannot be displayed in the PDA. NPP can be displayed normally on both sides. I added a dialog box in NPP and changed the resource accordingly. The result is displayed in both the simulator and PDA.

Calling shinitextracontrols () should be in the constructor and should not be in oninitdialog. If called in oninitdialog, the dialog box containing edit is not displayed.
In fact, it is better to call the xxxapp: initinstance function only once.

--------------------------------------------------------------------------------

12. How to convert. mdb database to. CDB Database

How to convert a. mdb database to A. CDB database without the actual PDA, only the Pocket PC emuliation and EVB.
Why does the message "operation cannot be completed due to insufficient memory" appear during the running of the Pocket PC emuliation "?

Microsoft has provided the answer to this question.
In the SDK documentation, there is an example program called device, which converts the TDB file into a CDB file, and a desktop program that converts the MDB file into a TDB file.

--------------------------------------------------------------------------------

13. How can I use EVC to create and call a DLL?

I followed the example of developing DLL with MFC in help, but a connection error occurred while calling another program, saying that the function could not be found. This is also true after looking at the EVC example spintest.

Same as in Windows
Is it link2001 error?
If you call it implicitly (without loadlibrary (), specify the Lib file of your DLL in project --> Settings ---> link ---> input.

--------------------------------------------------------------------------------

14. How does the edit box automatically wrap the line?

How to Implement the table control in Plam on WinCE?
The edit box will automatically wrap the line. When more than one line is entered, the line is automatically switched to the next line, and the following content is automatically rolled down.

Check the multiline of the edit control. If you want to enter a carriage return, then select want upload urn.

--------------------------------------------------------------------------------

15. Is the update statement in adoce and pocket access not executable?

Adoce cannot directly execute the update statement, but adoce has the update method, which can be used for implementation.

--------------------------------------------------------------------------------

16. How can I implement the inport (...) and outportb (...) functions in BC ++ in Windows CE?

Ce, you can use Windows API functions to operate ports. Relatively simple.
Createfile is generally used for APIS (open ports, serial port operations and file operations are only different in opening methods, so the third parameter must use open_existing)
The commtimeouts and DCB structures store the setting parameters.
Writefile and writefile (read/write ports)
Because serial communication uses asynchronous communication, the following two statements are important:
Setcommmask (Port event monitored)
Waitcommevent (wait for port event)

--------------------------------------------------------------------------------

17. How to display a dialog box for users to select a directory instead of a file

If there is no standard function to process this, you have to implement a third-party solution by yourself.

--------------------------------------------------------------------------------

18. Is there any way (API) to activate or disable the power saving mode?

See the installation documentation of systemidletimerreset. Create a thread that contains an infinite loop like sleep, and then call systemidletimerreset (). Maybe one way to interrupt the thread is to exit the program.

--------------------------------------------------------------------------------

19. What is the minimum file name for Windows CE?

In windef. H, max_path is defined, which generally contains 260 characters.

20. I used cfiledialog to create a browse button. The default directory is always displayed under "All Folders" and under "/My device/My do *** ents. How to change the initial directory to "/My device ". Use filedlg. m_ofn.lpstrinitialdir = text ("file: // my/device");, but the default directory is not changed.
Lpstrinitialdir points to a string that specifies the initial file directory. If it is null, the system root directory is used. Try to set lpstrinitialdir to null.

--------------------------------------------------------------------------------

21. Can there be X and OK buttons on the Pocket PC taskbar?

No, at least no third-party tool like wisbar.

--------------------------------------------------------------------------------

22. How do I prevent users from changing the date and time? Is it possible?

You may use your own program to replace/Windows/clock.exe, but they can process this through another program. Similarly, in the same step, ActiveSync changes the time when the device matches the PC.

--------------------------------------------------------------------------------

23. I have an xscal CPU ipaq 3970 device, but there is no target type on Embedded Visual C ++ 3.0. What type should I use on evc3.0. This issue also occurs on the installation program cabwiz.exe.

You can use the arm type. Xscal is based on the arm system.

--------------------------------------------------------------------------------

24. How to make the program run in the background?

The minimal program will bring the program into the background, so as long as the program is minimized at startup, it will run in the background.

Supplement: it can also be made into a service.
--------------------------------------------------------------------------------

25. I want to remove the SIP button. I used shfullscreen IN THE oninitdialog event. However, the SIP button is still visible. Do you forget what to do?

The Code is as follows:

// Shfullscreen fails if dialog box is not foreground.
Setforegroundwindow ();
// Go to the full screen mode
Shfullscreen (m_hwnd, shfs_hidesipbutton | shfs_hidestarticon );

You cannot use shfullscreen in oninitdialog because the dialog box is not visible. You should pass a custom message and call this function in that message.

The following code may be useful:

Void pfcsipbuttonshow (bool bshow)
{
Hwnd =: findwindow (_ T ("ms_sipbutton"), null );
If (hwnd = NULL)
Return;

If (bshow)
: Showwindow (hwnd, sw_show );
Else
: Showwindow (hwnd, sw_hide );

} // Pfcsipbuttonshow

--------------------------------------------------------------------------------

26. How to install the Pocket PC program on the pocket pc2002 simulator?

The ppc2002 simulator does not simulate an ARM processor, so you must have an x86 CPU binary file and the corresponding installer. You only need to use the file browser to copy the cab file to the simulator and then execute it. The installation package of commercial programs generally does not contain x86 binary programs. If you do not have an x86 processor program release version, you cannot install it. If the program is your own, you can create an x86 version, and then create an installation cab.

--------------------------------------------------------------------------------

27. How to read common Icon files in the EVC program?

Use extracticonex () in a PC program, but it does not seem to work on a pocket device. What is missing? Is the PC icon file invalid in the Pocket PC environment? Or need to convert the format?

Unfortunately, there is no API on the Pocket PC to read the icon. Therefore, you have to manually parse the icon file.

--------------------------------------------------------------------------------

28. How to draw a transparent circle?

I want to use EVC ++ and GDI to draw a circle on Pocket PC 2002. I used it to draw a straight line and it handled well:

Hbrold = (hbrush) SelectObject (HDC, createpatternbrush (RGB (0,255, 0 )));
Hpnold = (Hpen) SelectObject (HDC, createpen (ps_solid, 2, RGB (255, 0, 0 )));
Ellipse (HDC, 10, 10, 20, 20 );
Deleteobject (SelectObject (HDC, hbrold ));
Deleteobject (SelectObject (HDC, hpnold ));

But how to draw a transparent circle? Is there a paint brush type like ps_null?

You can use getstockobject () to get an null_brush or hollow_brush (the two are the same ). Then select it with SelectObject, as you have already done.

--------------------------------------------------------------------------------

29. Assuming that I know the program name and what API is used to close the running EVC program?

If you know the program name and assume that it is the same as the name of the main window, you can use findwindow to get the handle of that window and then send the wm_close message to that window.

Hwnd = findwindow (null, _ T ("Application name "));
If (hwnd)
Postmessage (hwnd, wm_destroy, 0, 0 );

--------------------------------------------------------------------------------

30. How do I set the PDA time from the PC?

The simplest method is to write a custom rapi function and call the setsystemtime of the device through cerapi.

--------------------------------------------------------------------------------

31. How to Use writebinary? I don't understand the second parameter (lpbyte ):

Bool cvoregistry: writebinary (lpctstr pcszkey, lpbyte pdata, DWORD cbdata)

The second parameter is the buffer that points to the binary data that you want to write to the Registry.

Byte data [] = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef };
Extern cvoregistry reg;
Reg. writedata (_ T ("binarydata"), data, sizeof (data ));

--------------------------------------------------------------------------------

32. Does Windows CE support hook APIs? In this way, we can monitor the time required. If yes, is it used like Windows 2000?

Bad message: ce does not support hooks.
The system does not support it. We can still find another method ......

--------------------------------------------------------------------------------

33. I cannot use the cdialog titlebar on the Pocket PC. I can use a static text box control to make it similar to titlebar. Is there a way to display titlebar?

In most Pocket PCs, the dialog box is displayed in full screen mode and does not have its own topic bar. Instead, the system taskbar is used. You can create a non-full-screen dialog box (like a message box ).

--------------------------------------------------------------------------------

34. How to disable (suspend) pocekt PC in the program?

Method 1: Virtual shut-down key
: Keybd_event (vk_off, 0, 0, 0 );
: Keybd_event (vk_off, 0, keyeventf_keyup, 0 );

Method 2: Call the undisclosed function poweroffsystem ()
Extern "C" _ declspec (dllimport) void poweroffsystem ();

--------------------------------------------------------------------------------

35. How to restart the Pocket PC in the program?

# Include
# Define ioctl_hal_reboot ctl_code (file_device_hal, 15, method_buffered, file_any_access)
Extern "C" _ declspec (dllimport) bool kerneliocontrol (
DWORD dwiocontrolcode,
Lpvoid lpinbuf,
DWORD ninbufsize,
Lpvoid lpoutbuf,
DWORD noutbufsize,
Lpdword lpbytesreturned );
Bool resetpocketpc ()
{
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}

--------------------------------------------------------------------------------

36. How to hard-start (hardware reset) pocekt PC in the program?

Note: using this code segment will clear all user data in your Pocket PC.

# Include
# Define ioctl_hal_reboot ctl_code (file_device_hal, 15, method_buffered, file_any_access)
Extern "C" _ declspec (dllimport) void setcleanrebootflag (void );
Extern "C" _ declspec (dllimport) bool kerneliocontrol (
DWORD dwiocontrolcode,
Lpvoid lpinbuf,
DWORD ninbufsize,
Lpvoid lpoutbuf,
DWORD noutbufsize,
Lpdword lpbytesreturned );
Bool hardresetpocketpc ()
{
Setcleanrebootflag ();
Return kerneliocontrol (ioctl_hal_reboot, null, 0, null, 0, null );
}

--------------------------------------------------------------------------------

37. The following methods are incomplete and cannot be used:

1. The system does not know vk_off
2. Which DLL and Lib file is used?

· How To disable (suspend) pocekt PC in a program?

Method 1: Virtual shut-down key
: Keybd_event (vk_off, 0, 0, 0 );
: Keybd_event (vk_off, 0, keyeventf_keyup, 0 );

Method 2: Call the undisclosed function poweroffsystem ()
Extern/"C/" _ declspec (dllimport) void poweroffsystem ();

Close (suspend)
Method 1:
// Virtual shut-down key
: Keybd_event (vk_off, 0, 0, 0 );
: Keybd_event (vk_off, 0, keyeventf_keyup, 0 );

Method 2:
// Call the undisclosed function poweroffsystem ()
Extern "C" _ declspec (dllimport) void poweroffsystem ();

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.