regedit: Convert menu & statusbar handling to unicode.

This commit is contained in:
Alexander Nicolaysen Sørnes 2008-08-26 19:55:35 +02:00 committed by Alexandre Julliard
parent 918303a308
commit 46ea43e677
2 changed files with 23 additions and 18 deletions

View File

@ -31,6 +31,7 @@
#include "main.h" #include "main.h"
#include "regproc.h" #include "regproc.h"
#include "wine/unicode.h"
/******************************************************************************** /********************************************************************************
* Global and Local Variables: * Global and Local Variables:
@ -82,12 +83,13 @@ static void resize_frame_client(HWND hWnd)
static void OnEnterMenuLoop(HWND hWnd) static void OnEnterMenuLoop(HWND hWnd)
{ {
int nParts; int nParts;
WCHAR empty = 0;
/* Update the status bar pane sizes */ /* Update the status bar pane sizes */
nParts = -1; nParts = -1;
SendMessage(hStatusBar, SB_SETPARTS, 1, (long)&nParts); SendMessageW(hStatusBar, SB_SETPARTS, 1, (long)&nParts);
bInMenuLoop = TRUE; bInMenuLoop = TRUE;
SendMessage(hStatusBar, SB_SETTEXT, (WPARAM)0, (LPARAM)_T("")); SendMessageW(hStatusBar, SB_SETTEXTW, (WPARAM)0, (LPARAM)&empty);
} }
static void OnExitMenuLoop(HWND hWnd) static void OnExitMenuLoop(HWND hWnd)
@ -102,8 +104,8 @@ static void UpdateMenuItems(HMENU hMenu) {
HWND hwndTV = g_pChildWnd->hTreeWnd; HWND hwndTV = g_pChildWnd->hTreeWnd;
BOOL bAllowEdit = FALSE; BOOL bAllowEdit = FALSE;
HKEY hRootKey = NULL; HKEY hRootKey = NULL;
LPCTSTR keyName; LPWSTR keyName;
keyName = GetItemPath(hwndTV, TreeView_GetSelection(hwndTV), &hRootKey); keyName = GetItemPathW(hwndTV, TreeView_GetSelection(hwndTV), &hRootKey);
if (GetFocus() != hwndTV || (keyName && *keyName)) { /* can't modify root keys, but allow for their values */ if (GetFocus() != hwndTV || (keyName && *keyName)) { /* can't modify root keys, but allow for their values */
bAllowEdit = TRUE; bAllowEdit = TRUE;
} }
@ -115,6 +117,8 @@ static void UpdateMenuItems(HMENU hMenu) {
EnableMenuItem(hMenu, ID_FAVORITES_ADDTOFAVORITES, (hRootKey ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); EnableMenuItem(hMenu, ID_FAVORITES_ADDTOFAVORITES, (hRootKey ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE, EnableMenuItem(hMenu, ID_FAVORITES_REMOVEFAVORITE,
(GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND); (GetMenuItemCount(hMenu)>2 ? MF_ENABLED : MF_GRAYED) | MF_BYCOMMAND);
HeapFree(GetProcessHeap(), 0, keyName);
} }
static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem) static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
@ -154,23 +158,23 @@ static void OnInitMenuPopup(HWND hWnd, HMENU hMenu, short wItem)
static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu) static void OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu)
{ {
TCHAR str[100]; WCHAR str[100];
_tcscpy(str, _T("")); str[0] = 0;
if (nFlags & MF_POPUP) { if (nFlags & MF_POPUP) {
if (hSysMenu != GetMenu(hWnd)) { if (hSysMenu != GetMenu(hWnd)) {
if (nItemID == 2) nItemID = 5; if (nItemID == 2) nItemID = 5;
} }
} }
if (LoadString(hInst, nItemID, str, 100)) { if (LoadStringW(hInst, nItemID, str, 100)) {
/* load appropriate string*/ /* load appropriate string*/
LPTSTR lpsz = str; LPWSTR lpsz = str;
/* first newline terminates actual string*/ /* first newline terminates actual string*/
lpsz = _tcschr(lpsz, '\n'); lpsz = strchrW(lpsz, '\n');
if (lpsz != NULL) if (lpsz != NULL)
*lpsz = '\0'; *lpsz = '\0';
} }
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)str); SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)str);
} }
void SetupStatusBar(HWND hWnd, BOOL bResize) void SetupStatusBar(HWND hWnd, BOOL bResize)
@ -181,15 +185,15 @@ void SetupStatusBar(HWND hWnd, BOOL bResize)
nParts = rc.right; nParts = rc.right;
/* nParts = -1;*/ /* nParts = -1;*/
if (bResize) if (bResize)
SendMessage(hStatusBar, WM_SIZE, 0, 0); SendMessageW(hStatusBar, WM_SIZE, 0, 0);
SendMessage(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts); SendMessageW(hStatusBar, SB_SETPARTS, 1, (LPARAM)&nParts);
UpdateStatusBar(); UpdateStatusBar();
} }
void UpdateStatusBar(void) void UpdateStatusBar(void)
{ {
LPTSTR fullPath = GetItemFullPath(g_pChildWnd->hTreeWnd, NULL, TRUE); LPWSTR fullPath = GetItemFullPathW(g_pChildWnd->hTreeWnd, NULL, TRUE);
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)fullPath); SendMessageW(hStatusBar, SB_SETTEXTW, 0, (LPARAM)fullPath);
HeapFree(GetProcessHeap(), 0, fullPath); HeapFree(GetProcessHeap(), 0, fullPath);
} }

View File

@ -80,6 +80,7 @@ const TCHAR szChildClass[] = {'R','E','G','E','D','I','T',0};
static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{ {
WCHAR empty = 0;
WNDCLASSEX wcFrame = { WNDCLASSEX wcFrame = {
sizeof(WNDCLASSEX), sizeof(WNDCLASSEX),
CS_HREDRAW | CS_VREDRAW/*style*/, CS_HREDRAW | CS_VREDRAW/*style*/,
@ -116,8 +117,8 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */ ATOM hChildWndClass = RegisterClassEx(&wcChild); /* register child windows class */
hChildWndClass = hChildWndClass; /* warning eater */ hChildWndClass = hChildWndClass; /* warning eater */
hMenuFrame = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_REGEDIT_MENU)); hMenuFrame = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_REGEDIT_MENU));
hPopupMenus = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_POPUP_MENUS)); hPopupMenus = LoadMenuW(hInstance, MAKEINTRESOURCEW(IDR_POPUP_MENUS));
/* Initialize the Windows Common Controls DLL */ /* Initialize the Windows Common Controls DLL */
InitCommonControls(); InitCommonControls();
@ -140,8 +141,8 @@ static BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
} }
/* Create the status bar */ /* Create the status bar */
hStatusBar = CreateStatusWindow(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS, hStatusBar = CreateStatusWindowW(WS_VISIBLE|WS_CHILD|WS_CLIPSIBLINGS|SBT_NOBORDERS,
_T(""), hFrameWnd, STATUS_WINDOW); &empty, hFrameWnd, STATUS_WINDOW);
if (hStatusBar) { if (hStatusBar) {
/* Create the status bar panes */ /* Create the status bar panes */
SetupStatusBar(hFrameWnd, FALSE); SetupStatusBar(hFrameWnd, FALSE);