Monday, July 26, 2010

Menu


This lesson we will add our application a menu.

Theory:

WINDOWS menu can be said one of the most important element. With it, users can easily select the action command. Users just read it all the menu items you can understand about the application provides function, but also immediate action, not to read the manual. Precisely because of the menu gives the user a kind of convenient way, so you join in the application menu should comply with general standards. For example: the first two menu items are usually "File" and "Edit", the last is the "Help", you can This is inserted in the middle you want to define the menu item. If you are running the menu command will pop up a dialog box, then the menu item should omit the symbol (...). menu after adding a resource, in addition to the menu but also have Others, like the dialog box, string, icon, bitmap resources. In the linker will link resources to the executable program to the end of our implementation of the program on both machines, including the resources they command. You can any text editor to write the script file, the file you can specify the resources shown by the appearance and some other properties. of course, more intuitive method is to use the resource editor, resource editor are usually packaged in compiling environment, such as Visual C + +, Borland C + + and so on with the resource editor. we can define as follows a menu of resources:

MyMenu MENU
(
[Menu list here]
)
This and the C language is very similar to the definition of structure. MyMenu similar variable is defined, and is similar to the keyword MENU. Of course, you can use another approach, that is to use BEGIN and END instead of curly braces, this and the same style PASCAL language.
List of items in the menu is long list of MENU99vEM and POPUP statement. MENU99vEM defines a menu item, when selected, will not activate the dialog box. Its syntax is as follows:
MENU99vEM "& text", ID [, options]
It begins by the keyword MENU99vEM, followed by the MENU99vEM menu item after the name refers to the string, the symbol "&" character after the first draw will be taken off line, it is the menu item shortcuts. ID's role when the menu is selected, WINDOWS message processing used to distinguish between menu items. There is no doubt, ID number must be unique. options have the following properties available:
GRAYED on behalf of the menu item in the non-active state, that is when it is selected will not generate WM_COMMAND messages. The menu displayed in gray.
INACTIVE The menu item is on behalf of non-activated state, that is when it is selected will not generate WM_COMMAND messages. The menu to the normal colors.
MENUBREAK the menu item and the following menu items will be displayed in a new column. (Translator's Note: more difficult to describe, please do experiment.)
HELP in the menu item and then right-aligned menu items. (Translator's Note: I compiled WINDOWS2000 menu items have the logo, the sign did not seem to work)
You can use these flags alone, or together, can put them. INACTIVE and GRAYED course can not be used. POPUP the syntax is as follows:
POPUP "& text" [, options]
(
[Menu list]
)
POPUP defines a menu item when the menu item is selected a sub-menu will pop up. In addition there is a special type of MENU99vEM statement MENU99vEM SEPARATOR, it said the location of the menu item draw a dividing line. End the definition of the menu, you can use the script in the program resources in the definition of the menu. You can program the two places (or called in two ways) to use them:
Structure in members of lpszMenuName WNDCLASSEX in. For example, you have a menu "FirstMenu", you can press the following ways to contact it to your window:
. DATA
MenuName db "FirstMenu", 0
...........................
...........................
. CODE
...........................
mov wc.lpszMenuName, OFFSET MenuName
...........................
Menu specified in the CreateWindowEx function handle:
. DATA
MenuName db "FirstMenu", 0
hMenu HMENU?
...........................
...........................
. CODE
...........................
invoke LoadMenu, hInst, OFFSET MenuName
mov hMenu, eax
invoke CreateWindowEx, NULL, OFFSET ClsName,
OFFSET Caption, WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL,
hMenu,
hInst,
NULL
...........................
You may ask, What is the difference between the two with it? When you use the first method, because the class specified in the window, so all classes derived by the window, the window will have the same menu. If you want to derive from the same class have different menu window to use it in the second method, the method specified by the menu CreateWindowEx function will "cover" WNDCLASSEX specified in the menu structure. Next we look at when the user selects a menu item, how it is to inform WINDOWS windows process: When the user selects a menu item, WINDOWS window procedure will receive a WM_COMMAND message, pass the parameters come in the bottom byte of wParam contains a menu item ID. Well, that is on the menu item above all, here we come to practice.
Examples:
The first example shows a menu item specifies the first method:
.386
. Model flat, stdcall
option casemap: none

WinMain proto: DWORD,: DWORD,: DWORD,: DWORD

include masm32includewindows.inc
include masm32includeuser32.inc
include masm32includekernel32.inc
includelib masm32libuser32.lib
includelib masm32libkernel32.lib

. Data
ClassName db "SimpleWinClass", 0
AppName db "Our First Window", 0
MenuName db "FirstMenu", 0; The name of our menu in the resource file.
Test_string db "You selected Test menu item", 0
Hello_string db "Hello, my friend", 0
Goodbye_string db "See you again, bye", 0

. Data?
hInstance HINSTANCE?
CommandLine LPSTR?

. Const
IDM_TEST equ 1; Menu IDs
IDM_HELLO equ 2
IDM_GOODBYE equ 3
IDM_EX99v equ 4

. Code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke GetCommandLine
mov CommandLine, eax
invoke WinMain, hInstance, NULL, CommandLine, SW_SHOWDEFAULT
invoke ExitProcess, eax

WinMain proc hInst: HINSTANCE, hPrevInst: HINSTANCE, CmdLine: LPSTR, CmdShow: DWORD
LOCAL wc: WNDCLASSEX
LOCAL msg: MSG
LOCAL hwnd: HWND
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInst
pop wc.hInstance
mov wc.hbrBackground, COLOR_WINDOW +1
mov wc.lpszMenuName, OFFSET MenuName; Put our menu name here
mov wc.lpszClassName, OFFSET ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx, NULL, ADDR ClassName, ADDR AppName,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL,
hInst, NULL
mov hwnd, eax
invoke ShowWindow, hwnd, SW_SHOWNORMAL
invoke UpdateWindow, hwnd
. WHILE TRUE
invoke GetMessage, ADDR msg, NULL, 0,0
. BREAK. IF (! Eax)
invoke DispatchMessage, ADDR msg
. ENDW
mov eax, msg.wParam
ret
WinMain endp

WndProc proc hWnd: HWND, uMsg: UINT, wParam: WPARAM, lParam: LPARAM
. IF uMsg == WM_DESTROY
invoke PostQuitMessage, NULL
. ELSEIF uMsg == WM_COMMAND
mov eax, wParam
. IF ax == IDM_TEST
invoke MessageBox, NULL, ADDR Test_string, OFFSET AppName, MB_OK
. ELSEIF ax == IDM_HELLO
invoke MessageBox, NULL, ADDR Hello_string, OFFSET AppName, MB_OK
. ELSEIF ax == IDM_GOODBYE
invoke MessageBox, NULL, ADDR Goodbye_string, OFFSET AppName, MB_OK
. ELSE
invoke DestroyWindow, hWnd
. ENDIF
. ELSE
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
. ENDIF
xor eax, eax
ret
WndProc endp
end start
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only

Menu.rc
backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only
# Define IDM_TEST 1
# Define IDM_HELLO 2
# Define IDM_GOODBYE 3
# Define IDM_EX99v 4

FirstMenu MENU
(
POPUP "& PopUp"
(
MENU99vEM "& Say Hello", IDM_HELLO
MENU99vEM "Say & GoodBye", IDM_GOODBYE
MENU99vEM SEPARATOR
MENU99vEM "E & xit", IDM_EX99v
)
MENU99vEM "& Test", IDM_TEST
)


Analysis:
Let's analyze the resource file:

# Define IDM_TEST 1 / bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware equal to IDM_TEST equ 1 * /
# Define IDM_HELLO 2
# Define IDM_GOODBYE 3
# Define IDM_EX99v 4

The above lines define the menu item ID. As long as attention to the menu item ID number must be unique, you can ID number to any value.
FirstMenu MENU

The definition of the menu with MENU keyword.

POPUP "& PopUp"
(
MENU99vEM "& Say Hello", IDM_HELLO
MENU99vEM "Say & GoodBye", IDM_GOODBYE
MENU99vEM SEPARATOR
MENU99vEM "E & xit", IDM_EX99v
)

There are four menu items to define a sub-menu, in which the third menu item is a separator.

MENU99vEM "& Test", IDM_TEST

A definition of the main menu. Let us look at the source code.


MenuName db "FirstMenu", 0; The name of our menu in the resource file.
Test_string db "You selected Test menu item", 0
Hello_string db "Hello, my friend", 0
Goodbye_string db "See you again, bye", 0

MenuName resource file is specified in the name of the menu. Because the script file you can define as many menus, so before use must be specified that you want to use one, the next line is displayed in the selected menu item strings in the relevant dialog box.

IDM_TEST equ 1; Menu IDs
IDM_HELLO equ 2
IDM_GOODBYE equ 3
IDM_EX99v equ 4

WINDOWS define the window used in the course of the menu item ID. These values must be the same script file.
. ELSEIF uMsg == WM_COMMAND
mov eax, wParam
. IF ax == IDM_TEST
invoke MessageBox, NULL, ADDR Test_string, OFFSET AppName, MB_OK
. ELSEIF ax == IDM_HELLO
invoke MessageBox, NULL, ADDR Hello_string, OFFSET AppName, MB_OK
. ELSEIF ax == IDM_GOODBYE
invoke MessageBox, NULL, ADDR Goodbye_string, OFFSET AppName, MB_OK
. ELSE
invoke DestroyWindow, hWnd
. ENDIF

In this process, we deal with WM_COMMAND window message. When the user selects a menu item, the menu item's ID into the parameters were also sent to the WINDOWS wParam window procedure, we save it to the eax register in order to pre-defined menu items and compare with ID. The first three cases, when we select the Test, Say Hello, Say GoodBye menu items, it will pop up a dialog box which displays a related string, select the Exit menu item, we will call the function DestroyWindow, where the parameters are We handle of the window, thus destroying the window. As you can see, through a window class name is specified in the menu to an application method to generate a menu is simple and intuitive. Outside in this method you can use another method, which is the same resource file, source file, only a few changes, these changes are as follows:


. Data?
hInstance HINSTANCE?
CommandLine LPSTR?
hMenu HMENU?; handle of our menu

Define a variable to hold the handle of our menu, then:
invoke LoadMenu, hInst, OFFSET MenuName
mov hMenu, eax
INVOKE CreateWindowEx, NULL, ADDR ClassName, ADDR AppName,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, hMenu,
hInst, NULL

Call LoadMenu function, which requires an instance handle and the menu name string, calls the results back to point to the menu handle, and then passed to the function just returns the menu handle CreateWindowEx on it.






Recommended links:



Ophone To Support The TD-based Chips Is Still The Bottleneck



Unicom frankly difficult to govern without legal constraint SP is critical violations



converting avi to Wmv



MTS to vob



Dealer how to identify the manufacturer with the money trap?



dvd audio ripper



Picked Games And Entertainment



Rising gods: a small pinch frame, more than busy for!



DreamWeaver, classic 50-Q (9)



If Tomorrow Is The Last Night Of IPv4



Mkv To Vob



Review Dictionaries EDUCATION



Photoshop retouching images (8) to adjust brightness



Saturday, July 24, 2010

Again on j2me progress bar and thread model


Abstract:

This article is a "j2me progress bar and the threaded model" of a text added (later referred to as the original, not seen the proposal to look at).

Discussed the original thread model used in the inadequacies and shortcomings made for her new ways to improve it and give the improved implementation. UI part because the text has flexible scalability, without change.

Copyright Statement:

This paper also published in www.j2medev.com and my Blog (blog.csdn.net / alikeboy), if needed reproduced in three ways: 1) contact me and with my consent; 2) and www.j2medev.com have Articles in co-operation agreement 3) Rss polymerization by my Blog. Also need to full text is reproduced (including articles in the head), not out of context.

