Friday, July 30, 2010

Dialog box for further study



We will further study this course in the dialog box. In particular, we will explore how the dialog box as the input device. If you learn a lesson, it will find an example of this lesson is only a small amount of change, that is, the dialog window of our subsidiary to the main window. In addition, we also study the use of common dialog boxes.

Theory:

The dialog box as an input device to use is really very simple, you create the main window, you just call the function CreatedialogParam or DialogBoxParam on it, before a function so long as the process in the dialog box handler can handle the message , which you must insert a paragraph in the message loop function IsDialogMessage call it logic to handle the keyboard keys. Because these two are relatively easy to program segment, we would not Xiangjie. You can download and study carefully.

Here we discuss the common dialog box. WINDOWS have been ready for your pre-defined dialog box class, you can put on the use of these common dialog boxes available to users with a unified interface. They include: open the file, print, choose colors, fonts, and searching. You should try to use them. To deal with these dialog code comdlg32.dll, in order to in your application to use them, you must link library files in the link stage comdlg32.lib. Then you can call one of the correlation function. Open File common dialog box for the function called GetOpenFileName, "Save as ..." dialog box for the GetSaveFileName, print common dialog box is PrintDlg, etc.. Each of these functions takes a pointer to point to a structure parameter, you can refer to the WIN32 API manual for detailed information, this lesson I will explain the creation and use of open file dialog box.
Here is the prototype of the Open dialog box function GetOpenFileName:

GetOpenFileName proto lpofn: DWORD
You can see that the function has only one parameter, that is, a pointer pointing to OPENFILENAME structure. When the user selects a file and open, the function returns TRUE, otherwise returns FALSE. Next we look at the definition of structure OPENFILENAME:

OPENFILENAME STRUCT
lStructSize DWORD?
hwndOwner HWND?
hInstance HINSTANCE?
lpstrFilter LPCSTR?
lpstrCustomFilter LPSTR?
nMaxCustFilter DWORD?
nFilterIndex DWORD?
lpstrFile LPSTR?
nMaxFile DWORD?
lpstrFileTitle LPSTR?
nMaxFileTitle DWORD?
lpstrInitialDir LPCSTR?
lpstrTitle LPCSTR?
Flags DWORD?
nFileOffset WORD?
nFileExtension WORD?
lpstrDefExt LPCSTR?
lCustData LPARAM?
lpfnHook DWORD?
lpTemplateName LPCSTR?
OPENFILENAME ENDS
Well, let us look at the structure in the common meaning of members:

lStructSize structure OPENFILENAME size.
hwndOwner Open dialog box has a handle of the window.
hInstance has the file open dialog application instance handle.
lpstrFilter to NULL at the end of one or more wildcard. Wildcards are in pairs, the first part of description, the last part is the wildcard format, such as:
FilterString db "All Files (*.*)", 0, "*.*", 0
db "Text Files (*. txt)", 0, "*. txt", 0,0
Note: Only the second part of each pair is required to filter WINDOWS selected files, and the other after the part you must place a 0 to indicate the end of the string.

nFilterIndex open file dialog box to specify when the first open string with the filter, the index is counted from a beginning, that is a wildcard pattern of the index is 1, the second is 2, for example, the example above If specified the value of 2, then the default display mode is string "*. txt".
lpstrFile need to open the file name of the address, the name will appear in the Open File dialog box, edit control, the buffer can not exceed 260 characters long, when the user opens the file, the buffer contains all the files path name, you can extract from the buffer you need a path or file name and other information.
nMaxFile lpstrFile size.
lpstrTitle point dialog title string.
Flags mark the decision of the dialog box determines the style and features.
nFileOffset the user opens a file, the value is the full path name of the file name points to the index of first character. For example: If the full path name "c: windowssystemlz32.dll", then the value is 18.
nFileExtension the user opens a file, the value is the full path name pointing to a file extension of the first character of the index.


Examples:
The following example, we have demonstrated that when the user selects "File-> Open", it will pop up a dialog box to open the file, when the user selects a file to open, it will pop up a dialog box, told to open the file full path name, file name and file extension.
.386
. Model flat, stdcall
option casemap: none
WinMain proto: DWORD,: DWORD,: DWORD,: DWORD
include masm32includewindows.inc
include masm32includeuser32.inc
include masm32includekernel32.inc
include masm32includecomdlg32.inc
includelib masm32libuser32.lib
includelib masm32libkernel32.lib
includelib masm32libcomdlg32.lib

. Const
IDM_OPEN equ 1
IDM_EX99v equ 2
MAXSIZE equ 260
OUTPUTSIZE equ 512

