Archive for March 2011

Basics of Message Dealing with in Windows

Getting to know Windows – Part six
Quantity – Windows Person Interface

Introduction
This is component 6 of my series, Acquiring to know Windows. I assume you have go through all the prior tutorials prior to this a single. You ought to be reading through the tutorials in the order presented. In this aspect of the series we seem at essentials of message dealing with in windows.

Note: If you cannot see the code or if you assume something is lacking (damaged hyperlink, image absent), just get in touch with me at forchatrans@yahoo.com. That is, contact me for the slightest difficulty you have about what you are reading through.

Some Data Types and Predefined Capabilities
In this section we appear at some information types and some predefined features supplied by the User Interface (Windows API) to handle messages. We are chatting about the messages that are sent to the window course treatment. A message has to be eliminated from the queue and dispatched (sent) to a process. There are particular information varieties and capabilities related with this.

The DOOL Type
The BOOL information sort is for a Boolean price. A Boolean price is possibly the appeal, Genuine or Fake. Accurate can also be a range and Fake can also be a number.

The MSG struct
A message has 4 parts (parameters). The MSG is a struct like the C++ struct. It is employed to hold a system message. Its members are:


  HWND   hwnd
  UINT   message
  WPARAM wParam
  LPARAM lParam
  DWORD  time
  POINT  pt

We shall not use the previous two members for most of the tutorials. The 1st 4 members are the various message areas we have been chatting about. You have the windows take care of, the message identifier (message) and the two parameters for the message knowledge (or knowledge site).

The GetMessage Function
The GetMessage function retrieves a message from the queue and spots it in an MSG structure, which you ought to have declared. When a message is retrieved, it is taken out from the queue and it is no lengthier in the queue. The GetMessage perform would normally return a nonzero amount. Even so, if the message it retrieves is WM_Quit, which indicates Stop the Application, the function will return zero. Any message identifier like WM_Give up is in fact an integer worth. In other phrases, an integer has been assigned to it.

The straightforward prototype of the GetMessage function is:

BOOL WINAPI GetMessage(LPMSG lpMsg,  HWND hWnd, UINT wMsgFilterMin, UINT wMsgFilterMax)

lpMsg is the deal with to the MSG structure. hWnd is the manage of the window whose messages are to be retrieved from the queue. If hWnd is NULL the funtion retrieves message that is for any window. wMsgFilterMin and wMsgFilterMax are each and every an interger appeal. For simple programming, set these two values to zero.

The return worth is a BOOL. The exact return sort is BOOL WINAPI do not fear considerably about that for now. The perform typically returns a nonzero number. If the function retrieves the WM_Stop message, the return worth is zero. If there is an error, the returned value is – one. Note that none of the parameters of the GetMessage operate truly handles the message. The function gets the message form the queue and spots it in the MSG struct the message does not pass via the operate.

The TranslateMessage Perform
The TranslateMessage function specials with keyboard character inputs. Each time the consumer presses a important, the working technique generates virtual-important messages (WM_KEYDOWN and WM_KEYUP). As the consumer is pressing a essential, the WM_KEYDOWN message is generated and goes into the queue. When the user releases the key, the WM_KEYUP message is produced and goes into the queue. Keep in mind, these messages are really integers.

A virtual-key message contains a virtual-key code that identifies which essential was pressed, but not its character value. To obtain the price, you have to use the TranslateMessage function. The simplified prototype of the TranslateMessage purpose is:

BOOL WINAPI TranslateMessage(const MSG *lpMsg)

It has only one particular argument, which is the handle of the MSG struct, which need to be possessing the message that the GetMessage operate acquired from the queue. Its return worth is a BOOL (a number). If the message is translated, the return appeal is nonzero. If the message is not translated the return worth is zero.

If the TranslateMessage purpose translates a message, it posts (sends) the translated message to the queue.

Be aware: The return worth of the function is not the character appeal. The TranslateMessage purpose translates (converts) the virtual-crucial message into a character message (WM_CHAR) and locations it back into the software message queue. The character message will then have to be eliminated from the queue prior to becoming sent (dispatched) to the window course treatment. The message placed back again into the queue has the character value (code).

The DispatchMessage Function
The DispatchMessage function sends the message go through from the MSG struct to a window course procedure. This purpose knows what window the message will act on, by the window manage in the message in the MSG struct. If the window manage parameter in the MSG struct is NULL, the DispatchMessage function does nothing (does not deliver any message) so far as windows are concerned.

Handling Events in Windows
Any input motion (keyboard or mouse) in Windows is an occasion. When the consumer clicks an item, he sees the reaction automatically. From a technical stage of view, there is practically nothing like, routinely, in the handling of occasions. You, the application developer has to create a While Loop to do that.

When an occasion occurs the corresponding message is sent to the system message queue and it stays there. If it is not removed and sent to the window course method the person will see no reaction. You have to compose a whilst loop that will be iterating continually, getting rid of the messages from the queue and sending to their respective windows (techniques). It is the window class process that supplies the reaction. Since the even though loop is running naturally extremely rapidly and repeatedly, the person sees a quite speedy reaction to his event. So to the consumer, the reaction is automatic.

While Loop Code for Occasions
The while loop works with an MSG info sort. The adhering to is classical code:

MSG msg
BOOL bRet
HWND hwnd

whilst( (bRet = GetMessage( &ampmsg, hwnd, , )) != )

    if (bRet == -1)
   
        // handle the error and perhaps exit the software
   
    else
   
        TranslateMessage(&ampmsg)
        DispatchMessage(&ampmsg)
   

In the code, first you have the identifier (msg) for an MSG struct declared. Subsequent you have an identifier (bRet) for a BOOL kind declared. You then have one more identifier (hwnd) for the window take care of of interest, declared, with the HWND kind. We shall see much more about window handles afterwards. Then you have the whilst loop.

