Monday, July 12, 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.







Recommand Link:



matroska VIDEO file



Simple Telephony



Youtube To Mobile Phone Products



.mkv FILES



My favorite Seasonal - Screen Savers



Youtube FLV To Psion Shareware



CABLE TV On PC



SuperAVConverter



Premier Genealogy



Youtube Video to Laptops Mixer



mp4 3gp video Converter



Games Sports Report



Christmas-Idea DVD to PS3 PDA



CHRISTMASGIFT RMVB to DVD



flac to mp3



Bluesea XviD Convert



X-Cloner Apple TV Converter



Thursday, December 10, 2009

VQF M3U to VQF

VQF M3U to VQF is an easy-using tool to convert your audio CD to MP3, WAV, WMA and OGG files. Its digital copy gives you perfect copy effect. VQF M3U to VQF adopts advanced LAME Encoder and OGG codec, allowing you to generate various qualities of MP3, WAV, WMA and OGG files. You can edit the Title, Artist, Album, Year, Genre and Comment information into the files you create. Supports free and powerful reading-disc-function. VQF M3U to VQF is also a smart CD player. The user-friendly-interface makes your converting just a button click away. You'll be an expert in no time!
Convert audio files and CD audio tracks to MP3, CD, CDA, CD-R, DVD-Audio, AAC, AC3, ID3, M3U, M4A, M4P, MP3 ID3 Tag, OGG, RA, WAV, WMA, MP2, APE, VQF, MPC, AMR, Midi, WAVE, and RM.

Tuesday, November 17, 2009

Digital CD Midi RA to WAVE Copier


Digital CD Midi RA to WAVE Copier- Convert WAV/MP3 to WMA. Convert MP3 to WAV. Convert WAV/MP3 to WMA. Convert OGG to WAV/MP3. Convert WAV to MP3. Burn your favorite songs to CDs so you can listen them in your home or car stereo CD player. Record sound include line-in, CD, tape, microphone and any input source to WAV, MP3, WMA and OGG files directly.62. Audio Converter quickly and easily converts your audio or video files to WMA, AIFF, Vorbis OGG, Wave, and MP3, CD, CDA, CD-R, DVD-Audio, AAC, AC3, ID3, M3U, M4A, M4P, MP3 ID3 Tag, OGG, RA, WAV, WMA, MP2, APE, VQF, MPC, AMR, Midi, WAVE, and RMformat. Using a clear and intuitive interface, you can convert files individually or in batches plus you have the options to normalize the volume, encode specific portions, or remove silences. The integrated CD ripper features automatic retrieval of disc information using CDDB, and Jitter error correction support. ID3 tags are preserved automatically, and it's possible to name output files by ID3 tags, such as artist name, song title, album title, and so on. Now start converting your audio files!

Monday, October 26, 2009

iPod VQF to OGG

iPod VQF to OGG supports WAV PCM. iPod VQF to OGG supports Compressed WAV (ADPCM, GSM, DSP, A-LAW, U-LAW, ALF2 and others). Support OGG (Ogg Vorbis), G.721, G.723, G.726. Support VOX (Dialogic ADPCM), WMA Windows Media Audio). Support RAW (PCM, A-LAW, U-LAW), CDA (Audio CD Tracks).
Create, encode, decode, and convert various audio files to another format such as MP3, CD, CDA, CD-R, DVD-Audio, AAC, AC3, ID3, M3U, M4A, M4P, MP3 ID3 Tag, OGG, RA, WAV, WMA, MP2, APE, VQF, MPC, AMR, Midi, WAVE, and RM file.

Wednesday, October 21, 2009

PPC to PSP Copier

With PPC to PSP Copier you can easily convert Wave files into MP3 files. PPC to PSP Copier has a very configurable and attractive WinZip style interface with Windows XP looking buttons. You can drag and drop Wave files, then convert them with the same structure of album catalog, eliminate corrupted files and see converted MP3 files in a result list. After that you can even save the list of converted files into an XML or HTML file. Program also works with command line parameters that allow using it in Batch processes to convert huge numbers of files. Highly recommended for all music fans and music studios.
It supports ID3v1,2 tagging that allows you to save and edit song information such as title of a song and album, name of artist, year etc. in MP3, OGG and WMA files. Encode WAV to MP3, OGG, WMA;

Tuesday, October 13, 2009

SuperBurner WMV Converter


SuperBurner WMV Converter fast convert WMV files to all popular video formats such as DVD, VCD, SVCD, AVI, MPEG, WMV, DivX, RM, MOV, MP4, 3GP, 3G2, Xvid, ASF, etc. easily, and convert DVD to audio formats including MP3, WAV, WMA, AAC, AC3, M4A, MP2, OGG, etc. It can support many personal multimedia devices such as PSP, iPod, Zune, iPhone, PDA and MP4 player.

SuperBurner WMV Converter is powerful, easy to use DVD to WMV converter and DVD to WMA converter software which helps you rip and convert DVD to WMV video file formats or extract to WMA audio file formats with excellent quality.

Saturday, October 3, 2009

Digital M4A MP3 to AC3 Converter


Digital M4A MP3 to AC3 Converter - Powerful audio encoder & codec which can convert between MP3 WAV WMA MP4 M4A OGG etc. popular audio formats and extract audio from popular video file formats, such as AVI MPG ASF WMV. ImTOO Audio Encoder provides users an easy way to convert audio files within a few clicks. An easy and completed way for OGG Codec, MP3 Codec, WMA Codec, Besides MP3 WAV WMA, ImTOO Audio Encoder also supports MP4 M4A MP2 OGG APE AAC VQF etc. formats. All conversion processes between these formats are very easy to handle and fast. Digital M4A MP3 to AC3 Converter provides different settings for different audio formats - users can easily get output files as they want. No matter what audio file you want, ImTOO Audio Codec Encoder can do it for you! Supports ID3 tag and batch conversion. Users don't have to think so much, just need a click! Audio converter to convert MP3, WMA, OGG, APE, VQF and WAV from one format to another directly. Support remote free CDDB. Support audio CD auto-detection . Easy-to-use design. Support multiple CD-ROM drives. High speed ripping and conversion. CD ripper to rip CD to MP3, CD, CDA, CD-R, DVD-Audio, AAC, AC3, ID3, M3U, M4A, M4P, MP3 ID3 Tag, OGG, RA, WAV, WMA, MP2, APE, VQF, MPC, AMR, Midi, WAVE, and RM directly,