. Data
ClassName db "SimpleWinClass", 0
AppName db "Our Main Window", 0
MenuName db "FirstMenu", 0
ofn OPENFILENAME <>
FilterString db "All Files", 0 ,"*.*", 0
db "Text Files", 0, "*. txt", 0,0
buffer db MAXSIZE dup (0)
OurTitle db "-= Our First Open File Dialog Box =-: Choose the file to open", 0
FullPathName db "The Full Filename with Path is:", 0
FullName db "The Filename is:", 0
ExtensionName db "The Extension is:", 0
OutputString db OUTPUTSIZE dup (0)
CrLf db 0Dh, 0Ah, 0

. Data?
hInstance HINSTANCE?
CommandLine LPSTR?

. 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
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, WS_EX_CLIENTEDGE, ADDR ClassName, ADDR AppName,
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
CW_USEDEFAULT, 300,200, 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 TranslateMessage, ADDR msg
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_OPEN
mov ofn.lStructSize, SIZEOF ofn
push hWnd
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter, OFFSET FilterString
mov ofn.lpstrFile, OFFSET buffer
mov ofn.nMaxFile, MAXSIZE
mov ofn.Flags, OFN_FILEMUSTEXIST or
OFN_PATHMUSTEXIST or OFN_LONGNAMES or
OFN_EXPLORER or OFN_HIDEREADONLY
mov ofn.lpstrTitle, OFFSET OurTitle
invoke GetOpenFileName, ADDR ofn
. If eax == TRUE
invoke lstrcat, offset OutputString, OFFSET FullPathName
invoke lstrcat, offset OutputString, ofn.lpstrFile
invoke lstrcat, offset OutputString, offset CrLf
invoke lstrcat, offset OutputString, offset FullName
mov eax, ofn.lpstrFile
push ebx
xor ebx, ebx
mov bx, ofn.nFileOffset
add eax, ebx
pop ebx
invoke lstrcat, offset OutputString, eax
invoke lstrcat, offset OutputString, offset CrLf
invoke lstrcat, offset OutputString, offset ExtensionName
mov eax, ofn.lpstrFile
push ebx
xor ebx, ebx
mov bx, ofn.nFileExtension
add eax, ebx
pop ebx
invoke lstrcat, offset OutputString, eax
invoke MessageBox, hWnd, OFFSET OutputString, ADDR AppName, MB_OK
invoke RtlZeroMemory, offset OutputString, OUTPUTSIZE
. Endif
. Else
invoke DestroyWindow, hWnd
. Endif
. ELSE
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
. ENDIF
xor eax, eax
ret
WndProc endp
end start


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

Analysis:
mov ofn.lStructSize, SIZEOF ofn
push hWnd
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
We are here to fill structure of the members of the OPENFILENAME ofn variables.

mov ofn.lpstrFilter, OFFSET FilterString

Here FilterString the file filter string address, we specify the filter string is as follows:

FilterString db "All Files", 0 ,"*.*", 0
db "Text Files", 0, "*. txt", 0,0
Note: All model series are paired, one a description of the latter is the real model, sub-office "*.*" and "*. txt" is used to find matching WIONDOWS want to open documents. When can we can specify any mode, but do not forget to add 0 to represent the end of the string has ended, or your operation may be unstable in the dialog box.
mov ofn.lpstrFile, OFFSET buffer
mov ofn.nMaxFile, MAXSIZE

Here is the address of the buffer into the structure, the size must be set. Since we are free to edit the information returned in the buffer.

mov ofn.Flags, OFN_FILEMUSTEXIST or
OFN_PATHMUSTEXIST or OFN_LONGNAMES or
OFN_EXPLORER or OFN_HIDEREADONLY

Flags in the dialog box into the style and property value.
One OFN_FILEMUSTEXIST and OFN_PATHMUSTEXIST require the user to the edit control in the Open dialog box, enter the file name or path name must exist.
OFN_LONGNAMES tell the dialog box display long file names.
OFN_EXPLORER told WINDOWS dialog must look like Explorer.
OFN_HIDEREADONLY designated read-only files do not show (even if it is the extension of the filter mode).
In addition, there are many other flags, you can refer to the WIN32 API manual.

mov ofn.lpstrTitle, OFFSET OurTitle

Open File dialog box specify the title name.

invoke GetOpenFileName, ADDR ofn

GetOpenFileName function call, and pass a pointer to point to structure ofn.
At this time, open the file dialog box that come, GetOpenFileName function to wait until after the user selects a file will be returned, or when the user presses the CANCEL button or close the dialog box.
When the user selects to open a file, the function returns TRUE, otherwise returns FALSE.

. If eax == TRUE
invoke lstrcat, offset OutputString, OFFSET FullPathName
invoke lstrcat, offset OutputString, ofn.lpstrFile
invoke lstrcat, offset OutputString, offset CrLf
invoke lstrcat, offset OutputString, offset FullName

When the user selects to open a file, we will display a dialog box in a string, we first give OutputString variables to allocate memory, then call the PAI function lstrcat, with all the strings together, in order for these strings branches shows that we must add a line break the back of each string.

mov eax, ofn.lpstrFile
push ebx
xor ebx, ebx
mov bx, ofn.nFileOffset
add eax, ebx
pop ebx
invoke lstrcat, offset OutputString, eax