Body:

Foreground and background threads to interact with UI
Model of the original text, is a front for ProgressGaugeUI independent model with a background thread. When this design on maximum simplification of the complexity of communication, in fact, the model is a single direction (from BackgroundTask to PGUI communication). In accordance with the requirements of this model, programmers Override BackgroundTask of runTask () method, the obligation of regular training to check the operation of reception PGUI and made under such circumstances to reflect. This model fully believe that a background thread, will it respond to the user the right to cancel an order to a background thread, if the background thread does not respond to the trouble (such as access to a very expensive network connection), then the user is no use trying to cancel , the program will be a temporary deadlock, until the background thread have the time to check the front of the state. And in reality, in the end when the last query, what is the frequency of the problem. In the code snippet in excess of such code will affect the normal process of understanding.

This sequence from the following chart, you can see this particular process:



We need a way for us to force the end of the Task. This method provided by the background thread itself, named called cancel (). Of course there is no one way to force an immediate end to the thread (there was, because of security issues has been canceled). So cancel () method often by closing the resources (a connection, a stream, etc.) to force runTask abnormal interruption, runTask obligated under their agreement and immediately exit to capture these anomalies. A graph worth a thousand words, let us look at the process of this method.



Clearly, the key lies in front of the thread on the background thread for the callback, so that you can solve the problem. But the new questions, and this forced us to foreground and background threads together closely coupled in (because callback Well). Can achieve both front UI callback avoiding tight coupling with the background thread it?

