Commit 4cfa6a15 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

oleview: Added base menu funcionality.

parent 75469d71
......@@ -77,6 +77,7 @@ STRINGTABLE
IDS_APPTITLE "Wine OleView"
IDS_READY "Ready"
IDS_ABOUT "OleView - OLE/COM Object Viewer"
IDS_ABOUTVER "version 1.0"
IDM_BIND, "Bind to file via a File Moniker"
IDM_TYPELIB, "Open a TypeLib file and view the contents"
......
......@@ -48,6 +48,7 @@ typedef struct
HWND hStatusBar;
HWND hToolBar;
HINSTANCE hMainInst;
BOOL bExpert;
DWORD dwClsCtx;
}GLOBALS;
......@@ -88,6 +89,9 @@ extern GLOBALS globals;
extern TREE tree;
/* Predefinitions: */
/* oleview.c */
void RefreshMenu(HTREEITEM item);
/* pane.c */
BOOL CreatePanedWindow(HWND hWnd, HWND *hWndCreated, HINSTANCE hInst);
void SetLeft(HWND hParent, HWND hWnd);
......@@ -95,4 +99,8 @@ void SetRight(HWND hParent, HWND hWnd);
/* tree.h */
void EmptyTree(void);
void AddTreeEx(void);
void AddTree(void);
HWND CreateTreeWindow(HINSTANCE hInst);
void CreateInst(HTREEITEM item);
void ReleaseInst(HTREEITEM item);
......@@ -21,6 +21,7 @@
#include "main.h"
GLOBALS globals;
static WCHAR wszRegEdit[] = { 'r','e','g','e','d','i','t','.','e','x','e','\0' };
void ResizeChild(void)
{
......@@ -45,6 +46,178 @@ void ResizeChild(void)
client.right, client.bottom-tool.bottom-stat.bottom, TRUE);
}
void RefreshMenu(HTREEITEM item)
{
TVITEM tvi;
HTREEITEM parent;
HMENU hMenu = GetMenu(globals.hMainWnd);
memset(&tvi, 0, sizeof(TVITEM));
tvi.hItem = item;
SendMessage(globals.hTree, TVM_GETITEM, 0, (LPARAM)&tvi);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, FALSE);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, FALSE);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, FALSE);
if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag&SHOWALL)
{
EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
EnableMenuItem(hMenu, IDM_HTMLTAG, MF_ENABLED);
EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
if(!((ITEM_INFO *)tvi.lParam)->loaded)
{
EnableMenuItem(hMenu, IDM_CREATEINST, MF_ENABLED);
EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_ENABLED);
EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_CREATEINST, TRUE);
}
else
{
EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
EnableMenuItem(hMenu, IDM_RELEASEINST, MF_ENABLED);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_RELEASEINST, TRUE);
}
}
else if(tvi.lParam && ((ITEM_INFO *)tvi.lParam)->cFlag&INTERFACE)
{
EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
EnableMenuItem(hMenu, IDM_VIEW, MF_ENABLED);
SendMessage(globals.hToolBar, TB_ENABLEBUTTON, IDM_VIEW, TRUE);
}
else
{
EnableMenuItem(hMenu, IDM_TYPEINFO, MF_GRAYED);
EnableMenuItem(hMenu, IDM_CREATEINST, MF_GRAYED);
EnableMenuItem(hMenu, IDM_CREATEINSTON, MF_GRAYED);
EnableMenuItem(hMenu, IDM_RELEASEINST, MF_GRAYED);
EnableMenuItem(hMenu, IDM_COPYCLSID, MF_GRAYED);
EnableMenuItem(hMenu, IDM_HTMLTAG, MF_GRAYED);
EnableMenuItem(hMenu, IDM_VIEW, MF_GRAYED);
}
parent = TreeView_GetParent(globals.hTree, item);
if(parent==tree.hAID || parent==tree.hGBCC)
EnableMenuItem(hMenu, IDM_COPYCLSID, MF_ENABLED);
}
int MenuCommand(WPARAM wParam, HWND hWnd)
{
BOOL vis;
HTREEITEM hSelect;
WCHAR wszAbout[MAX_LOAD_STRING];
WCHAR wszAboutVer[MAX_LOAD_STRING];
switch(wParam)
{
case IDM_ABOUT:
LoadString(globals.hMainInst, IDS_ABOUT, wszAbout,
sizeof(WCHAR[MAX_LOAD_STRING]));
LoadString(globals.hMainInst, IDS_ABOUTVER, wszAboutVer,
sizeof(WCHAR[MAX_LOAD_STRING]));
ShellAbout(hWnd, wszAbout, wszAboutVer, NULL);
break;
case IDM_CREATEINST:
hSelect = TreeView_GetSelection(globals.hTree);
CreateInst(hSelect);
SendMessage(globals.hTree, TVM_EXPAND, TVE_EXPAND, (LPARAM)hSelect);
break;
case IDM_RELEASEINST:
hSelect = TreeView_GetSelection(globals.hTree);
ReleaseInst(hSelect);
RefreshMenu(hSelect);
break;
case IDM_EXPERT:
globals.bExpert = !globals.bExpert;
CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
globals.bExpert ? MF_CHECKED : MF_UNCHECKED);
EmptyTree();
if(globals.bExpert) AddTreeEx();
else AddTree();
hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT);
SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
RefreshMenu(hSelect);
break;
case IDM_FLAG_INSERV:
vis = globals.dwClsCtx&CLSCTX_INPROC_SERVER;
globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_SERVER);
globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_SERVER);
if(!globals.dwClsCtx) globals.dwClsCtx = vis;
else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
break;
case IDM_FLAG_INHANDL:
vis = globals.dwClsCtx&CLSCTX_INPROC_HANDLER;
globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_INPROC_HANDLER);
globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_INPROC_HANDLER);
if(!globals.dwClsCtx) globals.dwClsCtx = vis;
else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
break;
case IDM_FLAG_LOCSERV:
vis = globals.dwClsCtx&CLSCTX_LOCAL_SERVER;
globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_LOCAL_SERVER);
globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_LOCAL_SERVER);
if(!globals.dwClsCtx) globals.dwClsCtx = vis;
else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
break;
case IDM_FLAG_REMSERV:
vis = globals.dwClsCtx&CLSCTX_REMOTE_SERVER;
globals.dwClsCtx = globals.dwClsCtx&(~CLSCTX_REMOTE_SERVER);
globals.dwClsCtx = globals.dwClsCtx|((~vis)&CLSCTX_REMOTE_SERVER);
if(!globals.dwClsCtx) globals.dwClsCtx = vis;
else CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
break;
case IDM_REFRESH:
EmptyTree();
if(globals.bExpert) AddTreeEx();
else AddTree();
hSelect = TreeView_GetChild(globals.hTree, TVI_ROOT);
SendMessage(globals.hTree, TVM_SELECTITEM, 0, (LPARAM)hSelect);
RefreshMenu(hSelect);
break;
case IDM_REGEDIT:
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
memset(&si, 0, sizeof(si));
si.cb = sizeof(si);
CreateProcess(NULL, wszRegEdit, NULL, NULL, FALSE, 0,\
NULL, NULL, &si, &pi);
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
break;
}
case IDM_STATUSBAR:
vis = IsWindowVisible(globals.hStatusBar);
ShowWindow(globals.hStatusBar, vis ? SW_HIDE : SW_SHOW);
CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
ResizeChild();
break;
case IDM_TOOLBAR:
vis = IsWindowVisible(globals.hToolBar);
ShowWindow(globals.hToolBar, vis ? SW_HIDE : SW_SHOW);
CheckMenuItem(GetMenu(hWnd), LOWORD(wParam),
vis ? MF_UNCHECKED : MF_CHECKED);
ResizeChild();
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
}
return 0;
}
void UpdateStatusBar(int itemID)
{
WCHAR info[MAX_LOAD_STRING];
......@@ -67,6 +240,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
SetLeft(globals.hPaneWnd, CreateTreeWindow(globals.hMainInst));
SetFocus(globals.hTree);
break;
case WM_COMMAND:
MenuCommand(LOWORD(wParam), hWnd);
break;
case WM_DESTROY:
OleUninitialize();
EmptyTree();
......@@ -143,6 +319,7 @@ BOOL InitInstance(HINSTANCE hInst, int nCmdShow)
globals.hMainWnd = hWnd;
globals.hMainInst = hInst;
globals.bExpert = TRUE;
globals.dwClsCtx = CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER;
ShowWindow(hWnd, nCmdShow);
......
......@@ -26,6 +26,7 @@
#define IDS_READY 10
#define IDS_ABOUT 20
#define IDS_ABOUTVER 21
#define IDM_BIND 100
#define IDM_TYPELIB 101
......
......@@ -159,6 +159,8 @@ void CreateInst(HTREEITEM item)
}
hCur = TreeView_GetNextSibling(globals.hTree, hCur);
}
RefreshMenu(item);
}
void ReleaseInst(HTREEITEM item)
......@@ -636,6 +638,9 @@ LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case TVN_ITEMEXPANDING:
CreateInst(((NMTREEVIEW *)lParam)->itemNew.hItem);
break;
case TVN_SELCHANGED:
RefreshMenu(((NMTREEVIEW *)lParam)->itemNew.hItem);
break;
}
break;
case WM_SIZE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment