How to display BMP or JPEG file Images
Cfbsbitmap is used for the display of Symbian slices. First, the images of other files are converted to cfbsbitmap for display. The core code is as follows:
Iimagedecoder = cimagedecoder: filenewl (IFS, afilename );
// Create the destination bitmap
Ibitmap = new (eleave) cfbsbitmap ();
Ibitmap-> Create (iimagedecoder-> frameinfo (). ioverallsizeinpixels,
Iimagedecoder-> frameinfo (). iframedisplaymode );
// Start conversion to bitmap
Istate = edecoding;
Iimagedecoder-> convert (& istatus, * ibitmap );
Mobile phone vibration Programming Interface In SDK
The vibration API is introduced in s60 2.0. To use this API, you must add the header file vibractrl in the code. h, and add vibractrl. lib, but one thing is that vibration must be enabled in the user settings. The main author can first look at the description of related classes in vibractrl. h.
Import_c static cvibracontrol * newl ();
Import_c static cvibracontrol * newl (mvibracontrolobserver * acallback );
Import_c static cvibracontrol * newlc (mvibracontrolobserver * acallback );
It should be to build a cvibracontrol object through the above three letters, and then call it startvibra (tuint16 aduration), stopvibra (void) to start/stop vibration.
Thread message sending mechanism
Create an active object class that encapsulates the sub-thread in the main thread, which is written by the operator, 141421.
// Myactive. h
Class cmyactive: Public cactive
{
Public:
Void downloadl (const tdesc & aurl );//
Protected:
Void docancel ();
Void runl ();
PRIVATE:
Static tint threadfunction (Tany * worker G );
PRIVATE:
Rthread ithread;
};
// Myactive. cpp
Void cmyactive: downloadl (const tdesc & aurl)
{
// Create a thread
Ithread. Logon (istatus); // The main thread is notified when the secondary thread exits.
Setactive ();
//...
}
Void cmyactive: runl ()
{
If (istatus. INT () = kerrnone)
{
// The Sub-thread has exited normally.
}
}
Tint cmyactive: threadfunction (Tany * worker g)
{
// Download
}
How to obtain the flip status
Series 60 C ++ developers can now write some application software to respond to users turning on or off the phone cover, or changing the orientation of the Mobile Camera. The above two user actions may occur on the Nokia N90 multimedia terminal. This type of software event is supported since Series 60 2nd Edition Feature Pack 2. For example, when a user closes the terminal, the developer can automatically transfer the output to the external screen for display. When the user opens the terminal, the output is automatically transferred to the Internal screen (usually the internal screen is large ).
To add such features to an application, simply add some event processing handles to ceikappui: handlekeyeventl. The corresponding events (teventcode) are eeventscreendevicechanged, eeventcaseopened, and eeventcaseclosed. When the camera is rotated, it is a key event of the eeventkeyup and eeventkeydown types.
The following sample code is used to check the current camera orientation:
# Include // link against Ecam. Lib
Ccamera * cam = ccamera: newl (* This, 0 );
Tcamerainfo Info;
Cam-> camerainfo (Info );
Tcameraorientation orientation = info. iorientation;
Convert tdesc type to char * type
Const char * CP = reinterpret_cast <const char *> (DESC. PTR (); // or use ptrz ()
Char * P = const_cast <char *> (CP );
Remember that the length of the string is desc-> size () (or desc-> length () * 2), and the max length of the string is desc-> maxlength () * 2 (including the '/0' Terminator, if any ).
For details, see:
"Conversion bitween 8 and 16 bits Descriptors"
Http://forum.newlc.com/index.php/topic,1075.0.html
How to read Chinese garbled characters from files
Method 1:
Cnvutfconverter: convertfromunicodetoutf8 (), convert Unicode to UTF-8 encoding before display.
Method 2:
Ccnvcharactersetconverter * converter = ccnvcharactersetconverter: newlc ();
// Check if there is conversion between GBK/gb2312 and Unicode
If (converter-> preparetoconverttoorfroml (kcharactersetidentifierutf8,
Ceikonenv: static ()-> fssession ())! = Ccnvcharactersetconverter: eavailable)
User: Leave (kerrnotsupported );
Tint state = ccnvcharactersetconverter: kstatedefault;
Hbufc * atextbuf = hbufc: newl (astuffdata. Length ());
Tptr16 PTR = atextbuf-> des ();
If (ccnvcharactersetconverter: eerrorillformedinput = converter-> converttounicode (PTR, astuffdata, State ))
User: Leave (kerrargument); // leave if error in conversion.
Cleanupstack: popanddestroy (); // clean for Converter
File Storage
Some data is stored in the file. Each variable is saved in one row in the notepad file, and the values of variables are stored in each row.
Rfile file;
// Open the file here...
Tfiletext txtfile;
Txtfile. Set (File );
// Convert your data to a descripter...
// This operation appends a line delimiter to the descriptor
Txtfile. Write (data );
// Of cource tfiletext: Read () is the reverse operation which read a whole line.
Current input method in the edit box
When the focus is on an editing box, obtain the input method of the current editing box:
Tcoeinputcapabilities ICAP = Edwin-> inputcapabilities ();
Caknedwinstate * edwinstate = static_cast (ICAP. fepawaretexteditor ()-> extension1 ()-> state (knulluid ));
Tint inputmode = edwinstate-> currentinputmode ();
Achieve byte alignment
The GCC compiler ignores "# pragma pack" statement when compiling for ARM platform, so you shoshould use "_ attribute _ (packed, aligned)", like this:
# If defined (_ wins __)
# Define packed
# Else
# Define packed _ attribute _ (packed, aligned (1 )))
# Endif
# Pragma pack (1)
Typedef struct {
Char sig [104];
Unsigned char Verl, key;
Int nfile, dfile, CRC;
} Packed avl1;
Typedef struct {
Char name [22];
Int length, CRC32;
} Packed avd1;
# Pragma pack (4)
A simple latency or timing Function
You need to complete at least three steps:
1. Create a cperiodic object, as shown in figure
Void cperiodicrunner: starttimer ()
{
Const tint tickinterval = 1000000;
Iperiodic = cperiodic: newl (0); // neutral priority
Iperiodic-> Start (tickinterval, tickinterval, tcallback (tick, this ));
}
Cperiodic: Start: void start (ttimeintervalmicroseconds32 adelay, ttimeintervalmicroseconds32 aninterval, tcallback acallback );
Therefore, we need a callback function to do something during each callback, so we have the second step.
Ii. Callback Function completion
Tint cperiodicrunner: Tick (Tany * aobject)
{
// Cast, and call non-static function
(Cperiodicrunner *) aobject)-> dotick ();
Return 1;
}
If you are not familiar with tcallback, you can refer to the SDK. The function above completes the corresponding cycle action (dotick) during timing)
Iii. Timer Analysis
After the timer is stopped or the outside world stops, you need to stop the timer in one sentence:
Cperiodicrunner-> cancel ();