Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into windivs8-dev
  • Loading branch information
errortek committed Oct 23, 2023
2 parents f6ecb44 + a07e3aa commit 279f8a9
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 13 deletions.
1 change: 1 addition & 0 deletions base/applications/mspaint/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enum HITTEST // hit

/* FUNCTIONS ********************************************************/

void ShowOutOfMemory(void);
BOOL nearlyEqualPoints(INT x0, INT y0, INT x1, INT y1);
BOOL OpenMailer(HWND hWnd, LPCWSTR pszPathName);

Expand Down
3 changes: 3 additions & 0 deletions base/applications/mspaint/dib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile)
COLORREF white = RGB(255, 255, 255);
HBITMAP hBitmap = CreateColorDIB(registrySettings.BMPWidth, registrySettings.BMPHeight, white);
if (hBitmap == NULL)
{
ShowOutOfMemory();
return NULL;
}

HDC hScreenDC = ::GetDC(NULL);
g_xDpi = (float)::GetDeviceCaps(hScreenDC, LOGPIXELSX);
Expand Down
24 changes: 18 additions & 6 deletions base/applications/mspaint/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,24 @@ void ImageModel::ClearHistory()
m_redoSteps = 0;
}

void ImageModel::PushImageForUndo()
{
PushImageForUndo(CopyBitmap());
}

void ImageModel::PushImageForUndo(HBITMAP hbm)
{
ATLTRACE("%s: %d\n", __FUNCTION__, m_currInd);

if (hbm == NULL)
{
ShowOutOfMemory();
return;
}

// Go to the next item with an HBITMAP or current item
::DeleteObject(m_hBms[(m_currInd + 1) % HISTORYSIZE]);
m_hBms[(m_currInd + 1) % HISTORYSIZE] = (hbm ? hbm : CopyDIBImage(m_hBms[m_currInd]));
m_hBms[(m_currInd + 1) % HISTORYSIZE] = hbm;
m_currInd = (m_currInd + 1) % HISTORYSIZE;
::SelectObject(m_hDrawingDC, m_hBms[m_currInd]);

Expand All @@ -145,7 +156,10 @@ void ImageModel::Crop(int nWidth, int nHeight, int nOffsetX, int nOffsetY)
// Create an HBITMAP
HBITMAP hbmCropped = CreateDIBWithProperties(nWidth, nHeight);
if (!hbmCropped)
{
ShowOutOfMemory();
return;
}

// Select the HBITMAP by memory DC
HDC hdcMem = ::CreateCompatibleDC(m_hDrawingDC);
Expand Down Expand Up @@ -251,8 +265,7 @@ void ImageModel::RotateNTimes90Degrees(int iN)
case 3:
{
HBITMAP hbm = Rotate90DegreeBlt(m_hDrawingDC, GetWidth(), GetHeight(), iN == 1, FALSE);
if (hbm)
PushImageForUndo(hbm);
PushImageForUndo(hbm);
break;
}
case 2:
Expand Down Expand Up @@ -294,8 +307,7 @@ void ImageModel::PushBlackAndWhite()
HBITMAP hNewBitmap = ConvertToBlackAndWhite(hBitmap);
UnlockBitmap(hBitmap);

if (hNewBitmap)
PushImageForUndo(hNewBitmap);
PushImageForUndo(hNewBitmap);
}

HBITMAP ImageModel::LockBitmap()
Expand All @@ -319,7 +331,7 @@ void ImageModel::SelectionClone(BOOL bUndoable)
return;

if (bUndoable)
PushImageForUndo(CopyBitmap());
PushImageForUndo();

selectionModel.DrawSelection(m_hDrawingDC, paletteModel.GetBgColor(),
toolsModel.IsBackgroundTransparent());
Expand Down
3 changes: 2 additions & 1 deletion base/applications/mspaint/history.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class ImageModel
HDC GetDC();
BOOL CanUndo() const { return m_undoSteps > 0; }
BOOL CanRedo() const { return m_redoSteps > 0; }
void PushImageForUndo(HBITMAP hbm = NULL);
void PushImageForUndo();
void PushImageForUndo(HBITMAP hbm);
void ResetToPrevious(void);
void Undo(BOOL bClearRedo = FALSE);
void Redo(void);
Expand Down
15 changes: 15 additions & 0 deletions base/applications/mspaint/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ CMainWindow mainWindow;

/* FUNCTIONS ********************************************************/

void ShowOutOfMemory(void)
{
WCHAR szTitle[64];
::LoadStringW(NULL, IDS_PROGRAMNAME, szTitle, _countof(szTitle));

WCHAR szText[256];
::FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
ERROR_OUTOFMEMORY,
0,
szText, _countof(szText),
NULL);
mainWindow.MessageBox(szText, szTitle, MB_ICONERROR);
}

// get file name extension from filter string
static BOOL
FileExtFromFilter(LPTSTR pExt, OPENFILENAME *pOFN)
Expand Down
2 changes: 1 addition & 1 deletion dll/win32/shell32/CCopyToMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ CCopyToMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
HRESULT hr = E_FAIL;
TRACE("CCopyToMenu::InvokeCommand(%p)\n", lpici);

if (HIWORD(lpici->lpVerb) == 0)
if (IS_INTRESOURCE(lpici->lpVerb))
{
if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdCopyTo)
{
Expand Down
8 changes: 7 additions & 1 deletion dll/win32/shell32/CDefView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1922,9 +1922,15 @@ HRESULT CDefView::InvokeContextMenuCommand(CComPtr<IContextMenu> &pCM, UINT uCom

ZeroMemory(&cmi, sizeof(cmi));
cmi.cbSize = sizeof(cmi);
cmi.lpVerb = MAKEINTRESOURCEA(uCommand);
cmi.hwnd = m_hWnd;

if (uCommand == FCIDM_SHVIEW_COPYTO)
cmi.lpVerb = "copyto";
else if (uCommand == FCIDM_SHVIEW_MOVETO)
cmi.lpVerb = "moveto";
else
cmi.lpVerb = MAKEINTRESOURCEA(uCommand);

if (GetKeyState(VK_SHIFT) & 0x8000)
cmi.fMask |= CMIC_MASK_SHIFT_DOWN;

Expand Down
2 changes: 1 addition & 1 deletion dll/win32/shell32/CMoveToMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ CMoveToMenu::InvokeCommand(LPCMINVOKECOMMANDINFO lpici)
HRESULT hr = E_FAIL;
TRACE("CMoveToMenu::InvokeCommand(%p)\n", lpici);

if (HIWORD(lpici->lpVerb) == 0)
if (IS_INTRESOURCE(lpici->lpVerb))
{
if (m_idCmdFirst + LOWORD(lpici->lpVerb) == m_idCmdMoveTo)
{
Expand Down
7 changes: 4 additions & 3 deletions ntoskrnl/lpc/create.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ LpcpCreatePort(OUT PHANDLE PortHandle,
}
else
{
if (ObjectAttributes->ObjectName)
CapturedObjectName = *(ObjectAttributes->ObjectName);
ObjectName = ObjectAttributes->ObjectName;
if (ObjectName)
CapturedObjectName = *ObjectName;
}

/* Normalize the buffer pointer in case we don't have
Expand All @@ -96,7 +97,7 @@ LpcpCreatePort(OUT PHANDLE PortHandle,
/* Capture the port name for DPRINT only - ObCreateObject does its
* own capture. As it is used only for debugging, ignore any failure;
* the string is zeroed out in such case. */
ProbeAndCaptureUnicodeString(&CapturedPortName, PreviousMode, &CapturedObjectName);
ProbeAndCaptureUnicodeString(&CapturedPortName, PreviousMode, ObjectName);
LPCTRACE(LPC_CREATE_DEBUG, "Name: %wZ\n", &CapturedPortName);
ReleaseCapturedUnicodeString(&CapturedPortName, PreviousMode);
#endif
Expand Down

0 comments on commit 279f8a9

Please sign in to comment.