?? fm.cpp
字號:
UString programString, commandsString;
// MessageBoxW(0, GetCommandLineW(), L"", 0);
SplitStringToTwoStrings(GetCommandLineW(), programString, commandsString);
commandsString.Trim();
UString paramString, tailString;
SplitStringToTwoStrings(commandsString, paramString, tailString);
paramString.Trim();
if (!paramString.IsEmpty())
{
g_MainPath = paramString;
// return WinMain2(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
// MessageBoxW(0, paramString, L"", 0);
}
/*
UStringVector commandStrings;
NCommandLineParser::SplitCommandLine(GetCommandLineW(), commandStrings);
NCommandLineParser::CParser parser(kNumSwitches);
try
{
parser.ParseStrings(kSwitchForms, commandStrings);
const UStringVector &nonSwitchStrings = parser.NonSwitchStrings;
if(nonSwitchStrings.Size() > 1)
{
g_MainPath = nonSwitchStrings[1];
// g_OpenArchive = parser[NKey::kOpenArachive].ThereIs;
CFileInfoW fileInfo;
if (FindFile(g_MainPath, fileInfo))
{
if (!fileInfo.IsDir())
g_OpenArchive = true;
}
}
}
catch(...) { }
*/
SetMemoryLock();
MSG msg;
if (!InitInstance (hInstance, nCmdShow))
return FALSE;
MyLoadMenu(g_HWND);
#ifndef _UNICODE
if (g_IsNT)
{
HACCEL hAccels = LoadAcceleratorsW(hInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR1));
while (GetMessageW(&msg, NULL, 0, 0))
{
if (TranslateAcceleratorW(g_HWND, hAccels, &msg) == 0)
{
TranslateMessage(&msg);
DispatchMessageW(&msg);
}
}
}
else
#endif
{
HACCEL hAccels = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));
while (GetMessage(&msg, NULL, 0, 0))
{
if (TranslateAccelerator(g_HWND, hAccels, &msg) == 0)
{
// if (g_Hwnd != NULL || !IsDialogMessage(g_Hwnd, &msg))
// if (!IsDialogMessage(g_Hwnd, &msg))
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
g_HWND = 0;
OleUninitialize();
return (int)msg.wParam;
}
static void SaveWindowInfo(HWND aWnd)
{
/*
RECT rect;
if (!::GetWindowRect(aWnd, &rect))
return;
*/
WINDOWPLACEMENT placement;
placement.length = sizeof(placement);
if (!::GetWindowPlacement(aWnd, &placement))
return;
SaveWindowSize(placement.rcNormalPosition,
BOOLToBool(::IsZoomed(aWnd)));
SavePanelsInfo(g_App.NumPanels, g_App.LastFocusedPanel,
g_Splitter.GetPos());
}
void ExecuteCommand(UINT commandID)
{
switch (commandID)
{
case kAddCommand:
g_App.AddToArchive();
break;
case kExtractCommand:
g_App.ExtractArchives();
break;
case kTestCommand:
g_App.TestArchives();
break;
}
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
if ((HWND) lParam != NULL && wmEvent != 0)
break;
if (wmId >= kToolbarStartID)
{
ExecuteCommand(wmId);
return 0;
}
if (OnMenuCommand(hWnd, wmId))
return 0;
break;
case WM_INITMENUPOPUP:
OnMenuActivating(hWnd, HMENU(wParam), LOWORD(lParam));
break;
/*
It doesn't help
case WM_EXITMENULOOP:
{
OnMenuUnActivating(hWnd);
break;
}
case WM_UNINITMENUPOPUP:
OnMenuUnActivating(hWnd, HMENU(wParam), lParam);
break;
*/
case WM_CREATE:
{
/*
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
icex.dwICC = ICC_BAR_CLASSES;
InitCommonControlsEx(&icex);
// Toolbar buttons used to create the first 4 buttons.
TBBUTTON tbb [ ] =
{
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
// {VIEW_PARENTFOLDER, kParentFolderID, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
// {0, 0, TBSTATE_ENABLED, BTNS_SEP, 0L, 0},
{VIEW_NEWFOLDER, ID_FILE_CREATEFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, 0L, 0},
};
int baseID = 100;
NWindows::NControl::CToolBar aToolBar;
aToolBar.Attach(::CreateToolbarEx (hWnd,
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_TOOLTIPS, // | TBSTYLE_FLAT
baseID + 2, 11,
(HINSTANCE)HINST_COMMCTRL, IDB_VIEW_SMALL_COLOR,
(LPCTBBUTTON)&tbb, sizeof(tbb) / sizeof(tbb[0]),
0, 0, 100, 30, sizeof (TBBUTTON)));
*/
// HCURSOR cursor = ::LoadCursor(0, IDC_SIZEWE);
// ::SetCursor(cursor);
if (g_PanelsInfoDefined)
g_Splitter.SetPos(hWnd, g_SplitterPos);
else
{
g_Splitter.SetRatio(hWnd, kSplitterRateMax / 2);
g_SplitterPos = g_Splitter.GetPos();
}
RECT rect;
::GetClientRect(hWnd, &rect);
int xSize = rect.right;
int xSizes[2];
xSizes[0] = g_Splitter.GetPos();
xSizes[1] = xSize - kSplitterWidth - xSizes[0];
if (xSizes[1] < 0)
xSizes[1] = 0;
g_App.CreateDragTarget();
bool archiveIsOpened;
bool encrypted;
bool needOpenFile = false;
if (!g_MainPath.IsEmpty() /* && g_OpenArchive */)
{
NFile::NFind::CFileInfoW fileInfo;
if (NFile::NFind::FindFile(g_MainPath, fileInfo))
if (!fileInfo.IsDir())
needOpenFile = true;
}
HRESULT res = g_App.Create(hWnd, g_MainPath, xSizes, archiveIsOpened, encrypted);
if (res == E_ABORT)
{
return -1;
}
if (needOpenFile && !archiveIsOpened || res != S_OK)
{
UString message = L"Error";
if (res == S_FALSE || res == S_OK)
{
if (encrypted)
message = MyFormatNew(IDS_CANT_OPEN_ENCRYPTED_ARCHIVE, 0x0200060A, g_MainPath);
else
message = MyFormatNew(IDS_CANT_OPEN_ARCHIVE, 0x02000609, g_MainPath);
}
else
{
if (res != S_OK)
{
if (res == E_OUTOFMEMORY)
message = LangString(IDS_MEM_ERROR, 0x0200060B);
else
if (!NError::MyFormatMessage(res, message))
message = L"Error";
}
}
MessageBoxW(0, message, L"7-zip", MB_ICONERROR);
return -1;
}
// g_SplitterPos = 0;
// ::DragAcceptFiles(hWnd, TRUE);
RegisterDragDrop(hWnd, g_App._dropTarget);
break;
}
case WM_DESTROY:
{
// ::DragAcceptFiles(hWnd, FALSE);
RevokeDragDrop(hWnd);
g_App._dropTarget.Release();
g_App.Save();
g_App.Release();
SaveWindowInfo(hWnd);
PostQuitMessage(0);
break;
}
/*
case WM_MOVE:
{
break;
}
*/
case WM_LBUTTONDOWN:
g_StartCaptureMousePos = LOWORD(lParam);
g_StartCaptureSplitterPos = g_Splitter.GetPos();
::SetCapture(hWnd);
break;
case WM_LBUTTONUP:
{
::ReleaseCapture();
break;
}
case WM_MOUSEMOVE:
{
if ((wParam & MK_LBUTTON) != 0 && ::GetCapture() == hWnd)
{
g_Splitter.SetPos(hWnd, g_StartCaptureSplitterPos +
(short)LOWORD(lParam) - g_StartCaptureMousePos);
MoveSubWindows(hWnd);
}
break;
}
case WM_SIZE:
{
if (g_CanChangeSplitter)
g_Splitter.SetPosFromRatio(hWnd);
else
{
g_Splitter.SetPos(hWnd, g_SplitterPos );
g_CanChangeSplitter = true;
}
OnSize(hWnd);
/*
int xSize = LOWORD(lParam);
int ySize = HIWORD(lParam);
// int xSplitter = 2;
int xWidth = g_SplitPos;
// int xSplitPos = xWidth;
g_Panel[0]._listView.MoveWindow(0, 0, xWidth, ySize);
g_Panel[1]._listView.MoveWindow(xSize - xWidth, 0, xWidth, ySize);
*/
return 0;
break;
}
case WM_SETFOCUS:
// g_App.SetFocus(g_App.LastFocusedPanel);
g_App.SetFocusToLastItem();
break;
/*
case WM_ACTIVATE:
{
int fActive = LOWORD(wParam);
switch (fActive)
{
case WA_INACTIVE:
{
// g_FocusIndex = g_App.LastFocusedPanel;
// g_App.LastFocusedPanel = g_App.GetFocusedPanelIndex();
// return 0;
}
}
break;
}
*/
/*
case kLangWasChangedMessage:
MyLoadMenu(g_HWND);
return 0;
*/
/*
case WM_SETTINGCHANGE:
break;
*/
case WM_NOTIFY:
{
g_App.OnNotify((int)wParam, (LPNMHDR)lParam);
break;
}
/*
case WM_DROPFILES:
{
g_App.GetFocusedPanel().CompressDropFiles((HDROP)wParam);
return 0 ;
}
*/
}
#ifndef _UNICODE
if (g_IsNT)
return DefWindowProcW(hWnd, message, wParam, lParam);
else
#endif
return DefWindowProc(hWnd, message, wParam, lParam);
}
void OnSize(HWND hWnd)
{
/*
if (g_App._rebar)
{
RECT rect;
::GetClientRect(hWnd, &rect);
int xSize = rect.right;
int ySize = rect.bottom;
// rect.bottom = 0;
// g_App._rebar.SizeToRect(&rect);
// g_App._rebar.Move(0, 0, xSize, ySize);
}
*/
MoveSubWindows(hWnd);
}
int Window_GetRealHeight(NWindows::CWindow &w)
{
RECT rect;
WINDOWPLACEMENT placement;
w.GetWindowRect(&rect);
int res = rect.bottom - rect.top;
if (w.GetPlacement(&placement))
res += placement.rcNormalPosition.top;
return res;
}
void MoveSubWindows(HWND hWnd)
{
RECT rect;
::GetClientRect(hWnd, &rect);
int xSize = rect.right;
int headerSize = 0;
if (g_App._rebar)
headerSize = Window_GetRealHeight(g_App._rebar);
int ySize = MyMax((int)(rect.bottom - headerSize), 0);
// It's for such case: Minimize / Close:
if (xSize == 0 && ySize == 0)
return;
if (g_App.NumPanels > 1)
{
g_App.Panels[0].Move(0, headerSize, g_Splitter.GetPos(), ySize);
int xWidth1 = g_Splitter.GetPos() + kSplitterWidth;
g_App.Panels[1].Move(xWidth1, headerSize, xSize - xWidth1, ySize);
}
else
{
/*
int otherPanel = 1 - g_App.LastFocusedPanel;
if (g_App.PanelsCreated[otherPanel])
g_App.Panels[otherPanel].Move(0, headerSize, 0, ySize);
*/
g_App.Panels[g_App.LastFocusedPanel].Move(0, headerSize, xSize, ySize);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -