Red de conocimiento informático - Problemas con los teléfonos móviles - Código fuente de audio Vc6.0

Código fuente de audio Vc6.0

//Archivo de encabezado//

Página principal

#Definir CM_FILE_SAVEAS 9072

#Definir CM_FILE_EXIT 9071

#Definir CM_FILE_OPEN 9070

#Definición CM _Acerca de 9069

//Archivo de programa principal//

Sitio web principal

/******** * ********************************************/

# include ltwindows.h gt

#Comments hdrstop

#Include "Main.h"

carácter estático g _ nombre de clase SZ[] = " mywindow class ";

STATIC HINSTANCE g_hInst = NULL

# define IDC_MAIN_TEXT 1001

BOOL cargar archivo (HWND hEdit, LPSTR pszFileName)

{

Procesar hFile

BOOL bSuccess = FALSE

hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL,

OPEN_EXISTING, 0, 0);

if (hFile! = valor de identificador no válido)

{

DWORD dwFileSize

dwFileSize = GetFileSize(hFile , NULL);

if(dwFileSize!= 0xFFFFFFFF)

{

LPSTR pszFileText

pszFileText =(LPSTR)global alloc( GPTR, tamaño de archivo dw 1);

if(pszFileText!=null)

{

DWORD dwRead

if(ReadFile(hFile , pszFileText, dwFileSize, ampdwRead, NULL))

{

pszFileText[dw size]= 0; //Terminador nulo

if(SetWindowText(hEdit, pszFileText))

b éxito = true; //¡Éxito!

}

global libre(pszFileText);

}

}

cerrar identificador(hFile);

}

Devuelve b correctamente

}

Archivo guardado BOOL (HWND hEdit, LPSTR pszFileName)

{

Procesando hFile

BOOL bSuccess = FALSE

hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, 0,

CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);

if (hFile! = valor de identificador no válido)<

/p>

{

DWORD dwTextLength

dw textlength = GetWindowTextLength(hEdit);

if(dwTextLength gt; 0)//Sin texto No necesito molestarme.

{

LPSTR pszText

pszText =(LPSTR)global alloc(GPTR, dwTextLength 1);

if(pszText!= Vacío)

{

if(GetWindowText(hEdit, pszText, dwTextLength 1))

{

DWORD dwWritten

if(WriteFile(hFile, pszText, dwTextLength, ampdwWritten, NULL))

b éxito = verdadero

}

global free(pszText) ;

}

}

cerrar identificador(hFile);

}

Devolver b exitosamente;

}

BOOL DoFileOpenSave(HWND hwnd, BOOL bSave)

{

OPENFILENAME ofn

char SZ nombre de archivo [MAX_PATH];

memoria cero(amp;ofn,sizeof(ofn));

nombre de archivo SZ[0]= 0;

ofn. = sizeof(ofn);

ofn.hwndOwner = hwnd

ofn.lpstrFilter = "Archivo de texto (*.txt)\0*. Todos los archivos (*.*) \0 *.*\0\0";

ofn.lpstrFile = szFileName

ofn.nMaxFile = MAX _ PATH

ofn.lpstrDefExt = " txt

if(bsave)

{

ofn.flags = OFN_explorer|OFN_path debe existir|OFN_hide readonly|

OFN _ aviso de sobrescritura;

if(getsave filename(amp; ofn))

{

if (!SaveFile(GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))

{

MessageBox(hwnd, "Error al guardar el archivo. ", "Error",

MB_OK | MB_signo de exclamación);

Devuelve FALSO

}

}

}

Otro

{

ofn.

flags = OFN _Explorer | OFN _file debe existir | OFN _hide readonly;

if(getopen filename(& ofn))

{

if (!LoadFile( GetDlgItem(hwnd, IDC_MAIN_TEXT), szFileName))

{

MessageBox(hwnd, "Error al cargar el archivo.

", "Error",

MB_OK | MB_signo de exclamación);

Devuelve FALSO

}

}

}

Devuelve TRUE

}

Devolución de llamada LRESULT WndProc(HWND hwnd, mensaje UINT, WPARAM wParam, LPARAM lParam)

{

Cambiar (mensaje)

{

Caso WM_CREATE:

CreateWindow("EDITAR ","",

p >

WS_CHILD | WS_VISIBLE | WS_HSCROLL | ES_MULTILINE |

ES_WANTRETURN,

CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,

hwnd IDC_MAIN_TEXT, g_hInst, NULL);

SendDlgItemMessage(hwnd, IDC_MAIN_TEXT, WM_SETFONT,

(WPARAM)GetStockObject(DEFAULT _ GUI _ FONT ),MAKELPARAM(TRUE,0));

Romper;

Caso WM_SIZE:

if (wParam!= TAMAÑO_minimize)

MoveWindow(GetDlgItem(hwnd, IDC_MAIN_TEXT), 0, 0, LOWORD(lParam),

HIWORD(lParam), TRUE

Romper

Caso WM_SETFOCUS:

SetFocus( GetDlgItem(hwnd, IDC_MAIN_TEXT));

Break;

Caso WM_COMMAND:

Switch(lowword(wParam))

{

Caso CM_FILE_OPEN:

DoFileOpenSave(hwnd, FALSE);

Romper;

Caso CM_FILE_SAVEAS:

DoFileOpenSave (hwnd, TRUE);

Interrupción;

Caso CM_FILE_EXIT:

p>

PostMessage(hwnd, WM_CLOSE, 0, 0); p>

Break;

Caso CM_About:

MessageBox(NULL, "Editor de archivos de Windows! \nUsar API Win32","Acerca de...", 0);

}

Interrupción;

Caso WM_CLOSE:

destruir ventana(hwnd);

Break;

Caso WM_DESTROY:

PostQuitMessage(0);

Break;

Valor predeterminado:

Devuelve DefWindowProc(hwnd, Message, wParam, lParam);

}

Devuelve 0;

}

int WINAPI WinMain(