Interface to reduce the coupling by Cancelable
Fortunately, I can use to interface with the door to this.

The previous model is like this:



To reduce the coupling, we build an interface

public interface Cancelable (

/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware

backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only non-blocking in this way should return immediately (if necessary open a new thread)

backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only addition, to avoid repeated calls to this method

backup / bin / bin_old / conf / data / eshow / log / maint / news: 10 / news: 11 / news: 12 / news: 13 / news: 14 / news: 15 / news: 16 / news: 17 / news: 18 / news: 2 / news: 3 / news: 4 / news: 5 / news: 6 / news: 7 / news: 8 / news: 9 / seeds / svn / tasks / tmp / xml2dict-read-only /

public void cancel ();

)

Then join in ProgressObserver support this method

public interface ProgressObserver (

... ...

... ...

/ Bin / boot / dev / etc / home / lib / lost + found / media / misc / mnt / net / opt / proc / root / sbin / selinux / srv / sys / tmp / u01 / usr / var / vmware

backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only set to cancel the callback function when the object Task

backup bin bin_old conf config crawler.tar.gz crawler_bin.tar.gz data eshow eshow_sitemap.html generate.sh google.html google.html.md5 log maint news: 10 news: 11 news: 12 news: 13 news: 14 news: 15 news: 16 news: 17 news: 18 news: 2 news: 3 news: 4 news: 5 news: 6 news: 7 news: 8 news: 9 outboundLinksMgr.sql seeds sitemap.html svn tasks tmp xml2dict-2008.6-tar. gz xml2dict-read-only @ param co

backup / bin / bin_old / conf / data / eshow / log / maint / news: 10 / news: 11 / news: 12 / news: 13 / news: 14 / news: 15 / news: 16 / news: 17 / news: 18 / news: 2 / news: 3 / news: 4 / news: 5 / news: 6 / news: 7 / news: 8 / news: 9 / seeds / svn / tasks / tmp / xml2dict-read-only /

public void setCancelalbeObject (Cancelable co);

)

