#include "treeview.h"
#include "listview.h"
#include <shellapi.h>
-//#include <winspool.h>
////////////////////////////////////////////////////////////////////////////////
-// Global Variables:
+// Globals and Variables:
//
-HWND hTreeWnd; // Tree Control Window
-HWND hListWnd; // List Control Window
-HWND hSplitWnd; // Splitter Bar Control Window
-int nOldWidth; // Holds the previous client area width
-int nOldHeight; // Holds the previous client area height
-BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop
+static BOOL bInMenuLoop = FALSE; // Tells us if we are in the menu loop
+
+static HWND hChildWnd;
////////////////////////////////////////////////////////////////////////////////
// Local module support methods
static void resize_frame_rect(HWND hWnd, PRECT prect)
{
-// int new_top;
RECT rt;
/*
if (IsWindowVisible(hToolBar)) {
}
*/
if (IsWindowVisible(hStatusBar)) {
+ SetupStatusBar(TRUE);
GetClientRect(hStatusBar, &rt);
prect->bottom -= rt.bottom;
}
-// MoveWindow(hWnd, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE);
+ MoveWindow(hChildWnd, prect->left-1,prect->top-1,prect->right+2,prect->bottom+1, TRUE);
}
static void resize_frame(HWND hWnd, int cx, int cy)
resize_frame_rect(hWnd, &rect);
}
-static void draw_splitbar(HWND hWnd, int x)
-{
- RECT rt;
- HDC hdc = GetDC(hWnd);
-
- GetClientRect(hWnd, &rt);
- if (IsWindowVisible(hStatusBar)) {
- RECT rect;
- GetClientRect(hStatusBar, &rect);
- rt.bottom -= rect.bottom;
- }
- rt.left = x - SPLIT_WIDTH/2;
- rt.right = x + SPLIT_WIDTH/2+1;
- InvertRect(hdc, &rt);
- ReleaseDC(hWnd, hdc);
-}
-
-#define _NO_EXTENSIONS
-
-static int nSplitPos = 250;
-
-static void ResizeWnd(int cx, int cy)
-{
- HDWP hdwp = BeginDeferWindowPos(2);
- RECT rt = {0, 0, cx, cy};
-
- cx = nSplitPos + SPLIT_WIDTH/2;
- if (IsWindowVisible(hStatusBar)) {
- RECT rect;
- GetClientRect(hStatusBar, &rect);
- rt.bottom -= rect.bottom;
- }
- DeferWindowPos(hdwp, hTreeWnd, 0, rt.left, rt.top, nSplitPos-SPLIT_WIDTH/2-rt.left, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
- DeferWindowPos(hdwp, hListWnd, 0, rt.left+cx+1, rt.top, rt.right-cx, rt.bottom-rt.top, SWP_NOZORDER|SWP_NOACTIVATE);
- EndDeferWindowPos(hdwp);
-}
-
-static void OnSize(WPARAM wParam, LPARAM lParam)
-{
- if (wParam != SIZE_MINIMIZED) {
- ResizeWnd(LOWORD(lParam), HIWORD(lParam));
- }
-}
-
-/*
-// OnSize()
-// This function handles all the sizing events for the application
-// It re-sizes every window, and child window that needs re-sizing
-static void OnSize(UINT nType, int cx, int cy)
-{
- int nParts[3];
- int nXDifference;
- int nYDifference;
- RECT rc;
- if (nType == SIZE_MINIMIZED)
- return;
- nXDifference = cx - nOldWidth;
- nYDifference = cy - nOldHeight;
- nOldWidth = cx;
- nOldHeight = cy;
-
- // Update the status bar size
- GetWindowRect(hStatusBar, &rc);
- SendMessage(hStatusBar, WM_SIZE, nType, MAKELPARAM(cx, cy + (rc.bottom - rc.top)));
-
- // Update the status bar pane sizes
- nParts[0] = bInMenuLoop ? -1 : 100;
- nParts[1] = 210;
- nParts[2] = cx;
- SendMessage(hStatusBar, SB_SETPARTS, bInMenuLoop ? 1 : 3, (long)nParts);
- GetWindowRect(hStatusBar, &rc);
- MoveWindow(hTreeWnd,0,0,cx/2,cy-(rc.bottom - rc.top),TRUE);
- MoveWindow(hListWnd,cx/2,0,cx,cy-(rc.bottom - rc.top),TRUE);
-
-}
- */
-void OnEnterMenuLoop(HWND hWnd)
+static void OnEnterMenuLoop(HWND hWnd)
{
int nParts;
SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T(""));
}
-void OnExitMenuLoop(HWND hWnd)
+static void OnExitMenuLoop(HWND hWnd)
{
RECT rc;
int nParts[3];
nParts[2] = rc.right;
SendMessage(hStatusBar, SB_SETPARTS, 3, (long)nParts);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)_T(""));
+ SetupStatusBar(TRUE);
+ UpdateStatusBar();
}
-void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
+static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
{
TCHAR str[100];
- strcpy(str, TEXT(""));
+ _tcscpy(str, _T(""));
if (nFlags & MF_POPUP) {
if (hSysMenu != GetMenu(hWnd)) {
if (nItemID == 2) nItemID = 5;
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str);
}
+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);
+
+ // Create the status bar panes
+ nParts[0] = 150;
+ nParts[1] = 220;
+ nParts[2] = 100;
+ nParts[3] = 100;
+ if (bResize)
+ SendMessage(hStatusBar, WM_SIZE, 0, 0);
+ SendMessage(hStatusBar, SB_SETPARTS, 4, (long)nParts);
+}
+
+void UpdateStatusBar(void)
+{
+ TCHAR text[260];
+ DWORD size;
+
+// size = sizeof(text)/sizeof(TCHAR);
+// GetUserName(text, &size);
+// SendMessage(hStatusBar, SB_SETTEXT, 2, (LPARAM)text);
+ size = sizeof(text)/sizeof(TCHAR);
+ GetComputerName(text, &size);
+ SendMessage(hStatusBar, SB_SETTEXT, 3, (LPARAM)text);
+}
+
+static void toggle_child(HWND hWnd, UINT cmd, HWND hchild)
+{
+ BOOL vis = IsWindowVisible(hchild);
+ HMENU hMenuView = GetSubMenu(hMenuFrame, ID_VIEW_MENU);
+
+ CheckMenuItem(hMenuView, cmd, vis?MF_BYCOMMAND:MF_BYCOMMAND|MF_CHECKED);
+ ShowWindow(hchild, vis?SW_HIDE:SW_SHOW);
+ resize_frame_client(hWnd);
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: _CmdWndProc(HWND, unsigned, WORD, LONG)
static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- int wmId, wmEvent;
- wmId = LOWORD(wParam);
- wmEvent = HIWORD(wParam);
-
switch (LOWORD(wParam)) {
- // Parse the menu selections:
- case ID_REGISTRY_PRINTERSETUP:
- //PRINTDLG pd;
- //PrintDlg(&pd);
- //PAGESETUPDLG psd;
- //PageSetupDlg(&psd);
- break;
- case ID_REGISTRY_OPENLOCAL:
+ // Parse the menu selections:
+ case ID_REGISTRY_PRINTERSETUP:
+ //PRINTDLG pd;
+ //PrintDlg(&pd);
+ //PAGESETUPDLG psd;
+ //PageSetupDlg(&psd);
+ break;
+ case ID_REGISTRY_OPENLOCAL:
/*
{
HWND hChildWnd;
}
}
*/
- break;
- case ID_REGISTRY_EXIT:
- DestroyWindow(hWnd);
- break;
- case ID_VIEW_REFRESH:
- // TODO:
- break;
- case ID_HELP_HELPTOPICS:
-// WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);
- WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
- break;
- case ID_HELP_ABOUT:
+ break;
+ case ID_REGISTRY_EXIT:
+ DestroyWindow(hWnd);
+ break;
+ case ID_VIEW_REFRESH:
+ // TODO:
+ break;
+// case ID_OPTIONS_TOOLBAR:
+// toggle_child(hWnd, LOWORD(wParam), hToolBar);
+// break;
+ case ID_VIEW_STATUSBAR:
+ toggle_child(hWnd, LOWORD(wParam), hStatusBar);
+ break;
+ case ID_HELP_HELPTOPICS:
+// WinHelp(hWnd, _T("regedit"), HELP_CONTENTS, 0);
+ WinHelp(hWnd, _T("regedit"), HELP_FINDER, 0);
+ break;
+ case ID_HELP_ABOUT:
#ifdef WINSHELLAPI
- ShellAbout(hWnd, szTitle, "", LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));
+ ShellAbout(hWnd, szTitle, _T(""), LoadIcon(hInst, (LPCTSTR)IDI_REGEDIT));
#else
- ShowAboutBox(hWnd);
+ ShowAboutBox(hWnd);
#endif
- break;
- default:
- return FALSE;
+ break;
+ default:
+ return FALSE;
}
return TRUE;
}
+
////////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: FrameWndProc(HWND, unsigned, WORD, LONG)
//
LRESULT CALLBACK FrameWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- static int last_split;
- PAINTSTRUCT ps;
- HDC hdc;
-
switch (message) {
case WM_CREATE:
- //HWND CreateListView(HWND hwndParent/*, Pane* pane*/, int id, LPTSTR lpszPathName);
- hTreeWnd = CreateTreeView(hWnd, 1000, "c:\\foobar.txt");
- hListWnd = CreateListView(hWnd, 1001, "");
+ {
+// HMENU hMenuWindow = GetSubMenu(hMenuFrame, GetMenuItemCount(hMenuFrame)-2);
+ hChildWnd = CreateWindowEx(0, szChildClass, _T("regedit child window"),
+// hChildWnd = CreateWindowEx(0, (LPCTSTR)(int)hChildWndClass, _T("regedit child window"),
+// WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE|WS_BORDER,
+ WS_CHILD|WS_VISIBLE|WS_BORDER,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ hWnd, (HMENU)0, hInst, NULL/*lpParam*/);
+ }
break;
case WM_COMMAND:
if (!_CmdWndProc(hWnd, message, wParam, lParam)) {
}
break;
case WM_SIZE:
-// resize_frame_client(hWnd);
-// OnSize(wParam, LOWORD(lParam), HIWORD(lParam));
-// break;
- OnSize(wParam, lParam);
- goto def;
- case WM_PAINT:
- hdc = BeginPaint(hWnd, &ps);
- // TODO: Add any drawing code here...
- //RECT rt;
- //GetClientRect(hWnd, &rt);
- //DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER);
- EndPaint(hWnd, &ps);
- break;
+ resize_frame_client(hWnd);
break;
+// OnSize(wParam, lParam);
+// goto def;
case WM_TIMER:
break;
- case WM_SETCURSOR:
- if (LOWORD(lParam) == HTCLIENT) {
- POINT pt;
- GetCursorPos(&pt);
- ScreenToClient(hWnd, &pt);
- if (pt.x>=nSplitPos-SPLIT_WIDTH/2 && pt.x<nSplitPos+SPLIT_WIDTH/2+1) {
- SetCursor(LoadCursor(0, IDC_SIZEWE));
- return TRUE;
- }
- }
- goto def;
-
- case WM_LBUTTONDOWN: {
- RECT rt;
- int x = LOWORD(lParam);
-
- GetClientRect(hWnd, &rt);
- if (x>=nSplitPos-SPLIT_WIDTH/2 && x<nSplitPos+SPLIT_WIDTH/2+1) {
- last_split = nSplitPos;
-#ifdef _NO_EXTENSIONS
- draw_splitbar(hWnd, last_split);
-#endif
- SetCapture(hWnd);
- }
- break;}
-
- case WM_LBUTTONUP:
- if (GetCapture() == hWnd) {
-#ifdef _NO_EXTENSIONS
- RECT rt;
- int x = LOWORD(lParam);
- draw_splitbar(hWnd, last_split);
- last_split = -1;
- GetClientRect(hWnd, &rt);
- nSplitPos = x;
- ResizeWnd(rt.right, rt.bottom);
-#endif
- ReleaseCapture();
- }
- break;
-
-#ifdef _NO_EXTENSIONS
- case WM_CAPTURECHANGED:
- if (GetCapture()==hWnd && last_split>=0)
- draw_splitbar(hWnd, last_split);
- break;
-#endif
-
- case WM_KEYDOWN:
- if (wParam == VK_ESCAPE)
- if (GetCapture() == hWnd) {
- RECT rt;
-#ifdef _NO_EXTENSIONS
- draw_splitbar(hWnd, last_split);
-#else
- nSplitPos = last_split;
-#endif
- GetClientRect(hWnd, &rt);
- ResizeWnd(rt.right, rt.bottom);
- last_split = -1;
- ReleaseCapture();
- SetCursor(LoadCursor(0, IDC_ARROW));
- }
- break;
-
- case WM_MOUSEMOVE:
- if (GetCapture() == hWnd) {
- RECT rt;
- int x = LOWORD(lParam);
-
-#ifdef _NO_EXTENSIONS
- HDC hdc = GetDC(hWnd);
- GetClientRect(hWnd, &rt);
- rt.left = last_split-SPLIT_WIDTH/2;
- rt.right = last_split+SPLIT_WIDTH/2+1;
- InvertRect(hdc, &rt);
- last_split = x;
- rt.left = x-SPLIT_WIDTH/2;
- rt.right = x+SPLIT_WIDTH/2+1;
- InvertRect(hdc, &rt);
- ReleaseDC(hWnd, hdc);
-#else
- GetClientRect(hWnd, &rt);
- if (x>=0 && x<rt.right) {
- nSplitPos = x;
- ResizeWnd(rt.right, rt.bottom);
- rt.left = x-SPLIT_WIDTH/2;
- rt.right = x+SPLIT_WIDTH/2+1;
- InvalidateRect(hWnd, &rt, FALSE);
- UpdateWindow(hTreeWnd);
- UpdateWindow(hWnd);
- UpdateWindow(hListWnd);
- }
-#endif
- }
- break;
-
-
case WM_ENTERMENULOOP:
OnEnterMenuLoop(hWnd);
break;
case WM_DESTROY:
WinHelp(hWnd, _T("regedit"), HELP_QUIT, 0);
PostQuitMessage(0);
- default: def:
+ default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;