If the price of the hwnd parameter in the GetMessage function is NULL, then the GetMessage perform will eliminate the following message in the queue. If the hwnd parameter is not NULL, then the perform will eliminate the following window message from the queue.

The situation in the even though loop is:

        (bRet = GetMessage(&ampmsg, hwnd, , )) !=

Look at the condition extremely properly. It removes the subsequent window message from the queue and areas it in the msg struct. The return appeal of the GetMessage purpose is a BOOL (and not the message) is assigned to the identifier, bRet. If the value of bRet is zero, it implies the message is WM_Give up, which implies the software really should give up and the although loop need to cease. If bRet is not zero is means, the GetMessage purpose succeeded to remove a message from the queue or an error occurred in the endeavor to remove a message. That is why you have “!= ” at the finish of the even though situation. If the value of bRet is -1, it means an error occurred in the message elimination endeavor. However, the although loop iteration will even now execute, since it is “!=-” and not “!= -one” that decides the execution of the even though loop block.

If the while loop block is to execute, it signifies either the message elimination and placing into the msg struct was productive or an error occurred. In the while loop block, there is an if-assemble. The if-block of the build handles the error if bRet ended up -one. The else-block of the construct has the TranslateMessage, and the DispatchMessage capabilities. Every single of these features employs the message in the msg struct.

The Window Course Method
One particular process can serve far more than one window, but the windows have to be of the exact same class. If a treatment is serving 1 window, it indicates that window is on your own in its class.

A window method really should not disregard a message. If it does not process a message, it need to deliver the message to the DefWindowProc treatment for default processing. In order to do this, the window method calls the default DefWindowProc process, which performs a default action and returns a message consequence. DefWindowProc is a predefined operate that would give a default processing to what the window course method does not do.
 
The Windows API Volumes
Individuals of us who write (publish) for the Internet, publish for funds. We get our earnings via the commercials you see on our web pages like this one. So please, do click on the advertisements on my pages to know what my partners are advertising. In that way they spend me on your behalf, for advertising their products. If you do not click on the ads of the Internet content articles, they will not pay out us. I know you are acquiring the stuff free, but do click the ads to permit us proceed to write. Many thanks.

We have observed much in this portion of the collection. Permit us get a break right here and continue in the subsequent portion.

Chrys

To arrive at any of the parts of this series, just kind the corresponding title down below in the Search Box of this page and click Research (use menu if offered):

Finding to know Windows
What is a Microsoft Window?
Principles of Window Classes
Window Procedure Essentials
Message Essentials for Window Course Procedure
Fundamentals of Message Managing in Windows
Creating Window Essentials
Basic Coding of Window Class Method
Your initial Window
 

Written by Chrys

The Best Practices For Developing Android Mobile Applications

ANDROID OVERVIEW

A platform for mobile device that includes an operating system, middleware and key applications. The Android Software development kit provides all the necessary API tools that help developing applications on the Android platform using the Java programming language.

ANDROID APP FEATURES

Android is featured with a rich development environment, a rich application framework, a virtual machine optimized for mobile devices, an integrated browser with optimized graphics and other hardware dependent features like camera, GPS, compass, Bluetooth and wifi.

CUSTOM ANDROID MOBILE APPLICATION DEVELOPMENT OVERVIEW

With the increase in the number of Android based smart phones, the number of applications in the Android market has shown a tremendous increase, this maybe because of the popularity of the OS, or the ease in usability or the intuitive UI of the application.

An Android mobile application is said to live in its own happy world;

Every Android mobile application runs in its own Linux Process, the process is initiated when any one of the code is triggered to be executed and this is turned off when the system no longer requires the code to be executed. Each Android mobile application process has its own Virtual machine, which means it has its own code which runs in isolation without affecting the code of any other application, thus providing the user to use multiple applications at a time on his Android smart phone.

By Providing an open development platform, Android provides the developers an opportunity to experiment and build highly creative applications, as the developers can take an advantage of the device hardware’s, set alarms, add notifications and use the location services enabling them to experiment with the OS.The application architecture simplifies the reuse of components, a application can publish its capabilities and any application can make use of these capabilities. This also allows users to reuse their application components.

BEST PRACTICES FOR CUSTOM ANDROID MOBILE APPLICATION DEVELOPMENT

Developing applications for the mobile in itself is a challenge when compared to developing web pages and web applications for the typical desktop web browser.

For a developer to develop a successful android mobile application, it helps when he keeps in mind; to use a valid markup DOCTYPE which suits the mobile device, the proper use of a Viewport Meta data to resize the data along with a vertical layout which provides the user with a convenient usability option.

In order to come out with the best Android mobile application results the developer needs to follow a set of do’s and don’ts as follows:

The developer should avoid small font size rigid positioned layouts.

Avoid porting from different UI platforms.

Android icon guidelines must be followed.

The D pad and the trackball must be in sync with the application

Efficient management of the activity stack is a must.

PAYODA AND ANDROID MOBILE APPLICATION DEVELOPMENT

The android mobile application developers here at Payoda have understood the need of the hour after experiencing the intense competition and demand for android mobile applications in the market, and established itself with a few of the best android developers who have understood the basics of android mobile application development and have been successful endlessly resulting in partnership with a bunch of happy clients all over the globe.

We have been successful in creating custom application development for Android, which includes both office and business applications with video streaming facility. We have also proved ourselves in the stream of game application development along with social networking applications for android.

For more information, contact the Mobile Application Development experts at Payoda Technologies. You can find them online at www.payoda.com, email them at info@payoda.com, or call them at +1 (212) 400 7541

Written by Payoda

More Application Articles