This allows the user presses the Cancel button, you can be on the Cancelable.cancel () callback. This flexibility greatly enhanced.



New code

The updated code is as follows, in addition to the above model to use, but also on the part of the BUG was corrected, the place will change in different colors. Detailed usage, see comments






Recommended links:



Professional CD Sound RA to CD-R Cloner



CONVERTING avi to mp4



converter mp4 to avi



Youtube FLV Backup + Converter Freeware



Explosion PDA Converter



Alive VIDEO Converter



Avc Player



Wizard Vertical Market Apps



AllRipper DVD to RMVB



China's ENVIRONMENTAL satellite data



Perpetually Cell Phone 3G2 Converter



how TO convert avi to wmv



Storage CARTOONS - Screen Savers



Adobe At The End Of Acquiring, At A Price Well



On The Implementation Of Financial Knowledge In The Use Of



Monday, July 5, 2010

ALLCapture Enterprise

ALLCapture records any screen activity and creates in minutes internet ready screen movies, presentations, software simulations and tutorials! ALLCapture records multiple soundtracks during or after video capture. Users can edit their projects with speech bubbles, text objects and special effects. The intuitive timeline makes the editing process spectacularly easy. Videos can be exported to Flash, EXE, ASF or as video files for DVD, VCD or SVCD.

Good reasons for using ALLCapture:

- Record all screen activity in real-time, even webinars or video conferences.
- Easily edit the captured video and insert captions, notes, special effects, etc.
- Record sound during the capture process or add it conveniently during playback.
- Memory manager for better recording performance.
- Small output size is ideal for e-mail and Internet use. Choose between different output formats including Flash, EXE, ASF, DVD, SVCD and VCD.
- Convert PowerPoint presentations automatically to Flash

ALLCapture records any screen activity in real-time to quickly and easily create software simulations, videos, demos, screencasts and tutorials without any programming language necessary. It's as easy as:
record - edit - export - play



Recommand Link:



Christmas-Idea VCD VOB DAT Copier



Launchers AND Task Managers reviews



WORLDCUP RM to DVD



Best Telephony



Lohan Blackberry Converter



Mpg To Mp4



Christmas-Idea FLV PS3 Deconde



WorldCup DVD To M4V



Graphic CAD evaluation



Movavi PSP Video Suite



convert Mpeg4 to avi



converter flv to 3GP



Converting wav to mp3