📄 mme.c
字号:
MessageBox(mme_app.main_hwnd, buffer, "INFO", MB_ICONINFORMATION|MB_OK);
EnableWindow(mme_app.main_hwnd, TRUE);
return;
}
/*-----------------------------------------------------------------*/
static void on_file_goplist()
{
OPENFILENAME of;
char path[32768];
char work[1024];
char *head;
int n;
DWORD gl_mode;
/* initialize */
memset(&of, 0, sizeof(OPENFILENAME));
memset(path, 0, sizeof(path));
of.lStructSize = sizeof(OPENFILENAME);
of.hwndOwner = mme_app.main_hwnd;
of.lpstrFile = path;
of.nMaxFile = sizeof(path);
of.lpstrFilter = mme_app.vfapi.info.cFileType;
of.lpstrInitialDir = mme_app.openpath;
of.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR;
if(GetOpenFileName(&of) == 0){
return;
}
put_openpath(of.lpstrFile);
gl_mode = get_goplist_mode();
put_goplist_mode(2); // NEVER_USE_TIMECODE + SAVE_GL_FILE
head = path + of.nFileOffset;
while( head[0] != '\0' ){
memcpy(work, path, of.nFileOffset);
n = strlen(head) + 1;
if(work[of.nFileOffset-1] == '\0'){
work[of.nFileOffset-1] = '\\';
}
memcpy(work+of.nFileOffset, head, n);
head += n;
create_goplist(&(mme_app.vfapi), work);
}
put_goplist_mode(gl_mode);
return;
}
/*-----------------------------------------------------------------*/
static void on_file_end()
{
SendMessage(mme_app.main_hwnd, WM_CLOSE, 0, 0L);
return;
}
/*-----------------------------------------------------------------*/
static void on_edit_in()
{
if(!set_in_point_mme_project(&(mme_app.project))){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
if(get_in_point_mme_project(&(mme_app.project)) > LONG_MAX){
SendMessage(mme_app.slide_bar, TBM_SETSELSTART, TRUE, LONG_MAX);
}else{
SendMessage(mme_app.slide_bar, TBM_SETSELSTART, TRUE, (LONG)get_in_point_mme_project(&(mme_app.project)));
}
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
return;
}
/*-----------------------------------------------------------------*/
static void on_edit_out()
{
if(!set_out_point_mme_project(&(mme_app.project))){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
if(get_out_point_mme_project(&(mme_app.project)) > LONG_MAX){
SendMessage(mme_app.slide_bar, TBM_SETSELEND, TRUE, LONG_MAX);
}else{
SendMessage(mme_app.slide_bar, TBM_SETSELEND, TRUE, (LONG)get_out_point_mme_project(&(mme_app.project)));
}
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
return;
}
/*-----------------------------------------------------------------*/
static void on_edit_undo()
{
MessageBox(mme_app.main_hwnd, "曇廤 -> 傗傝側偍偟儊僯儏乕偑慖戰偝傟傑偟偨", "僨僶僢僌", MB_OK|MB_ICONINFORMATION);
return;
}
/*-----------------------------------------------------------------*/
static void on_edit_copy()
{
char *p;
const BITMAPINFOHEADER *bih;
if(!OpenClipboard(mme_app.main_hwnd)){
show_error(msg_table[mme_app.lang][MSG_FAILED_TO_OPEN_CLIPBOARD], GetLastError());
return;
}
if(!EmptyClipboard()){
CloseClipboard();
show_error(msg_table[mme_app.lang][MSG_FAILED_TO_GET_CLIPBOARD_OWNERSHIP], GetLastError());
return;
}
bih = get_dib_header_mme_project(&(mme_app.project));
if(mme_app.clipboard != NULL){
GlobalFree(mme_app.clipboard);
}
mme_app.clipboard = GlobalAlloc(GMEM_MOVEABLE, bih->biSize + bih->biSizeImage);
if(mme_app.clipboard == NULL){
CloseClipboard();
show_error(msg_table[mme_app.lang][MSG_NO_ENOUGH_MEMORY], GetLastError());
return;
}
p = (char *)GlobalLock(mme_app.clipboard);
memcpy(p, bih, bih->biSize);
memcpy(p+bih->biSize, get_frame_mme_project(&(mme_app.project)), bih->biSizeImage);
GlobalUnlock(mme_app.clipboard);
SetClipboardData(CF_DIB, mme_app.clipboard);
CloseClipboard();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_frame()
{
__int64 index;
FRAME_BY_NUMBER prm;
prm.current = get_frame_index_mme_project(&(mme_app.project));
prm.max = get_frame_count_mme_project(&(mme_app.project))-1;
prm.lang = mme_app.lang;
index = query_frame_by_number(mme_app.instance, mme_app.main_hwnd, &prm);
if(index != set_frame_index_mme_project(&(mme_app.project), index)){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
InvalidateRgn(mme_app.main_hwnd, NULL, FALSE); /* repaint */
return;
}
/*-----------------------------------------------------------------*/
static void on_move_timecode()
{
__int64 index;
FRAME_BY_TIMECODE prm;
prm.current = get_frame_index_mme_project(&(mme_app.project));
prm.max = get_frame_count_mme_project(&(mme_app.project))-1;
prm.lang = mme_app.lang;
prm.rate = mme_app.project.video_info.dwRate;
prm.scale = mme_app.project.video_info.dwScale;
index = query_frame_by_timecode(mme_app.instance, mme_app.main_hwnd, &prm);
if(index != set_frame_index_mme_project(&(mme_app.project), index)){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
InvalidateRgn(mme_app.main_hwnd, NULL, FALSE); /* repaint */
return;
}
/*-----------------------------------------------------------------*/
static void on_move_forward()
{
__int64 index;
index = get_frame_index_mme_project(&(mme_app.project));
if(index == set_frame_index_mme_project(&(mme_app.project), index+1)){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_back()
{
__int64 index;
index = get_frame_index_mme_project(&(mme_app.project));
if(index == set_frame_index_mme_project(&(mme_app.project), index-1)){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_next_i()
{
__int64 index;
index = get_frame_index_mme_project(&(mme_app.project));
if(index == go_next_i_frame_mme_project(&(mme_app.project))){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_prev_i()
{
__int64 index;
index = get_frame_index_mme_project(&(mme_app.project));
if(index == go_prev_i_frame_mme_project(&(mme_app.project))){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_in()
{
go_in_point_mme_project(&(mme_app.project));
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_out()
{
go_out_point_mme_project(&(mme_app.project));
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_start()
{
go_start_frame_mme_project(&(mme_app.project));
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_move_end()
{
go_end_frame_mme_project(&(mme_app.project));
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
return;
}
/*-----------------------------------------------------------------*/
static void on_help_about()
{
MessageBox(mme_app.main_hwnd, "僿儖僾 -> MME 偵偮偄偰儊僯儏乕偑慖戰偝傟傑偟偨", "僨僶僢僌", MB_OK|MB_ICONINFORMATION);
return;
}
/*-----------------------------------------------------------------*/
static void on_destory()
{
if(is_open_mme_project(&(mme_app.project))){
close_mme_project(&(mme_app.project));
}
close_m2v_vfapi(&(mme_app.vfapi));
GlobalFree(mme_app.clipboard);
PostQuitMessage(0);
}
/*-----------------------------------------------------------------*/
static void on_paint()
{
HDC hdc;
PAINTSTRUCT ps;
hdc = BeginPaint(mme_app.main_hwnd, &ps);
if(is_open_mme_project(&(mme_app.project))){
showdib(hdc, get_dib_header_mme_project(&(mme_app.project)), get_frame_mme_project(&(mme_app.project)));
}
EndPaint(mme_app.main_hwnd, &ps);
}
/*-----------------------------------------------------------------*/
static void on_cbdialog_cancel()
{
mme_app.callback_dlg = (HWND)INVALID_HANDLE_VALUE;
}
/*-----------------------------------------------------------------*/
static void on_h_scroll(int code, HWND hwnd)
{
int index;
if(code == TB_ENDTRACK){
index = SendMessage(mme_app.slide_bar, TBM_GETPOS, 0, 0);
if(index != set_frame_index_mme_project(&(mme_app.project), index)){
MessageBox(mme_app.main_hwnd, get_error_msg_mme_project(&(mme_app.project)), "INFO", MB_OK|MB_ICONINFORMATION);
}
update_slider();
SetWindowText(mme_app.main_hwnd, get_status_str_mme_project(&(mme_app.project)));
repaint();
}
return;
}
/*-----------------------------------------------------------------*/
static void on_dropfiles(HANDLE hdrop)
{
int n;
char *path;
n = DragQueryFile(hdrop, 0, NULL, 0) + 4;
path = malloc(n);
n = DragQueryFile(hdrop, 0, path, n);
DragFinish(hdrop);
open_file(path);
free(path);
}
/*-----------------------------------------------------------------*/
static void enable_menu_from_list(const UINT *list, int count)
{
int i;
for(i=0;i<count;i++){
EnableMenuItem(GetMenu(mme_app.main_hwnd), list[i], MF_ENABLED);
}
}
/*-----------------------------------------------------------------*/
static void disable_menu_from_list(const UINT *list, int count)
{
int i;
for(i=0;i<count;i++){
EnableMenuItem(GetMenu(mme_app.main_hwnd), list[i], MF_GRAYED);
}
}
/*-----------------------------------------------------------------*/
static void showdib(HDC hdc, const BITMAPINFOHEADER *header, const VOID *data)
{
StretchDIBits(hdc, 0, 0, header->biWidth, header->biHeight, 0, 0, header->biWidth, header->biHeight, data, (BITMAPINFO *)header, DIB_RGB_COLORS, SRCCOPY);
}
/*-----------------------------------------------------------------*/
static void resize(int client_width, int client_height)
{
RECT rect;
RECT client_rect;
int h_diff;
int v_diff;
GetWindowRect(mme_app.main_hwnd, &rect);
GetClientRect(mme_app.main_hwnd, &client_rect);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -