2002-07-06 02:44:16 +00:00
|
|
|
/*
|
|
|
|
* ReactOS winfile
|
|
|
|
*
|
|
|
|
* main.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Robert Dickenson <robd@reactos.org>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include "stdafx.h"
|
|
|
|
#else
|
|
|
|
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
|
|
#include <windows.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <memory.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
#include <process.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
#include "main.h"
|
|
|
|
#include "framewnd.h"
|
|
|
|
#include "childwnd.h"
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Global Variables:
|
|
|
|
//
|
2002-07-10 18:39:21 +00:00
|
|
|
UINT OemCodePage;
|
|
|
|
UINT AnsiCodePage;
|
|
|
|
LCID UserDefaultLCID;
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
HINSTANCE hInst;
|
|
|
|
#ifdef USE_GLOBAL_STRUCT
|
2002-07-06 02:44:16 +00:00
|
|
|
WINFILE_GLOBALS Globals;
|
2002-07-09 19:46:14 +00:00
|
|
|
#else
|
|
|
|
HINSTANCE hInstance;
|
|
|
|
HACCEL hAccel;
|
|
|
|
HWND hMainWnd;
|
|
|
|
HMENU hMenuFrame;
|
|
|
|
HMENU hWindowsMenu;
|
|
|
|
HMENU hLanguageMenu;
|
|
|
|
HMENU hMenuView;
|
|
|
|
HMENU hMenuOptions;
|
|
|
|
HWND hMDIClient;
|
|
|
|
HWND hStatusBar;
|
|
|
|
HWND hToolBar;
|
|
|
|
HWND hDriveBar;
|
|
|
|
HFONT hFont;
|
|
|
|
|
|
|
|
TCHAR num_sep;
|
|
|
|
SIZE spaceSize;
|
|
|
|
HIMAGELIST himl;
|
|
|
|
|
|
|
|
TCHAR drives[BUFFER_LEN];
|
|
|
|
BOOL prescan_node; //TODO
|
|
|
|
|
|
|
|
LPCSTR lpszLanguage;
|
|
|
|
UINT wStringTableOffset;
|
|
|
|
#endif
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
TCHAR szTitle[MAX_LOADSTRING];
|
2002-07-06 02:44:16 +00:00
|
|
|
TCHAR szFrameClass[MAX_LOADSTRING];
|
2002-07-09 19:46:14 +00:00
|
|
|
TCHAR szChildClass[MAX_LOADSTRING];
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// FUNCTION: InitInstance(HANDLE, int)
|
|
|
|
//
|
|
|
|
// PURPOSE: Saves instance handle and creates main window
|
|
|
|
//
|
|
|
|
// COMMENTS:
|
|
|
|
//
|
|
|
|
// In this function, we save the instance handle in a global variable and
|
|
|
|
// create and display the main program window.
|
|
|
|
//
|
|
|
|
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
|
|
|
{
|
2002-07-14 17:59:36 +00:00
|
|
|
// char TCHAR[MAX_PATH];
|
2002-07-09 19:46:14 +00:00
|
|
|
// int nParts[4];
|
|
|
|
// ChildWnd* child;
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
WNDCLASSEX wcFrame = {
|
|
|
|
sizeof(WNDCLASSEX),
|
2002-07-09 19:46:14 +00:00
|
|
|
CS_HREDRAW | CS_VREDRAW/*style*/,
|
|
|
|
FrameWndProc,
|
2002-07-06 02:44:16 +00:00
|
|
|
0/*cbClsExtra*/,
|
|
|
|
0/*cbWndExtra*/,
|
|
|
|
hInstance,
|
|
|
|
LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINFILE)),
|
|
|
|
LoadCursor(0, IDC_ARROW),
|
|
|
|
0/*hbrBackground*/,
|
|
|
|
0/*lpszMenuName*/,
|
2002-07-09 19:46:14 +00:00
|
|
|
szFrameClass,
|
2002-07-06 02:44:16 +00:00
|
|
|
(HICON)LoadImage(hInstance, MAKEINTRESOURCE(IDI_WINFILE), IMAGE_ICON,
|
|
|
|
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED)
|
|
|
|
};
|
2002-07-09 19:46:14 +00:00
|
|
|
ATOM hFrameWndClass = RegisterClassEx(&wcFrame); // register frame window class
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
WNDCLASS wcChild = {
|
|
|
|
CS_CLASSDC|CS_DBLCLKS|CS_VREDRAW,
|
|
|
|
ChildWndProc,
|
|
|
|
0/*cbClsExtra*/,
|
|
|
|
0/*cbWndExtra*/,
|
|
|
|
hInstance,
|
|
|
|
0/*hIcon*/,
|
|
|
|
LoadCursor(0, IDC_ARROW),
|
|
|
|
0/*hbrBackground*/,
|
|
|
|
0/*lpszMenuName*/,
|
2002-07-09 19:46:14 +00:00
|
|
|
szChildClass
|
2002-07-06 02:44:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ATOM hChildClass = RegisterClass(&wcChild); // register child windows class
|
|
|
|
|
|
|
|
HMENU hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDC_WINFILE));
|
|
|
|
HMENU hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
|
|
|
|
|
|
|
|
CLIENTCREATESTRUCT ccs = {
|
|
|
|
hMenuWindow, IDW_FIRST_CHILD
|
|
|
|
};
|
|
|
|
|
|
|
|
INITCOMMONCONTROLSEX icc = {
|
|
|
|
sizeof(INITCOMMONCONTROLSEX),
|
|
|
|
ICC_BAR_CLASSES
|
|
|
|
};
|
|
|
|
|
|
|
|
// TCHAR path[MAX_PATH];
|
|
|
|
|
|
|
|
HDC hdc = GetDC(0);
|
|
|
|
|
|
|
|
// hMenuFrame = hMenuFrame;
|
|
|
|
Globals.hMenuView = GetSubMenu(hMenuFrame, 3);
|
|
|
|
Globals.hMenuOptions = GetSubMenu(hMenuFrame, 4);
|
|
|
|
Globals.hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_WINFILE));
|
|
|
|
Globals.hFont = CreateFont(-MulDiv(8,GetDeviceCaps(hdc,LOGPIXELSY),72), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, _T("MS Sans Serif"));
|
|
|
|
ReleaseDC(0, hdc);
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
Globals.hMainWnd = CreateWindowEx(0, (LPCTSTR)(int)hFrameWndClass, szTitle,
|
|
|
|
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
2002-07-06 02:44:16 +00:00
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
0/*hWndParent*/, hMenuFrame, hInstance, 0/*lpParam*/);
|
|
|
|
if (!Globals.hMainWnd) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
if (InitCommonControlsEx(&icc)) {
|
|
|
|
// TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP};
|
2002-07-06 02:44:16 +00:00
|
|
|
TBBUTTON drivebarBtn = {0, 0, TBSTATE_ENABLED, TBSTYLE_SEP};
|
|
|
|
int btn = 1;
|
|
|
|
PTSTR p;
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
Globals.hDriveBar = CreateToolbarEx(Globals.hMainWnd,
|
|
|
|
WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_FLAT|TBSTYLE_LIST|TBSTYLE_WRAPABLE,
|
|
|
|
// WS_CHILD|WS_VISIBLE|CCS_NOMOVEY|TBSTYLE_LIST|TBSTYLE_TRANSPARENT|TBSTYLE_WRAPABLE,
|
2002-07-09 19:46:14 +00:00
|
|
|
IDW_DRIVEBAR, 2, hInstance, IDB_DRIVEBAR,
|
|
|
|
&drivebarBtn, 1/*iNumButtons*/,
|
2002-07-14 17:59:36 +00:00
|
|
|
25/*dxButton*/, 16/*dyButton*/,
|
|
|
|
0/*dxBitmap*/, 0/*dyBitmap*/, sizeof(TBBUTTON));
|
|
|
|
// 16/*dxButton*/, 13/*dyButton*/,
|
|
|
|
// 16/*dxBitmap*/, 13/*dyBitmap*/, sizeof(TBBUTTON));
|
2002-07-06 02:44:16 +00:00
|
|
|
CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_DRIVEBAR, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
GetLogicalDriveStrings(BUFFER_LEN, Globals.drives);
|
|
|
|
drivebarBtn.fsStyle = TBSTYLE_BUTTON;
|
|
|
|
#ifndef _NO_EXTENSIONS
|
|
|
|
// register windows drive root strings
|
|
|
|
SendMessage(Globals.hDriveBar, TB_ADDSTRING, 0, (LPARAM)Globals.drives);
|
|
|
|
#endif
|
|
|
|
drivebarBtn.idCommand = ID_DRIVE_FIRST;
|
2002-07-09 19:46:14 +00:00
|
|
|
for (p = Globals.drives; *p;) {
|
2002-07-06 02:44:16 +00:00
|
|
|
#ifdef _NO_EXTENSIONS
|
|
|
|
// insert drive letter
|
|
|
|
TCHAR b[3] = { tolower(*p) };
|
|
|
|
SendMessage(Globals.hDriveBar, TB_ADDSTRING, 0, (LPARAM)b);
|
|
|
|
#endif
|
|
|
|
switch(GetDriveType(p)) {
|
|
|
|
case DRIVE_REMOVABLE: drivebarBtn.iBitmap = 1; break;
|
|
|
|
case DRIVE_CDROM: drivebarBtn.iBitmap = 3; break;
|
|
|
|
case DRIVE_REMOTE: drivebarBtn.iBitmap = 4; break;
|
|
|
|
case DRIVE_RAMDISK: drivebarBtn.iBitmap = 5; break;
|
|
|
|
default:/*DRIVE_FIXED*/ drivebarBtn.iBitmap = 2;
|
|
|
|
}
|
|
|
|
SendMessage(Globals.hDriveBar, TB_INSERTBUTTON, btn++, (LPARAM)&drivebarBtn);
|
|
|
|
drivebarBtn.idCommand++;
|
|
|
|
drivebarBtn.iString++;
|
|
|
|
while(*p++);
|
|
|
|
}
|
2002-07-09 19:46:14 +00:00
|
|
|
{
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
#define DRIVEBOX_WIDTH 200
|
|
|
|
#define DRIVEBOX_HEIGHT 8
|
|
|
|
|
2002-07-06 02:44:16 +00:00
|
|
|
TBBUTTON toolbarBtns[] = {
|
2002-07-14 17:59:36 +00:00
|
|
|
{DRIVEBOX_WIDTH+10, 0, 0, TBSTYLE_SEP},
|
2002-07-06 02:44:16 +00:00
|
|
|
{0, 0, 0, TBSTYLE_SEP},
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
// {1, ID_FILE_OPEN, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_OPEN },
|
|
|
|
{2, ID_FILE_MOVE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_MOVE},
|
|
|
|
{3, ID_FILE_COPY, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY},
|
|
|
|
{4, ID_FILE_COPY_CLIPBOARD, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_COPY_CLIPBOARD},
|
|
|
|
{5, ID_FILE_DELETE, TBSTATE_ENABLED, TBSTYLE_BUTTON, 0, ID_FILE_DELETE},
|
|
|
|
{6, ID_FILE_RENAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{7, ID_FILE_PROPERTIES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{8, ID_FILE_COMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{9, ID_FILE_UNCOMPRESS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {10, ID_FILE_RUN, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{10, ID_FILE_PRINT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{11, ID_FILE_ASSOCIATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{12, ID_FILE_CREATE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{13, ID_FILE_SEARCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{14, ID_FILE_SELECT_FILES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {16, ID_FILE_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{15, ID_DISK_COPY_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{16, ID_DISK_LABEL_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{17, ID_DISK_FORMAT_DISK, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{18, ID_DISK_CONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{19, ID_DISK_DISCONNECT_NETWORK_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{20, ID_DISK_SHARE_AS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{21, ID_DISK_STOP_SHARING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {24, ID_DISK_SELECT_DRIVE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {25, ID_TREE_EXPAND_ONE_LEVEL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {26, ID_TREE_EXPAND_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {27, ID_TREE_EXPAND_ALL, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {28, ID_TREE_COLLAPSE_BRANCH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{22, ID_TREE_INDICATE_EXPANDABLE_BRANCHES, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {30, ID_VIEW_TREE_DIRECTORY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {31, ID_VIEW_TREE_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {32, ID_VIEW_DIRECTORY_ONLY, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {33, ID_VIEW_SPLIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{23, ID_VIEW_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{24, ID_VIEW_ALL_FILE_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{25, ID_VIEW_PARTIAL_DETAILS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {37, ID_VIEW_SORT_BY_NAME, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {38, ID_VIEW_SORT_BY_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {39, ID_VIEW_SORT_BY_SIZE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {40, ID_VIEW_SORT_BY_DATE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{26, ID_VIEW_BY_FILE_TYPE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{27, ID_OPTIONS_CONFIRMATION, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{28, ID_OPTIONS_FONT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{29, ID_OPTIONS_CUSTOMISE_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {45, ID_OPTIONS_TOOLBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {46, ID_OPTIONS_DRIVEBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {47, ID_OPTIONS_STATUSBAR, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{30, ID_OPTIONS_OPEN_NEW_WINDOW_ON_CONNECT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{31, ID_OPTIONS_MINIMISE_ON_USE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{32, ID_OPTIONS_SAVE_ON_EXIT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{33, ID_SECURITY_PERMISSIONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{34, ID_SECURITY_AUDITING, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{35, ID_SECURITY_OWNER, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{36, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{37, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{38, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{39, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{40, ID_WINDOW_ARRANGE_ICONS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{41, ID_WINDOW_REFRESH, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
{42, ID_HELP_CONTENTS, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {61, ID_HELP_SEARCH_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {62, ID_HELP_HOW_TO_USE_HELP, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {63, ID_HELP_ABOUT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
|
|
|
|
|
|
|
|
// {0, ID_WINDOW_NEW_WINDOW, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {1, ID_WINDOW_CASCADE, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {2, ID_WINDOW_TILE_HORZ, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {3, ID_WINDOW_TILE_VERT, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {4, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
|
|
|
// {5, 2/*TODO: ID_...*/, TBSTATE_ENABLED, TBSTYLE_BUTTON},
|
2002-07-06 02:44:16 +00:00
|
|
|
};
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
// Globals.hToolBar = CreateToolbarEx(Globals.hMainWnd, WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS|TBSTYLE_FLAT,
|
|
|
|
Globals.hToolBar = CreateToolbarEx(Globals.hMainWnd, WS_CHILD|WS_VISIBLE|TBSTYLE_TOOLTIPS|CCS_ADJUSTABLE,
|
2002-07-06 02:44:16 +00:00
|
|
|
IDW_TOOLBAR, 2, hInstance, IDB_TOOLBAR, toolbarBtns,
|
|
|
|
sizeof(toolbarBtns)/sizeof(TBBUTTON), 16, 15, 16, 15, sizeof(TBBUTTON));
|
|
|
|
CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_TOOLBAR, MF_BYCOMMAND|MF_CHECKED);
|
2002-07-14 17:59:36 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
// Create the edit control. Notice that hWndParent, parent of
|
|
|
|
// the toolbar, is used as the parent of the edit control.
|
|
|
|
|
|
|
|
//HWND hWndEdit = CreateWindowEx(0L, WC_COMBOBOXEX, NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
|
|
|
|
HWND hWndEdit = CreateWindowEx(0L, "ComboBox", NULL, WS_CHILD | WS_BORDER | WS_VISIBLE
|
|
|
|
| CBS_DROPDOWN | ES_LEFT | ES_AUTOVSCROLL | ES_MULTILINE,
|
|
|
|
10, 0, DRIVEBOX_WIDTH, DRIVEBOX_HEIGHT, Globals.hMainWnd, (HMENU)IDW_DRIVEBOX, hInstance, 0);
|
|
|
|
|
|
|
|
// Set the toolbar window as the parent of the edit control
|
|
|
|
// window. You must set the toolbar as the parent of the edit
|
|
|
|
// control for it to appear embedded in the toolbar.
|
|
|
|
SetParent (hWndEdit, Globals.hToolBar);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
}
|
2002-07-06 02:44:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create the status bar
|
|
|
|
Globals.hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
|
2002-07-14 17:59:36 +00:00
|
|
|
_T(""), Globals.hMainWnd, IDW_STATUS_WINDOW);
|
2002-07-06 02:44:16 +00:00
|
|
|
if (!Globals.hStatusBar)
|
|
|
|
return FALSE;
|
|
|
|
CheckMenuItem(Globals.hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
|
|
|
|
|
|
|
// Create the status bar panes
|
2002-07-09 19:46:14 +00:00
|
|
|
SetupStatusBar(FALSE);
|
|
|
|
/*
|
|
|
|
nParts[0] = 250;
|
|
|
|
nParts[1] = 220;
|
|
|
|
nParts[2] = 100;
|
|
|
|
nParts[3] = 100;
|
|
|
|
SendMessage(Globals.hStatusBar, SB_SETPARTS, 4, (long)nParts);
|
|
|
|
*/
|
|
|
|
#if 0
|
2002-07-06 02:44:16 +00:00
|
|
|
//Globals.hstatusbar = CreateStatusWindow(WS_CHILD|WS_VISIBLE, 0, Globals.Globals.hMainWnd, IDW_STATUSBAR);
|
|
|
|
//CheckMenuItem(Globals.Globals.hMenuOptions, ID_OPTIONS_STATUSBAR, MF_BYCOMMAND|MF_CHECKED);
|
2002-07-09 19:46:14 +00:00
|
|
|
/* CreateStatusWindow does not accept WS_BORDER */
|
|
|
|
/* Globals.hstatusbar = CreateWindowEx(WS_EX_NOPARENTNOTIFY, STATUSCLASSNAME, 0,
|
2002-07-06 02:44:16 +00:00
|
|
|
WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_BORDER|CCS_NODIVIDER, 0,0,0,0,
|
|
|
|
Globals.Globals.hMainWnd, (HMENU)IDW_STATUSBAR, hinstance, 0);*/
|
2002-07-09 19:46:14 +00:00
|
|
|
//TODO: read paths and window placements from registry
|
2002-07-06 02:44:16 +00:00
|
|
|
GetCurrentDirectory(MAX_PATH, path);
|
|
|
|
child = alloc_child_window(path);
|
|
|
|
child->pos.showCmd = SW_SHOWMAXIMIZED;
|
|
|
|
child->pos.rcNormalPosition.left = 0;
|
|
|
|
child->pos.rcNormalPosition.top = 0;
|
|
|
|
child->pos.rcNormalPosition.right = 320;
|
|
|
|
child->pos.rcNormalPosition.bottom = 280;
|
|
|
|
if (!create_child_window(child))
|
|
|
|
free(child);
|
2002-07-09 19:46:14 +00:00
|
|
|
SetWindowPlacement(child->hWnd, &child->pos);
|
2002-07-06 02:44:16 +00:00
|
|
|
Globals.himl = ImageList_LoadBitmap(Globals.hInstance, MAKEINTRESOURCE(IDB_IMAGES), 16, 0, RGB(0,255,0));
|
|
|
|
Globals.prescan_node = FALSE;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ShowWindow(Globals.hMainWnd, nCmdShow);
|
|
|
|
UpdateWindow(Globals.hMainWnd);
|
2002-07-09 19:46:14 +00:00
|
|
|
UpdateStatusBar();
|
2002-07-06 02:44:16 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
2002-07-09 19:46:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
Globals.hMDIClient = CreateWindowEx(0, _T("MDICLIENT"), NULL,
|
|
|
|
// Globals.hMDIClient = CreateWindowEx(0, (LPCTSTR)(int)hChildClass, NULL,
|
|
|
|
WS_CHILD|WS_CLIPCHILDREN|WS_VSCROLL|WS_HSCROLL|WS_VISIBLE|WS_BORDER,
|
|
|
|
0, 0, 0, 0,
|
|
|
|
Globals.hMainWnd, 0, hInstance, &ccs);
|
|
|
|
if (!Globals.hMDIClient) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
*/
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
void SetupStatusBar(BOOL bResize)
|
|
|
|
{
|
|
|
|
int nParts[4];
|
|
|
|
// int parts[] = {300, 500};
|
|
|
|
// SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0);
|
|
|
|
// SendMessage(Globals.hStatusBar, SB_SETPARTS, 2, (LPARAM)&parts);
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
// Create the status bar panes
|
|
|
|
nParts[0] = 150;
|
|
|
|
nParts[1] = 220;
|
|
|
|
nParts[2] = 100;
|
|
|
|
nParts[3] = 100;
|
|
|
|
if (bResize)
|
|
|
|
SendMessage(Globals.hStatusBar, WM_SIZE, 0, 0);
|
|
|
|
SendMessage(Globals.hStatusBar, SB_SETPARTS, 4, (long)nParts);
|
|
|
|
}
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
void UpdateStatusBar(void)
|
|
|
|
{
|
|
|
|
TCHAR text[260];
|
|
|
|
DWORD size;
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
// size = sizeof(text)/sizeof(TCHAR);
|
|
|
|
// GetUserName(text, &size);
|
|
|
|
// SendMessage(Globals.hStatusBar, SB_SETTEXT, 2, (LPARAM)text);
|
2002-07-09 19:46:14 +00:00
|
|
|
size = sizeof(text)/sizeof(TCHAR);
|
|
|
|
GetComputerName(text, &size);
|
|
|
|
SendMessage(Globals.hStatusBar, SB_SETTEXT, 3, (LPARAM)text);
|
|
|
|
}
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
static int g_foundPrevInstance = 0;
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
// search for already running instances
|
|
|
|
static BOOL CALLBACK EnumWndProc(HWND hWnd, LPARAM lparam)
|
2002-07-06 02:44:16 +00:00
|
|
|
{
|
|
|
|
TCHAR cls[128];
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
GetClassName(hWnd, cls, 128);
|
2002-07-06 02:44:16 +00:00
|
|
|
if (!lstrcmp(cls, (LPCTSTR)lparam)) {
|
|
|
|
g_foundPrevInstance++;
|
2002-07-10 18:39:21 +00:00
|
|
|
SetForegroundWindow(hWnd);
|
2002-07-06 02:44:16 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
void ExitInstance(void)
|
2002-07-06 02:44:16 +00:00
|
|
|
{
|
|
|
|
if (Globals.himl)
|
|
|
|
ImageList_Destroy(Globals.himl);
|
|
|
|
}
|
|
|
|
|
2002-07-10 18:39:21 +00:00
|
|
|
/*
|
|
|
|
struct _cpinfo {
|
|
|
|
UINT MaxCharSize;
|
|
|
|
BYTE DefaultChar[MAX_DEFAULTCHAR];
|
|
|
|
BYTE LeadByte[MAX_LEADBYTES];
|
|
|
|
} CPINFO, *LPCPINFO;
|
|
|
|
*/
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
int APIENTRY WinMain(HINSTANCE hInstance,
|
|
|
|
HINSTANCE hPrevInstance,
|
|
|
|
LPSTR lpCmdLine,
|
|
|
|
int nCmdShow)
|
|
|
|
{
|
|
|
|
MSG msg;
|
|
|
|
HACCEL hAccel;
|
2002-07-09 19:46:14 +00:00
|
|
|
HWND hMDIClient;
|
2002-07-06 02:44:16 +00:00
|
|
|
|
2002-07-10 18:39:21 +00:00
|
|
|
CPINFO CPinfo;
|
|
|
|
|
|
|
|
OemCodePage = GetOEMCP();
|
|
|
|
AnsiCodePage = GetACP();
|
|
|
|
UserDefaultLCID = GetUserDefaultLCID();
|
|
|
|
if (GetCPInfo(UserDefaultLCID, &CPinfo)) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2002-07-06 02:44:16 +00:00
|
|
|
// Initialize global strings
|
|
|
|
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
2002-07-09 19:46:14 +00:00
|
|
|
LoadString(hInstance, IDC_WINFILE, szFrameClass, MAX_LOADSTRING);
|
|
|
|
LoadString(hInstance, IDC_WINFILE_CHILD, szChildClass, MAX_LOADSTRING);
|
|
|
|
|
|
|
|
// Allow only one running instance
|
|
|
|
EnumWindows(EnumWndProc, (LPARAM)szFrameClass);
|
2002-07-10 18:39:21 +00:00
|
|
|
if (g_foundPrevInstance) {
|
2002-07-06 02:44:16 +00:00
|
|
|
return 1;
|
2002-07-10 18:39:21 +00:00
|
|
|
}
|
2002-07-09 19:46:14 +00:00
|
|
|
|
|
|
|
// Store instance handle in our global variable
|
|
|
|
hInst = hInstance;
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
// Perform application initialization:
|
|
|
|
if (!InitInstance(hInstance, nCmdShow)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-07-14 17:59:36 +00:00
|
|
|
// hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDC_WINFILE);
|
|
|
|
hAccel = LoadAccelerators(hInstance, (LPCTSTR)IDR_ACCELERATOR1);
|
|
|
|
|
2002-07-09 19:46:14 +00:00
|
|
|
hMDIClient = GetWindow(Globals.hMainWnd, GW_CHILD);
|
2002-07-06 02:44:16 +00:00
|
|
|
|
|
|
|
// Main message loop:
|
|
|
|
while (GetMessage(&msg, (HWND)NULL, 0, 0)) {
|
2002-07-09 19:46:14 +00:00
|
|
|
if (!TranslateMDISysAccel(hMDIClient, &msg) &&
|
2002-07-06 02:44:16 +00:00
|
|
|
!TranslateAccelerator(Globals.hMainWnd/*hwndFrame*/, hAccel, &msg)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ExitInstance();
|
|
|
|
return msg.wParam;
|
|
|
|
}
|
|
|
|
|
2002-07-10 18:39:21 +00:00
|
|
|
void _GetFreeSpaceEx(void)
|
|
|
|
{
|
|
|
|
BOOL fResult;
|
|
|
|
TCHAR szDrive[MAX_PATH];
|
|
|
|
ULARGE_INTEGER i64FreeBytesToCaller;
|
|
|
|
ULARGE_INTEGER i64TotalBytes;
|
|
|
|
ULARGE_INTEGER i64FreeBytes;
|
|
|
|
|
|
|
|
fResult = GetDiskFreeSpaceEx(szDrive,
|
|
|
|
(PULARGE_INTEGER)&i64FreeBytesToCaller,
|
|
|
|
(PULARGE_INTEGER)&i64TotalBytes,
|
|
|
|
(PULARGE_INTEGER)&i64FreeBytes);
|
|
|
|
}
|