Above these lines may require some explanation. nFileOffset value equal to the full path name to open the file in the file name's first character in the index, as nFileOffset is a WORD type variable, and lpstrFile is a DWORD pointer shape, so we will have to deposit a conversion to nFileOffset the bottom byte ebx register, and then add to the eax register to get a pointer type DWORD.

invoke MessageBox, hWnd, OFFSET OutputString, ADDR AppName, MB_OK

We are in the dialog box display the string.

invoke RtlZerolMemory, offset OutputString, OUTPUTSIZE

In order to correctly display the next time, we must clear the buffer, we call the function RtlZerolMemory to do it.







Recommended links:



Thunder's Humor: The Content Of Our Nearly 100% Genuine



CONVERTING mov to wmv



Compare Delphi



E-cology in the Pan Micro Series 31



C + + compiler on the template of separate answers to questions



video FILE converter



Covert Surveillance COMMENTS



.mkv file



FMCG distributors and how the difficulties faced by self-improvement



Overcome stage fright interview the 10 candidates recruited nirvana



CPU chip with independent intellectual property rights through the acceptance of Godson 2E



PhotoShop New Tricks: Paintings In Paintings



Format Ts



Thursday, July 22, 2010

"Random eight-digit" Beware of your U disk



The virus a "hijacking image" technology, the virus running, will generate a random numbers and letters composed by the 8-bit name of the virus process and try to close the variety of anti-virus software, firewalls and security tools to process, making an extremely difficult virus. Virus in the root directory of each partition generated Autorun.inf and random 8-bit EXE, the user double-click the hard drive to activate the virus. The virus also through U disk, MP3, mobile hard drives and other removable storage spread, spread very rapidly.

Image hijacking "technology that is currently widely used virus virus technology. Viruses using the technology of some antivirus and security software screen, when the computer user to perform the procedure to be shielded, the virus can lead to the implementation of the goals is empty, this to evade anti-virus software to kill.

According to reports, "random 8-digit" virus Trojan-like virus, using Delphi language, through the UPX packers processing tools. Virus running, make the system run slower, and the virus will try to close the variety of anti-virus software and firewall processes, so that users can not open the antivirus software and virus database can not be upgraded. Virus will shield the Registry Editor and msconfig other variety of security tools, to create difficulties for users to manually killing the virus. The virus will be downloaded from the specified URL Trojan variety of online games can be stolen, including World of Warcraft, Legend of the world, journey, including several online game account and password, games for the network equipment constitutes a significant threat.

Prevention and treatment measures:

1. Protect your U disk, MP3, mobile hard drives and other removable storage usage, when the external U disk access computer, please do not rush to double-click to open, be sure to read the anti-virus treatment, suggested a U disk virus immune function antivirus software, such as U-disk shield KV2007 unique technology that can drive the virus immune to all U U disk by double-clicking to run.

2. Lay the patch to the system, especially in MS06-014 and MS07-17 The two patches, most of the pages currently Trojans are two holes through the invasion to the computers inside.

3. To update anti-virus software virus database, so that regular upgrades, regular anti-virus.

4. Install the software to go to regular website, avoid software installation package is bundled into the Trojan.







Recommended links:



New worm Floodnet (cute) little files



Convert mp3 to m4a



mkv FILES



Mpeg4 To Avi



Win32 Debug API part III



Infomation Games Sports



Photoshop Pumping Effect Of The New Line Of Thinking



In the Title bar of an art form



Shop Dictionaries EDUCATION



Storage Source Editors



Wang Zhuo: LANDesk Chinese "master" (1)



On-site supervision evaluation [3]



Real Player Format



Storage Debugging



Secret benefits to Customers Shi Xiaoen



Wednesday, July 7, 2010

WMA to MP3 Converter

WMA to MP3 Converter is a DRM protected audio and music conversion software which can convert protected iTunes M4A, M4P Files, DRM WMA, DRM protected AAC to plain Audio MP3, WAV, WMA files ready for use on any computers or mobile music devices such as iPod, iPhone, PSP, Zune, cell phone, MP3 player and car MP3 CD players, etc.

This WMA to MP3 Converter uses the Virtual CD burning technology which emulates the whole workflow of burning music to normal CD-R/RW disc: CD ripping, CD burning, MP3 encoding are automatic and with the fastest speed. Its ability to convert DRM protected music files into regular MP3 files makes it a perfect solution for people who purchase their music online but have compatibility issues with their MP3 player.




Recommand Link:



Youtube to MPEG Shareware



Flv To 3gp Converter



M2ts to mkv



Youtube To RMVB Utility



Moyea Video to iPod Converter



Christmasgift DVD Creator



For you Flash Tools



Recommend Reference Tools



avi to mpeg converter



CATALOGS Icon Tools



Converter flv to mp3



Christmas-Idea DVD To PS3 PDA



Lohan IPhone Converter