mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-30 19:26:05 +00:00
- Complete overhaul of imagesoft from Thomas Weidenmueller
- Includes the addition of docking toolbars using the Win32 API svn path=/trunk/; revision=21201
This commit is contained in:
@@ -2,62 +2,67 @@ IDR_MAINMENU MENU
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "New...", ID_NEW
|
||||
MENUITEM "Open...", ID_OPEN
|
||||
MENUITEM "Close", ID_CLOSE, GRAYED
|
||||
MENUITEM "Close all", ID_CLOSEALL, GRAYED
|
||||
MENUITEM "&New...", ID_NEW
|
||||
MENUITEM "&Open...", ID_OPEN
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Save", ID_SAVE, GRAYED
|
||||
MENUITEM "Save As", ID_SAVEAS, GRAYED
|
||||
MENUITEM "&Close\tCtrl+F4", ID_CLOSE, GRAYED
|
||||
MENUITEM "C&lose all", ID_CLOSEALL, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Print Preview", ID_PRINTPRE, GRAYED
|
||||
MENUITEM "Print...", ID_PRINT, GRAYED
|
||||
MENUITEM "&Save", ID_SAVE, GRAYED
|
||||
MENUITEM "Save &As...", ID_SAVEAS, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Properties...", ID_PROP, GRAYED
|
||||
MENUITEM "Print Pre&view", ID_PRINTPRE, GRAYED
|
||||
MENUITEM "&Print...", ID_PRINT, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", ID_EXIT
|
||||
MENUITEM "Pr&operties...", ID_PROP, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tAlt+F4", ID_EXIT
|
||||
END
|
||||
POPUP "Edit"
|
||||
POPUP "&Edit"
|
||||
BEGIN
|
||||
MENUITEM "Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "Redo", ID_REDO, GRAYED
|
||||
MENUITEM "&Undo", ID_UNDO, GRAYED
|
||||
MENUITEM "&Redo", ID_REDO, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Cut", ID_CUT, GRAYED
|
||||
MENUITEM "Copy", ID_COPY, GRAYED
|
||||
MENUITEM "Paste", ID_PASTE, GRAYED
|
||||
MENUITEM "Paste as new image",ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM "Cu&t", ID_CUT, GRAYED
|
||||
MENUITEM "&Copy", ID_COPY, GRAYED
|
||||
MENUITEM "&Paste", ID_PASTE, GRAYED
|
||||
MENUITEM "Paste as new &image", ID_PASTENEWIMAGE, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select All", ID_SELALL, GRAYED
|
||||
MENUITEM "Select &All", ID_SELALL, GRAYED
|
||||
END
|
||||
POPUP "View"
|
||||
POPUP "&View"
|
||||
BEGIN
|
||||
MENUITEM "Tools", ID_TOOLS, CHECKED
|
||||
MENUITEM "Status Bar", ID_STATUSBAR, CHECKED
|
||||
MENUITEM "&Tools", ID_TOOLS, CHECKED
|
||||
MENUITEM "&Status Bar", ID_STATUSBAR, CHECKED
|
||||
END
|
||||
POPUP "Image"
|
||||
POPUP "&Image"
|
||||
BEGIN
|
||||
MENUITEM "Crop", -1, GRAYED
|
||||
MENUITEM "Resize", -1, GRAYED
|
||||
MENUITEM "Rotate", -1, GRAYED
|
||||
MENUITEM "Flip", -1, GRAYED
|
||||
MENUITEM "Stretch", -1, GRAYED
|
||||
MENUITEM "Skew", -1, GRAYED
|
||||
MENUITEM "Invert Colours", -1, GRAYED
|
||||
MENUITEM "&Crop...", -1, GRAYED
|
||||
MENUITEM "&Resize...", -1, GRAYED
|
||||
MENUITEM "R&otate...", -1, GRAYED
|
||||
MENUITEM "&Flip...", -1, GRAYED
|
||||
MENUITEM "&Stretch...", -1, GRAYED
|
||||
MENUITEM "S&kew...", -1, GRAYED
|
||||
MENUITEM "&Invert Colors", -1, GRAYED
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Attributes", -1, GRAYED
|
||||
MENUITEM "&Attributes...", -1, GRAYED
|
||||
END
|
||||
POPUP "Colours"
|
||||
POPUP "&Colors"
|
||||
BEGIN
|
||||
MENUITEM "Edit Colours...", ID_EDITCOLOURS
|
||||
MENUITEM "&Edit Colors...", ID_EDITCOLOURS
|
||||
END
|
||||
POPUP "Window"
|
||||
POPUP "&Window"
|
||||
BEGIN
|
||||
MENUITEM "Tile", -1
|
||||
MENUITEM "Cascade", -1
|
||||
MENUITEM "&Cascade", ID_WINDOW_CASCADE
|
||||
MENUITEM "Tile &Horizontally", ID_WINDOW_TILE_HORZ
|
||||
MENUITEM "Tile &Vertiacally", ID_WINDOW_TILE_VERT
|
||||
MENUITEM "&Arrange Icons", ID_WINDOW_ARRANGE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Nex&t\tCtrl+F6", ID_WINDOW_NEXT
|
||||
END
|
||||
POPUP "Help"
|
||||
POPUP "&Help"
|
||||
BEGIN
|
||||
MENUITEM "About...", ID_ABOUT
|
||||
MENUITEM "&About...", ID_ABOUT
|
||||
END
|
||||
END
|
||||
|
||||
@@ -108,14 +113,13 @@ END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_APPNAME "ImageSoft"
|
||||
IDS_LICENSE "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.\r\n\r\nThis 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.\r\n\r\nYou 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."
|
||||
END
|
||||
|
||||
/* status bar info */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_CURPOS "Cursor : %d,%d"
|
||||
IDS_READY "Ready"
|
||||
IDS_READY " Ready."
|
||||
|
||||
IDS_TOOLBAR_STANDARD "Standard"
|
||||
IDS_TOOLBAR_TEST "Test"
|
||||
IDS_IMAGE_NAME "Image %1!u!"
|
||||
END
|
||||
|
||||
/* Tooltips */
|
||||
@@ -132,3 +136,18 @@ BEGIN
|
||||
IDS_TOOLTIP_UNDO "Undo"
|
||||
IDS_TOOLTIP_REDO "Redo"
|
||||
END
|
||||
|
||||
/* Hints */
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_HINT_EXIT " Exits this application."
|
||||
|
||||
IDS_HINT_SYS_RESTORE " Restores this window to normal size."
|
||||
IDS_HINT_SYS_MOVE " Moves this window."
|
||||
IDS_HINT_SYS_SIZE " Resizes this window."
|
||||
IDS_HINT_SYS_MINIMIZE " Collapses this window to an icon."
|
||||
IDS_HINT_SYS_MAXIMIZE " Expands this window to fill this screen."
|
||||
IDS_HINT_SYS_CLOSE " Closes this window."
|
||||
IDS_HINT_SYS_NEXT " Activates the next window."
|
||||
END
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include "imagesoft.h"
|
||||
|
||||
extern HINSTANCE hInstance;
|
||||
#include <precomp.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4100)
|
||||
#endif
|
||||
BOOL CALLBACK
|
||||
INT_PTR CALLBACK
|
||||
AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
HWND hLicenseEditWnd;
|
||||
|
||||
@@ -1,787 +1,78 @@
|
||||
#include "imagesoft.h"
|
||||
|
||||
#define ID_MDI_FIRSTCHILD 50000
|
||||
|
||||
const TCHAR AppClassName[] = _T("Parent");
|
||||
const TCHAR ChildClassName[] = _T("Child");
|
||||
|
||||
#include <precomp.h>
|
||||
|
||||
HINSTANCE hInstance;
|
||||
HWND hMainWnd;
|
||||
HWND hMDIClient;
|
||||
HWND hStatus;
|
||||
HWND hTool;
|
||||
HWND hFloatTool;
|
||||
HMENU hShortcutMenu;
|
||||
|
||||
WORD cxClient;
|
||||
WORD cyClient;
|
||||
|
||||
/*
|
||||
* Initialize the structure and send a message to the MDI
|
||||
* frame requesting a new new child window.
|
||||
*/
|
||||
HWND CreateNewMDIChild(HWND hMDIClient)
|
||||
{
|
||||
MDICREATESTRUCT mcs;
|
||||
HWND hChild;
|
||||
TCHAR Buf[15];
|
||||
static DWORD MDINum = 1;
|
||||
DWORD style;
|
||||
|
||||
_sntprintf(Buf, sizeof(Buf) / sizeof(TCHAR), _T("Untitled%d"), MDINum);
|
||||
|
||||
style = 0;//MDIS_ALLCHILDSTYLES & ~WS_BORDER;
|
||||
|
||||
mcs.szTitle = Buf;
|
||||
mcs.szClass = ChildClassName;
|
||||
mcs.hOwner = hInstance;
|
||||
mcs.x = mcs.cx = CW_USEDEFAULT;
|
||||
mcs.y = mcs.cy = CW_USEDEFAULT;
|
||||
mcs.style = style; //MDIS_ALLCHILDSTYLES | WS_MAXIMIZE;
|
||||
|
||||
hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LPARAM)&mcs);
|
||||
if(!hChild)
|
||||
{
|
||||
MessageBox(hMDIClient, _T("MDI Child creation failed."), _T("Error!"),
|
||||
MB_ICONEXCLAMATION | MB_OK);
|
||||
return hChild;
|
||||
}
|
||||
|
||||
MDINum++;
|
||||
return hChild;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main program message handler
|
||||
*/
|
||||
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
{
|
||||
CLIENTCREATESTRUCT ccs;
|
||||
TBADDBITMAP tbab;
|
||||
HMENU hMenu;
|
||||
INT iImageOffset;
|
||||
INT statwidths[] = {300, 450, 550, -1}; /* widths of status bar */
|
||||
TCHAR Buf[6];
|
||||
|
||||
/* Standard toolbar buttons */
|
||||
TBBUTTON StdButtons [NUM_BUTTONS] =
|
||||
{
|
||||
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||
{STD_FILENEW, ID_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, /* new */
|
||||
{STD_FILEOPEN, ID_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* open */
|
||||
{STD_FILESAVE, ID_SAVE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0}, /* save */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_PRINTPRE, ID_PRINTPRE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* print */
|
||||
{STD_PRINT, ID_PRINT, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* print preview */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_CUT, ID_CUT, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* cut */
|
||||
{STD_COPY, ID_COPY, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* copy */
|
||||
{STD_PASTE, ID_PASTE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* paste */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_UNDO, ID_UNDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* undo */
|
||||
{STD_REDOW, ID_REDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* redo */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
/* ======================== Create Std Toolbar ============================== */
|
||||
|
||||
/* Create Toolbar */
|
||||
hTool = CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
|
||||
0, 0, 0, 0,
|
||||
hwnd,
|
||||
(HMENU)IDC_TOOLBAR,
|
||||
hInstance,
|
||||
NULL);
|
||||
if(hTool == NULL)
|
||||
MessageBox(hwnd, _T("Could not create tool bar."), _T("Error!"), MB_OK | MB_ICONERROR);
|
||||
|
||||
/* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */
|
||||
SendMessage(hTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
|
||||
/* Add standard images */
|
||||
tbab.hInst = HINST_COMMCTRL;
|
||||
tbab.nID = IDB_STD_SMALL_COLOR;
|
||||
SendMessage(hTool, TB_ADDBITMAP, NUM_BUTTONS, (LPARAM)&tbab);
|
||||
|
||||
/* Add buttons to toolbar */
|
||||
SendMessage(hTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &StdButtons);
|
||||
|
||||
/* Show toolbar */
|
||||
ShowWindow(hTool, SW_SHOW);
|
||||
|
||||
|
||||
|
||||
/* ======================== Create Floating Toolbar ============================== */
|
||||
|
||||
hFloatTool = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_TOOLBAR),
|
||||
hwnd, (DLGPROC)ToolDlgProc);
|
||||
if(hFloatTool != NULL)
|
||||
{
|
||||
;//ShowWindow(hFloatTool, SW_SHOW);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hwnd, _T("CreateDialog returned NULL"), _T("Warning!"),
|
||||
MB_OK | MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
/* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */
|
||||
SendMessage(hFloatTool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
|
||||
/* Add custom images */
|
||||
tbab.hInst = HINST_COMMCTRL;
|
||||
tbab.nID = IDB_STD_SMALL_COLOR;
|
||||
iImageOffset = (INT)SendMessage(hFloatTool, TB_ADDBITMAP, 10, (LPARAM)&tbab);
|
||||
|
||||
/* StdButtons[0].iBitmap += iImageOffset; / * properties * /
|
||||
StdButtons[1].iBitmap += iImageOffset; / * refresh * /
|
||||
StdButtons[2].iBitmap += iImageOffset; / * export * /
|
||||
StdButtons[4].iBitmap += iImageOffset; / * create * /
|
||||
StdButtons[6].iBitmap += iImageOffset; / * start * /
|
||||
StdButtons[7].iBitmap += iImageOffset; / * stop * /
|
||||
StdButtons[8].iBitmap += iImageOffset; / * pause * /
|
||||
StdButtons[9].iBitmap += iImageOffset; / * restart * /
|
||||
StdButtons[11].iBitmap += iImageOffset; / * help * /
|
||||
StdButtons[12].iBitmap += iImageOffset; / * exit * /
|
||||
*/
|
||||
|
||||
/* Add buttons to toolbar */
|
||||
SendMessage(hFloatTool, TB_ADDBUTTONS, NUM_BUTTONS, (LPARAM) &StdButtons);
|
||||
|
||||
/* Show toolbar */
|
||||
//ShowWindow(hFloatTool, SW_SHOWNORMAL);
|
||||
|
||||
|
||||
|
||||
/* ======================== Create Status Bar ============================== */
|
||||
|
||||
hStatus = CreateWindowEx(0,
|
||||
STATUSCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
|
||||
0, 0, 0, 0,
|
||||
hwnd,
|
||||
(HMENU)IDC_STATUSBAR,
|
||||
hInstance,
|
||||
NULL);
|
||||
if(hStatus == NULL)
|
||||
MessageBox(hwnd, _T("Could not create status bar."),
|
||||
_T("Error!"), MB_OK | MB_ICONERROR);
|
||||
|
||||
SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
|
||||
|
||||
|
||||
/* ======================== Create Popup Menu ============================== */
|
||||
|
||||
hShortcutMenu = LoadMenu(hInstance, MAKEINTRESOURCE (IDR_POPUP));
|
||||
hShortcutMenu = GetSubMenu(hShortcutMenu, 0);
|
||||
|
||||
|
||||
/* ======================= Create MDI Client ============================= */
|
||||
|
||||
/* Find window menu where children will be listed */
|
||||
ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 5);
|
||||
ccs.idFirstChild = ID_MDI_FIRSTCHILD;
|
||||
|
||||
hMDIClient = CreateWindowEx(WS_EX_CLIENTEDGE,
|
||||
_T("mdiclient"),
|
||||
NULL,
|
||||
WS_CHILD | WS_CLIPCHILDREN | WS_VSCROLL | WS_HSCROLL | WS_VISIBLE,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
hwnd,
|
||||
(HMENU)IDC_MAIN_MDI,
|
||||
GetModuleHandle(NULL),
|
||||
(LPVOID)&ccs);
|
||||
|
||||
|
||||
if(hMDIClient == NULL)
|
||||
MessageBox(hwnd, _T("Could not create MDI client."),
|
||||
_T("Error!"), MB_OK | MB_ICONERROR);
|
||||
|
||||
|
||||
/* ======================= Miscelaneous ============================= */
|
||||
|
||||
hMenu = GetMenu(hwnd);
|
||||
|
||||
EnableMenuItem(hMenu, 1, MF_DELETE); /* edit */
|
||||
EnableMenuItem(hMenu, 2, MF_REMOVE); /* image */
|
||||
EnableMenuItem(hMenu, 3, MF_BYPOSITION | MF_REMOVE); /* colours */
|
||||
EnableMenuItem(hMenu, 4, MF_BYPOSITION | MF_DELETE); /* window */
|
||||
|
||||
|
||||
/* indicate program is ready in the status bar */
|
||||
LoadString(hInstance, IDS_READY, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)Buf);
|
||||
|
||||
/* inilalize file open/save structure */
|
||||
FileInitialize(hwnd);
|
||||
|
||||
//Style = GetWindowLong(hwnd, GWL_STYLE);
|
||||
|
||||
//SetWindowLong(hwnd, GWL_STYLE, (Style & DS_CENTER));
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
RECT rcTool;
|
||||
int iToolHeight;
|
||||
|
||||
RECT rcStatus;
|
||||
int iStatusHeight;
|
||||
|
||||
HWND hMDI;
|
||||
int iMDIHeight;
|
||||
RECT rcClient;
|
||||
|
||||
cxClient = LOWORD(lParam);
|
||||
cyClient = HIWORD(lParam);
|
||||
|
||||
/* Size toolbar and get height */
|
||||
hTool = GetDlgItem(hwnd, IDC_TOOLBAR);
|
||||
SendMessage(hTool, TB_AUTOSIZE, 0, 0);
|
||||
|
||||
GetWindowRect(hTool, &rcTool);
|
||||
iToolHeight = rcTool.bottom - rcTool.top;
|
||||
|
||||
/* Size status bar and get height */
|
||||
hStatus = GetDlgItem(hwnd, IDC_STATUSBAR);
|
||||
GetWindowRect(hStatus, &rcStatus);
|
||||
iStatusHeight = rcStatus.bottom - rcStatus.top;
|
||||
|
||||
/* Calculate remaining height and size for the MDI frame */
|
||||
GetClientRect(hwnd, &rcClient);
|
||||
|
||||
iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
|
||||
|
||||
hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI);
|
||||
SetWindowPos(hMDIClient, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
NMHDR* nm = (NMHDR*) lParam;
|
||||
|
||||
switch (nm->code)
|
||||
{
|
||||
case TTN_GETDISPINFO:
|
||||
{
|
||||
LPTOOLTIPTEXT lpttt;
|
||||
UINT idButton;
|
||||
|
||||
lpttt = (LPTOOLTIPTEXT) lParam;
|
||||
|
||||
/* Specify the resource identifier of the descriptive
|
||||
* text for the given button. */
|
||||
idButton = (UINT)lpttt->hdr.idFrom;
|
||||
switch (idButton)
|
||||
{
|
||||
case ID_NEW:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW);
|
||||
break;
|
||||
|
||||
case ID_OPEN:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_OPEN);
|
||||
break;
|
||||
|
||||
case ID_SAVE:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SAVE);
|
||||
break;
|
||||
|
||||
case ID_PRINTPRE:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINTPRE);
|
||||
break;
|
||||
|
||||
case ID_PRINT:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINT);
|
||||
break;
|
||||
|
||||
case ID_CUT:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_CUT);
|
||||
break;
|
||||
|
||||
case ID_COPY:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_COPY);
|
||||
break;
|
||||
|
||||
case ID_PASTE:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PASTE);
|
||||
break;
|
||||
|
||||
case ID_UNDO:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNDO);
|
||||
break;
|
||||
|
||||
case ID_REDO:
|
||||
lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REDO);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
/*
|
||||
case WM_CONTEXTMENU:
|
||||
{
|
||||
int xPos, yPos;
|
||||
|
||||
xPos = GET_X_LPARAM(lParam);
|
||||
yPos = GET_Y_LPARAM(lParam);
|
||||
|
||||
TrackPopupMenuEx(hShortcutMenu, TPM_RIGHTBUTTON,
|
||||
xPos, yPos, hwnd, NULL);
|
||||
}
|
||||
break;
|
||||
*/
|
||||
case WM_COMMAND:
|
||||
|
||||
switch(LOWORD(wParam))
|
||||
{
|
||||
case ID_NEW:
|
||||
CreateNewMDIChild(hMDIClient);
|
||||
break;
|
||||
|
||||
case ID_OPEN:
|
||||
DoOpenFile(hwnd);
|
||||
break;
|
||||
|
||||
case ID_SAVEAS:
|
||||
DoSaveFile(hwnd);
|
||||
break;
|
||||
|
||||
case ID_CLOSE:
|
||||
{
|
||||
/* close the active child window */
|
||||
HWND hChild = (HWND)SendMessage(hMDIClient, WM_MDIGETACTIVE,0,0);
|
||||
if(hChild)
|
||||
{
|
||||
SendMessage(hChild, WM_CLOSE, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_CLOSEALL:
|
||||
{
|
||||
HWND hChild;
|
||||
/* loop until all windows have been closed */
|
||||
while ((hChild = (HWND)SendMessage(hMDIClient, WM_MDIGETACTIVE,0,0)) != NULL)
|
||||
{
|
||||
SendMessage(hChild, WM_CLOSE, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_TOOLS:
|
||||
ShowHideToolbar(hFloatTool);
|
||||
break;
|
||||
|
||||
case ID_STATUSBAR:
|
||||
ShowHideToolbar(hStatus);
|
||||
/* FIXME: Need to resize client area */
|
||||
break;
|
||||
|
||||
case ID_EXIT:
|
||||
PostMessage(hwnd, WM_CLOSE, 0, 0);
|
||||
break;
|
||||
|
||||
case ID_EDITCOLOURS:
|
||||
{
|
||||
/* open up the colour selection dialog */
|
||||
|
||||
static CHOOSECOLOR cc;
|
||||
static COLORREF crCustColors[16];
|
||||
|
||||
cc.lStructSize = sizeof(CHOOSECOLOR);
|
||||
cc.hwndOwner = hwnd;
|
||||
cc.hInstance = NULL;
|
||||
cc.rgbResult = RGB(0x80, 0x80, 0x80);
|
||||
cc.lpCustColors = crCustColors;
|
||||
cc.Flags = CC_RGBINIT | CC_FULLOPEN;
|
||||
cc.lCustData = 0;
|
||||
cc.lpfnHook = NULL;
|
||||
cc.lpTemplateName = NULL;
|
||||
|
||||
ChooseColor(&cc);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_WINDOW_TILE:
|
||||
SendMessage(hMDIClient, WM_MDITILE, 0, 0);
|
||||
break;
|
||||
|
||||
case ID_WINDOW_CASCADE:
|
||||
SendMessage(hMDIClient, WM_MDICASCADE, 0, 0);
|
||||
break;
|
||||
|
||||
case ID_ABOUT:
|
||||
DialogBox(hInstance,
|
||||
MAKEINTRESOURCE(IDD_ABOUTBOX),
|
||||
hMainWnd,
|
||||
(DLGPROC)AboutDialogProc);
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Catch all commands that I didn't process directly and do
|
||||
* a check to see if the value is greater than or equal to
|
||||
* ID_MDI_FIRSTCHILD. If it is, then the user has clicked
|
||||
* on one of the Window menu items and we send the message
|
||||
* on to DefFrameProc() for processing.
|
||||
*/
|
||||
if(LOWORD(wParam) >= ID_MDI_FIRSTCHILD)
|
||||
DefFrameProc(hwnd, hMDIClient, WM_COMMAND, wParam, lParam);
|
||||
else
|
||||
{
|
||||
HWND hChild = (HWND)SendMessage(hMDIClient, WM_MDIGETACTIVE,0,0);
|
||||
if(hChild)
|
||||
SendMessage(hChild, WM_COMMAND, wParam, lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
DestroyMenu(hShortcutMenu);
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
return DefFrameProc(hwnd, hMDIClient, msg, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void GetLargestDisplayMode (int * pcxBitmap, int * pcyBitmap)
|
||||
{
|
||||
DEVMODE devmode ;
|
||||
int iModeNum = 0 ;
|
||||
|
||||
* pcxBitmap = * pcyBitmap = 0 ;
|
||||
|
||||
ZeroMemory (&devmode, sizeof (DEVMODE)) ;
|
||||
devmode.dmSize = sizeof (DEVMODE) ;
|
||||
|
||||
while (EnumDisplaySettings (NULL, iModeNum++, &devmode))
|
||||
{
|
||||
* pcxBitmap = max (* pcxBitmap, (int) devmode.dmPelsWidth) ;
|
||||
* pcyBitmap = max (* pcyBitmap, (int) devmode.dmPelsHeight) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* MDI child window message handler
|
||||
*/
|
||||
LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static BOOL fLeftButtonDown, fRightButtonDown;
|
||||
static HBITMAP hBitmap;
|
||||
static HDC hdcMem;
|
||||
static INT cxBitmap, cyBitmap, cxClient, cyClient, xMouse, yMouse;
|
||||
HDC hdc;
|
||||
PAINTSTRUCT ps;
|
||||
|
||||
switch(msg)
|
||||
{
|
||||
case WM_CREATE:
|
||||
GetLargestDisplayMode(&cxBitmap, &cyBitmap);
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
hBitmap = CreateCompatibleBitmap(hdc, cxBitmap, cyBitmap);
|
||||
hdcMem = CreateCompatibleDC(hdc);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
|
||||
if (!hBitmap) // no memory for bitmap
|
||||
{
|
||||
DeleteDC(hdcMem);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SelectObject(hdcMem, hBitmap);
|
||||
PatBlt(hdcMem, 0, 0, cxBitmap, cyBitmap, WHITENESS);
|
||||
|
||||
break;
|
||||
|
||||
case WM_MDIACTIVATE:
|
||||
{
|
||||
HMENU hMenu, hFileMenu;
|
||||
UINT EnableFlag;
|
||||
|
||||
hMenu = GetMenu(hMainWnd);
|
||||
if(hwnd == (HWND)lParam)
|
||||
{ /* being activated, enable the menus */
|
||||
EnableFlag = MF_ENABLED;
|
||||
}
|
||||
else
|
||||
{
|
||||
TCHAR Buf[6];
|
||||
/* being de-activated, gray the menus */
|
||||
EnableFlag = MF_GRAYED;
|
||||
|
||||
/* indicate program is ready in the status bar */
|
||||
LoadString(hInstance, IDS_READY, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)Buf);
|
||||
}
|
||||
|
||||
EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag); /* edit */
|
||||
EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag); /* image */
|
||||
EnableMenuItem(hMenu, 3, MF_BYPOSITION | EnableFlag); /* colours */
|
||||
EnableMenuItem(hMenu, 4, MF_BYPOSITION | EnableFlag); /* window */
|
||||
|
||||
hFileMenu = GetSubMenu(hMenu, 0);
|
||||
EnableMenuItem(hFileMenu, ID_SAVEAS, MF_BYCOMMAND | EnableFlag);
|
||||
|
||||
EnableMenuItem(hFileMenu, ID_CLOSE, MF_BYCOMMAND | EnableFlag);
|
||||
EnableMenuItem(hFileMenu, ID_CLOSEALL, MF_BYCOMMAND | EnableFlag);
|
||||
|
||||
SendMessage(hTool, TB_SETSTATE, ID_COPY,
|
||||
(LPARAM)MAKELONG(TBSTATE_ENABLED, 0));
|
||||
|
||||
DrawMenuBar(hMainWnd);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
MSG mymsg;
|
||||
PeekMessage(&mymsg, NULL, 0, 0, PM_REMOVE);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
POINT pt;
|
||||
TCHAR Buf[200];
|
||||
TCHAR Cur[15];
|
||||
|
||||
pt.x = LOWORD(lParam);
|
||||
pt.y = HIWORD(lParam);
|
||||
|
||||
/* set cursor location in the status bar */
|
||||
LoadString(hInstance, IDS_CURPOS, Cur, sizeof(Cur) / sizeof(TCHAR));
|
||||
_sntprintf(Buf, sizeof(Buf) / sizeof(TCHAR), Cur, pt.x, pt.y);
|
||||
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)Buf);
|
||||
|
||||
/* change cursor to a cross */
|
||||
/*FIXME: can this be forced into the MDI child class? */
|
||||
SetCursor (LoadCursor (NULL, IDC_CROSS));
|
||||
|
||||
if (!fLeftButtonDown && !fRightButtonDown)
|
||||
break;
|
||||
|
||||
hdc = GetDC(hwnd);
|
||||
|
||||
SelectObject(hdc,
|
||||
GetStockObject(fLeftButtonDown ? BLACK_PEN : WHITE_PEN) );
|
||||
|
||||
SelectObject(hdcMem,
|
||||
GetStockObject(fLeftButtonDown ? BLACK_PEN : WHITE_PEN) );
|
||||
|
||||
MoveToEx (hdc, xMouse, yMouse, NULL);
|
||||
MoveToEx (hdcMem, xMouse, yMouse, NULL);
|
||||
|
||||
xMouse = (short) LOWORD(lParam);
|
||||
yMouse = (short) HIWORD(lParam);
|
||||
|
||||
LineTo(hdc, xMouse, yMouse);
|
||||
LineTo(hdcMem, xMouse, yMouse);
|
||||
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
if (!fRightButtonDown)
|
||||
SetCapture(hwnd);
|
||||
|
||||
xMouse = LOWORD(lParam);
|
||||
yMouse = HIWORD(lParam);
|
||||
fLeftButtonDown = TRUE;
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
if (fLeftButtonDown)
|
||||
SetCapture(NULL);
|
||||
|
||||
fLeftButtonDown = FALSE;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
if (!fLeftButtonDown)
|
||||
SetCapture(hwnd);
|
||||
|
||||
xMouse = LOWORD(lParam);
|
||||
yMouse = HIWORD(lParam);
|
||||
fRightButtonDown = TRUE;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
if (fRightButtonDown)
|
||||
SetCapture(NULL);
|
||||
|
||||
fRightButtonDown = FALSE;
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint(hwnd, &ps);
|
||||
|
||||
BitBlt(hdc, 0, 0, cxClient, cyClient, hdcMem, 0, 0, SRCCOPY);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
|
||||
|
||||
return DefMDIChildProc(hwnd, msg, wParam, lParam);
|
||||
|
||||
case WM_DESTROY:
|
||||
DeleteDC(hdcMem);
|
||||
DeleteObject(hBitmap);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
{
|
||||
TCHAR Buf[6];
|
||||
|
||||
/* indicate program is ready in the status bar */
|
||||
LoadString(hInstance, IDS_READY, Buf, sizeof(Buf) / sizeof(TCHAR));
|
||||
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)Buf);
|
||||
|
||||
return DefMDIChildProc(hwnd, msg, wParam, lParam);
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register the MDI child window class
|
||||
*/
|
||||
BOOL SetUpMDIChildWindowClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = MDIChildWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = ChildClassName;
|
||||
wc.hIconSm = (HICON)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
||||
|
||||
if(!RegisterClassEx(&wc))
|
||||
{
|
||||
MessageBox(0, _T("Could Not Register Child Window"), _T("Error!"),
|
||||
MB_ICONEXCLAMATION | MB_OK);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
HANDLE ProcessHeap;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4100)
|
||||
#endif
|
||||
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine, int nCmdShow)
|
||||
int WINAPI
|
||||
WinMain(HINSTANCE hThisInstance,
|
||||
HINSTANCE hPrevInstance,
|
||||
LPSTR lpCmdLine,
|
||||
int nCmdShow)
|
||||
{
|
||||
WNDCLASSEX wc;
|
||||
LPTSTR lpAppName;
|
||||
HWND hMainWnd;
|
||||
MSG Msg;
|
||||
BOOL bRet;
|
||||
int Ret = 1;
|
||||
INITCOMMONCONTROLSEX icex;
|
||||
|
||||
hInstance = hThisInstance;
|
||||
ProcessHeap = GetProcessHeap();
|
||||
|
||||
icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
|
||||
icex.dwICC = ICC_BAR_CLASSES;
|
||||
icex.dwICC = ICC_BAR_CLASSES | ICC_COOL_CLASSES;
|
||||
InitCommonControlsEx(&icex);
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON));
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
|
||||
wc.lpszClassName = AppClassName;
|
||||
wc.hIconSm = (HICON)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON), IMAGE_ICON, 16, 16, 0);
|
||||
|
||||
if(!RegisterClassEx(&wc))
|
||||
if (!AllocAndLoadString(&lpAppName,
|
||||
hInstance,
|
||||
IDS_APPNAME))
|
||||
{
|
||||
MessageBox(NULL, _T("Window Registration Failed!"), _T("Error!"),
|
||||
MB_ICONEXCLAMATION | MB_OK);
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!SetUpMDIChildWindowClass(hInstance))
|
||||
return 0;
|
||||
|
||||
hMainWnd = CreateWindowEx(0,
|
||||
AppClassName,
|
||||
_T("ImageSoft"),
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 800, 600,
|
||||
NULL, NULL, hInstance, NULL);
|
||||
|
||||
if(hMainWnd == NULL)
|
||||
if (TbdInitImpl())
|
||||
{
|
||||
MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"),
|
||||
MB_ICONEXCLAMATION | MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ShowWindow(hMainWnd, nCmdShow);
|
||||
UpdateWindow(hMainWnd);
|
||||
|
||||
while( GetMessage( &Msg, NULL, 0, 0 ) )
|
||||
{
|
||||
if (!TranslateMDISysAccel(hMDIClient, &Msg))
|
||||
if (InitMainWindowImpl())
|
||||
{
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
if (InitImageEditWindowImpl())
|
||||
{
|
||||
hMainWnd = CreateMainWindow(lpAppName,
|
||||
nCmdShow);
|
||||
if (hMainWnd != NULL)
|
||||
{
|
||||
/* pump the message queue */
|
||||
while((bRet = GetMessage(&Msg,
|
||||
NULL,
|
||||
0,
|
||||
0) != 0))
|
||||
{
|
||||
if (bRet != (BOOL)-1)
|
||||
{
|
||||
if (!MainWndTranslateMDISysAccel(hMainWnd,
|
||||
&Msg))
|
||||
{
|
||||
TranslateMessage(&Msg);
|
||||
DispatchMessage(&Msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ret = 0;
|
||||
}
|
||||
|
||||
UninitImageEditWindowImpl();
|
||||
}
|
||||
|
||||
UninitMainWindowImpl();
|
||||
}
|
||||
|
||||
TbdUninitImpl();
|
||||
}
|
||||
return (int)Msg.wParam;
|
||||
|
||||
LocalFree((HLOCAL)lpAppName);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#ifndef __PAINT_H
|
||||
#define __PAINT_H
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h> /* GET_X/Y_LPARAM */
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
#define MAX_KEY_LENGTH 256
|
||||
#define NUM_BUTTONS 14
|
||||
|
||||
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
BOOL CALLBACK ToolDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
BOOL ShowHideToolbar(HWND hwnd);
|
||||
|
||||
VOID FileInitialize(HWND hwnd);
|
||||
VOID DoOpenFile(HWND hwnd);
|
||||
VOID DoSaveFile(HWND hwnd);
|
||||
|
||||
#endif /* __SERVMAN_H */
|
||||
@@ -1,28 +1,31 @@
|
||||
<?xml version="1.0"?>
|
||||
<rbuild xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
<module name="imagesoft" type="win32gui" installbase="system32" installname="imagesoft.exe">
|
||||
<include base="imagesoft">.</include>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="__REACTOS__" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x600</define>
|
||||
<define name="_WIN32_WINNT">0x501</define>
|
||||
<library>kernel32</library>
|
||||
<library>gdi32</library>
|
||||
<library>user32</library>
|
||||
<library>advapi32</library>
|
||||
<library>version</library>
|
||||
<library>comctl32</library>
|
||||
<library>shell32</library>
|
||||
<library>comdlg32</library>
|
||||
<compilationunit name="unit.c">
|
||||
<file>about.c</file>
|
||||
<file>floattoolbar.c</file>
|
||||
<file>imagesoft.c</file>
|
||||
<file>opensave.c</file>
|
||||
</compilationunit>
|
||||
<file>imagesoft.rc</file>
|
||||
<pch>imagesoft.h</pch>
|
||||
</module>
|
||||
<module name="imagesoft" type="win32gui" installbase="system32" installname="imagesoft.exe">
|
||||
<include base="imagesoft">.</include>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x0600</define>
|
||||
<define name="_WIN32_WINNT">0x0501</define>
|
||||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
<library>gdi32</library>
|
||||
<library>user32</library>
|
||||
<library>advapi32</library>
|
||||
<library>version</library>
|
||||
<library>comctl32</library>
|
||||
<library>shell32</library>
|
||||
<library>comdlg32</library>
|
||||
<compilationunit name="unit.c">
|
||||
<file>about.c</file>
|
||||
<file>imagesoft.c</file>
|
||||
<file>imgedwnd.c</file>
|
||||
<file>mainwnd.c</file>
|
||||
<file>opensave.c</file>
|
||||
<file>tooldock.c</file>
|
||||
<file>misc.c</file>
|
||||
</compilationunit>
|
||||
<file>imagesoft.rc</file>
|
||||
<pch>precomp.h</pch>
|
||||
</module>
|
||||
</rbuild>
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
|
||||
1 24 DISCARDABLE "manifest.xml"
|
||||
|
||||
IDI_ICON ICON "res/imagesoft.ico"
|
||||
|
||||
#include "En.rc"
|
||||
|
||||
@@ -0,0 +1,296 @@
|
||||
#include <precomp.h>
|
||||
|
||||
static const TCHAR szImageEditWndClass[] = TEXT("ImageSoftEditWndClass");
|
||||
|
||||
#define IMAGE_FRAME_SIZE 1
|
||||
|
||||
static VOID
|
||||
EditWndUpdateScrollInfo(PEDIT_WND_INFO Info)
|
||||
{
|
||||
SCROLLINFO si;
|
||||
RECT rcClient;
|
||||
|
||||
GetClientRect(Info->hSelf,
|
||||
&rcClient);
|
||||
|
||||
si.cbSize = sizeof(si);
|
||||
si.fMask = SIF_PAGE | SIF_RANGE;
|
||||
si.nPage = rcClient.right - (2 * IMAGE_FRAME_SIZE);
|
||||
si.nMin = 0;
|
||||
si.nMax = Info->Width;
|
||||
|
||||
SetScrollInfo(Info->hSelf,
|
||||
SB_HORZ,
|
||||
&si,
|
||||
TRUE);
|
||||
|
||||
si.nPage = rcClient.bottom - (2 * IMAGE_FRAME_SIZE);
|
||||
si.nMax = Info->Height;
|
||||
SetScrollInfo(Info->hSelf,
|
||||
SB_VERT,
|
||||
&si,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
static BOOL
|
||||
InitEditWnd(PEDIT_WND_INFO Info)
|
||||
{
|
||||
Info->Zoom = 100;
|
||||
|
||||
if (Info->OpenInfo != NULL)
|
||||
{
|
||||
if (Info->OpenInfo->CreateNew)
|
||||
{
|
||||
Info->Width = Info->OpenInfo->New.Width;
|
||||
Info->Height = Info->OpenInfo->New.Height;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Load the image from file */
|
||||
}
|
||||
|
||||
Info->OpenInfo = NULL;
|
||||
}
|
||||
|
||||
EditWndUpdateScrollInfo(Info);
|
||||
|
||||
/* Add image editor to the list */
|
||||
Info->Next = Info->MainWnd->ImageEditors;
|
||||
Info->MainWnd->ImageEditors = Info;
|
||||
|
||||
/* FIXME - if returning FALSE, remove the image editor from the list! */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
DestroyEditWnd(PEDIT_WND_INFO Info)
|
||||
{
|
||||
PEDIT_WND_INFO *PrevEditor;
|
||||
PEDIT_WND_INFO Editor;
|
||||
|
||||
/* FIXME - free resources and run down editor */
|
||||
|
||||
/* Remove the image editor from the list */
|
||||
PrevEditor = &Info->MainWnd->ImageEditors;
|
||||
Editor = Info->MainWnd->ImageEditors;
|
||||
do
|
||||
{
|
||||
if (Editor == Info)
|
||||
{
|
||||
*PrevEditor = Info->Next;
|
||||
break;
|
||||
}
|
||||
PrevEditor = &Editor->Next;
|
||||
Editor = Editor->Next;
|
||||
} while (Editor != NULL);
|
||||
}
|
||||
|
||||
static VOID
|
||||
ImageEditWndRepaint(PEDIT_WND_INFO Info,
|
||||
HDC hDC,
|
||||
LPPAINTSTRUCT lpps)
|
||||
{
|
||||
/* FIXME */
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK
|
||||
ImageEditWndProc(HWND hwnd,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
PEDIT_WND_INFO Info;
|
||||
LRESULT Ret = 0;
|
||||
|
||||
/* Get the window context */
|
||||
Info = (PEDIT_WND_INFO)GetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA);
|
||||
if (Info == NULL && uMsg != WM_CREATE)
|
||||
{
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_ERASEBKGND:
|
||||
if (Info->Width != 0 && Info->Height != 0)
|
||||
{
|
||||
Ret = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
{
|
||||
if (Info->Width != 0 && Info->Height != 0)
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hDC;
|
||||
|
||||
hDC = BeginPaint(hwnd,
|
||||
&ps);
|
||||
if (hDC != NULL)
|
||||
{
|
||||
ImageEditWndRepaint(Info,
|
||||
hDC,
|
||||
&ps);
|
||||
|
||||
EndPaint(hwnd,
|
||||
&ps);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SIZE:
|
||||
{
|
||||
EditWndUpdateScrollInfo(Info);
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
case WM_MENUSELECT:
|
||||
case WM_ENTERMENULOOP:
|
||||
case WM_EXITMENULOOP:
|
||||
/* forward these messages to the main window procedure */
|
||||
Ret = SendMessage(Info->MainWnd->hSelf,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
break;
|
||||
|
||||
case WM_MDIACTIVATE:
|
||||
/* Switch the main window context if neccessary */
|
||||
MainWndSwitchEditorContext(Info->MainWnd,
|
||||
(HWND)wParam,
|
||||
(HWND)lParam);
|
||||
break;
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
Info = (PEDIT_WND_INFO)(((LPMDICREATESTRUCT)((LPCREATESTRUCT)lParam)->lpCreateParams)->lParam);
|
||||
Info->hSelf = hwnd;
|
||||
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
(LONG_PTR)Info);
|
||||
|
||||
if (!InitEditWnd(Info))
|
||||
{
|
||||
Ret = (LRESULT)-1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DestroyEditWnd(Info);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
0);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
HandleDefaultMessage:
|
||||
Ret = DefMDIChildProc(hwnd,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
break;
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
VOID
|
||||
SetImageEditorEnvironment(PEDIT_WND_INFO Info,
|
||||
BOOL Setup)
|
||||
{
|
||||
if (Setup)
|
||||
{
|
||||
/* FIXME - setup editor environment (e.g. show toolbars, enable menus etc) */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* FIXME - cleanup editor environment (e.g. hide toolbars, disable menus etc) */
|
||||
}
|
||||
}
|
||||
|
||||
BOOL
|
||||
CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
|
||||
LPCTSTR lpCaption,
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo)
|
||||
{
|
||||
PEDIT_WND_INFO Info;
|
||||
HWND hWndEditor;
|
||||
|
||||
Info = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(EDIT_WND_INFO));
|
||||
if (Info != NULL)
|
||||
{
|
||||
ZeroMemory(Info,
|
||||
sizeof(EDIT_WND_INFO));
|
||||
Info->MainWnd = MainWnd;
|
||||
Info->MdiEditorType = metImageEditor;
|
||||
Info->OpenInfo = OpenInfo;
|
||||
|
||||
hWndEditor = CreateMDIWindow(szImageEditWndClass,
|
||||
lpCaption,
|
||||
WS_HSCROLL | WS_VSCROLL,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
MainWnd->hMdiClient,
|
||||
hInstance,
|
||||
(LPARAM)Info);
|
||||
|
||||
if (hWndEditor != NULL)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitImageEditWindowImpl(VOID)
|
||||
{
|
||||
WNDCLASSEX wc = {0};
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = ImageEditWndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON));
|
||||
wc.hCursor = LoadCursor(NULL,
|
||||
IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszClassName = szImageEditWndClass;
|
||||
wc.hIconSm = (HICON)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON),
|
||||
IMAGE_ICON,
|
||||
16,
|
||||
16,
|
||||
LR_SHARED);
|
||||
|
||||
return RegisterClassEx(&wc) != (ATOM)0;
|
||||
}
|
||||
|
||||
VOID
|
||||
UninitImageEditWindowImpl(VOID)
|
||||
{
|
||||
UnregisterClass(szImageEditWndClass,
|
||||
hInstance);
|
||||
}
|
||||
@@ -0,0 +1,905 @@
|
||||
#include <precomp.h>
|
||||
|
||||
static const TCHAR szMainWndClass[] = TEXT("ImageSoftWndClass");
|
||||
|
||||
#define ID_MDI_FIRSTCHILD 50000
|
||||
#define ID_MDI_WINDOWMENU 5
|
||||
|
||||
/* menu hints */
|
||||
static const MENU_HINT MainMenuHintTable[] = {
|
||||
/* File Menu */
|
||||
{ID_CLOSE, IDS_HINT_SYS_CLOSE},
|
||||
{ID_EXIT, IDS_HINT_EXIT},
|
||||
|
||||
/* Window Menu */
|
||||
{ID_WINDOW_NEXT, IDS_HINT_SYS_NEXT}
|
||||
};
|
||||
|
||||
static const MENU_HINT SystemMenuHintTable[] = {
|
||||
{SC_RESTORE, IDS_HINT_SYS_RESTORE},
|
||||
{SC_MOVE, IDS_HINT_SYS_MOVE},
|
||||
{SC_SIZE, IDS_HINT_SYS_SIZE},
|
||||
{SC_MINIMIZE, IDS_HINT_SYS_MINIMIZE},
|
||||
{SC_MAXIMIZE, IDS_HINT_SYS_MAXIMIZE},
|
||||
{SC_CLOSE, IDS_HINT_SYS_CLOSE},
|
||||
{SC_NEXTWINDOW, IDS_HINT_SYS_NEXT},
|
||||
};
|
||||
|
||||
/* Standard Toolbar */
|
||||
#define ID_TOOLBAR_STANDARD 0
|
||||
static const TCHAR szToolbarStandard[] = TEXT("STANDARD");
|
||||
static const TBBUTTON StdButtons[] = {
|
||||
/* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
|
||||
{STD_FILENEW, ID_NEW, TBSTATE_ENABLED, TBSTYLE_BUTTON, {0}, 0, 0}, /* new */
|
||||
{STD_FILEOPEN, ID_OPEN, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* open */
|
||||
{STD_FILESAVE, ID_SAVE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0}, /* save */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_PRINTPRE, ID_PRINTPRE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* print */
|
||||
{STD_PRINT, ID_PRINT, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* print preview */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_CUT, ID_CUT, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* cut */
|
||||
{STD_COPY, ID_COPY, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* copy */
|
||||
{STD_PASTE, ID_PASTE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* paste */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
|
||||
|
||||
{STD_UNDO, ID_UNDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* undo */
|
||||
{STD_REDOW, ID_REDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* redo */
|
||||
|
||||
{10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0},
|
||||
};
|
||||
|
||||
/* Test Toolbar */
|
||||
#define ID_TOOLBAR_TEST 1
|
||||
static const TCHAR szToolbarTest[] = TEXT("TEST");
|
||||
|
||||
/* Toolbars table */
|
||||
static const DOCKBAR MainDockBars[] = {
|
||||
{ID_TOOLBAR_STANDARD, szToolbarStandard, IDS_TOOLBAR_STANDARD, TOP_DOCK},
|
||||
{ID_TOOLBAR_TEST, szToolbarTest, IDS_TOOLBAR_TEST, TOP_DOCK},
|
||||
};
|
||||
|
||||
static BOOL CALLBACK
|
||||
MainWndCreateToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hParent,
|
||||
HWND *hwnd)
|
||||
{
|
||||
const TBBUTTON *Buttons = NULL;
|
||||
UINT NumButtons = 0;
|
||||
HWND hWndClient = NULL;
|
||||
|
||||
UNREFERENCED_PARAMETER(Context);
|
||||
|
||||
/* Standard toolbar */
|
||||
switch (Dockbar->BarId)
|
||||
{
|
||||
case ID_TOOLBAR_STANDARD:
|
||||
{
|
||||
Buttons = StdButtons;
|
||||
NumButtons = sizeof(StdButtons) / sizeof(StdButtons[0]);
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_TOOLBAR_TEST:
|
||||
{
|
||||
hWndClient = CreateWindowEx(0,
|
||||
TEXT("BUTTON"),
|
||||
TEXT("Test Button"),
|
||||
WS_CHILD | WS_VISIBLE,
|
||||
0,
|
||||
0,
|
||||
150,
|
||||
25,
|
||||
hParent,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (Buttons != NULL)
|
||||
{
|
||||
TBADDBITMAP tbab;
|
||||
|
||||
hWndClient = CreateWindowEx(0,
|
||||
TOOLBARCLASSNAME,
|
||||
NULL,
|
||||
WS_CHILD | WS_CLIPSIBLINGS |
|
||||
CCS_NOPARENTALIGN | CCS_NOMOVEY | CCS_NORESIZE | CCS_NODIVIDER |
|
||||
TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
hParent,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL);
|
||||
if (hWndClient != NULL)
|
||||
{
|
||||
SendMessage(hWndClient,
|
||||
TB_SETEXTENDEDSTYLE,
|
||||
0,
|
||||
TBSTYLE_EX_HIDECLIPPEDBUTTONS);
|
||||
|
||||
/* Send the TB_BUTTONSTRUCTSIZE message, which is required for backward compatibility */
|
||||
SendMessage(hWndClient,
|
||||
TB_BUTTONSTRUCTSIZE,
|
||||
sizeof(Buttons[0]),
|
||||
0);
|
||||
|
||||
/* Add standard images */
|
||||
tbab.hInst = HINST_COMMCTRL;
|
||||
tbab.nID = IDB_STD_SMALL_COLOR;
|
||||
SendMessage(hWndClient,
|
||||
TB_ADDBITMAP,
|
||||
(WPARAM)NumButtons,
|
||||
(LPARAM)&tbab);
|
||||
|
||||
/* Add buttons to toolbar */
|
||||
SendMessage(hWndClient,
|
||||
TB_ADDBUTTONS,
|
||||
(WPARAM)NumButtons,
|
||||
(LPARAM)Buttons);
|
||||
}
|
||||
}
|
||||
|
||||
if (hWndClient != NULL)
|
||||
{
|
||||
*hwnd = hWndClient;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK
|
||||
MainWndDestroyToolbarClient(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hwnd)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(TbDocks);
|
||||
UNREFERENCED_PARAMETER(Dockbar);
|
||||
UNREFERENCED_PARAMETER(Context);
|
||||
|
||||
DestroyWindow(hwnd);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static BOOL CALLBACK
|
||||
MainWndToolbarInsertBand(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
UINT *Index,
|
||||
LPREBARBANDINFO rbi)
|
||||
{
|
||||
switch (rbi->wID)
|
||||
{
|
||||
case ID_TOOLBAR_STANDARD:
|
||||
{
|
||||
SIZE Size;
|
||||
|
||||
if (SendMessage(rbi->hwndChild,
|
||||
TB_GETMAXSIZE,
|
||||
0,
|
||||
(LPARAM)&Size))
|
||||
{
|
||||
rbi->fStyle |= RBBS_USECHEVRON | RBBS_HIDETITLE;
|
||||
rbi->fMask |= RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE;
|
||||
rbi->cx = rbi->cxIdeal = Size.cx;
|
||||
rbi->cxMinChild = 0;
|
||||
rbi->cyMinChild = Size.cy;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_TOOLBAR_TEST:
|
||||
{
|
||||
RECT rcBtn;
|
||||
|
||||
if (GetWindowRect(rbi->hwndChild,
|
||||
&rcBtn))
|
||||
{
|
||||
rbi->fStyle |= RBBS_HIDETITLE;
|
||||
rbi->fMask |= RBBIM_SIZE | RBBIM_CHILDSIZE;
|
||||
rbi->cx = rcBtn.right - rcBtn.left;
|
||||
rbi->cxMinChild = 0;
|
||||
rbi->cyMinChild = rcBtn.bottom - rcBtn.top;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static VOID CALLBACK
|
||||
MainWndToolbarDockBand(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
DOCK_POSITION DockFrom,
|
||||
DOCK_POSITION DockTo,
|
||||
LPREBARBANDINFO rbi)
|
||||
{
|
||||
if (rbi->fMask & RBBIM_CHILD && rbi->hwndChild != NULL)
|
||||
{
|
||||
switch (rbi->wID)
|
||||
{
|
||||
case ID_TOOLBAR_STANDARD:
|
||||
{
|
||||
SIZE Size;
|
||||
BOOL Vert;
|
||||
DWORD dwStyle = SendMessage(rbi->hwndChild,
|
||||
TB_GETSTYLE,
|
||||
0,
|
||||
0);
|
||||
switch (DockTo)
|
||||
{
|
||||
case LEFT_DOCK:
|
||||
case RIGHT_DOCK:
|
||||
dwStyle |= CCS_VERT | TBSTYLE_WRAPABLE;
|
||||
Vert = TRUE;
|
||||
break;
|
||||
|
||||
default:
|
||||
dwStyle &= ~(CCS_VERT | TBSTYLE_WRAPABLE);
|
||||
Vert = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
SendMessage(rbi->hwndChild,
|
||||
TB_SETSTYLE,
|
||||
0,
|
||||
(LPARAM)dwStyle);
|
||||
|
||||
if (SendMessage(rbi->hwndChild,
|
||||
TB_GETMAXSIZE,
|
||||
0,
|
||||
(LPARAM)&Size))
|
||||
{
|
||||
rbi->fMask |= RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE;
|
||||
rbi->cx = rbi->cxIdeal = (Vert ? Size.cy : Size.cx);
|
||||
rbi->cxMinChild = 0;
|
||||
rbi->cyMinChild = (Vert ? Size.cx : Size.cy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_TOOLBAR_TEST:
|
||||
{
|
||||
if (DockTo == NO_DOCK)
|
||||
{
|
||||
rbi->fMask |= RBBIM_SIZE | RBBIM_CHILDSIZE | RBBIM_IDEALSIZE;
|
||||
rbi->cx = rbi->cxIdeal = 150;
|
||||
rbi->cxMinChild = 0;
|
||||
rbi->cyMinChild = 40;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static VOID CALLBACK
|
||||
MainWndToolbarChevronPushed(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hwndChild,
|
||||
LPNMREBARCHEVRON lpnm)
|
||||
{
|
||||
switch (lpnm->wID)
|
||||
{
|
||||
case ID_TOOLBAR_STANDARD:
|
||||
{
|
||||
MapWindowPoints(lpnm->hdr.hwndFrom,
|
||||
HWND_DESKTOP,
|
||||
(LPPOINT)&lpnm->rc,
|
||||
2);
|
||||
/* Create a popup menu for all toolbar icons hidden */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const DOCKBAR_ITEM_CALLBACKS MainWndDockBarCallbacks = {
|
||||
MainWndCreateToolbarClient,
|
||||
MainWndDestroyToolbarClient,
|
||||
MainWndToolbarInsertBand,
|
||||
MainWndToolbarDockBand,
|
||||
MainWndToolbarChevronPushed,
|
||||
};
|
||||
|
||||
static VOID
|
||||
CreateToolbars(PMAIN_WND_INFO Info)
|
||||
{
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < sizeof(MainDockBars) / sizeof(MainDockBars[0]); i++)
|
||||
{
|
||||
/* FIXME - lookup whether to display the toolbar */
|
||||
TbdAddToolbar(&Info->ToolDocks,
|
||||
&MainDockBars[i],
|
||||
Info,
|
||||
&MainWndDockBarCallbacks);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID CALLBACK
|
||||
MainWndResize(PVOID Context,
|
||||
WORD cx,
|
||||
WORD cy)
|
||||
{
|
||||
RECT rcClient = {0};
|
||||
RECT rcStatus = {0};
|
||||
HDWP dwp;
|
||||
INT DocksVisible;
|
||||
PMAIN_WND_INFO Info = (PMAIN_WND_INFO)Context;
|
||||
|
||||
/* Calculate the MDI client rectangle */
|
||||
rcClient.right = cx;
|
||||
rcClient.bottom = cy;
|
||||
|
||||
if (Info->hStatus != NULL)
|
||||
{
|
||||
GetWindowRect(Info->hStatus,
|
||||
&rcStatus);
|
||||
rcClient.bottom -= (rcStatus.bottom - rcStatus.top);
|
||||
}
|
||||
|
||||
/* Adjust the client rect if docked toolbars are visible */
|
||||
DocksVisible = TbdAdjustUpdateClientRect(&Info->ToolDocks,
|
||||
&rcClient);
|
||||
|
||||
dwp = BeginDeferWindowPos(2 + DocksVisible);
|
||||
if (dwp != NULL)
|
||||
{
|
||||
/* Update the toolbar docks */
|
||||
if (DocksVisible != 0)
|
||||
{
|
||||
dwp = TbdDeferDocks(dwp,
|
||||
&Info->ToolDocks);
|
||||
if (dwp == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the MDI client */
|
||||
if (Info->hMdiClient != NULL)
|
||||
{
|
||||
dwp = DeferWindowPos(dwp,
|
||||
Info->hMdiClient,
|
||||
NULL,
|
||||
rcClient.left,
|
||||
rcClient.top,
|
||||
rcClient.right - rcClient.left,
|
||||
rcClient.bottom - rcClient.top,
|
||||
SWP_NOZORDER);
|
||||
if (dwp == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Update the status bar */
|
||||
if (Info->hStatus != NULL)
|
||||
{
|
||||
dwp = DeferWindowPos(dwp,
|
||||
Info->hStatus,
|
||||
NULL,
|
||||
0,
|
||||
cy - (rcStatus.bottom - rcStatus.top),
|
||||
cx,
|
||||
rcStatus.bottom - rcStatus.top,
|
||||
SWP_NOZORDER);
|
||||
if (dwp == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
EndDeferWindowPos(dwp);
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
InitMainWnd(PMAIN_WND_INFO Info)
|
||||
{
|
||||
CLIENTCREATESTRUCT ccs;
|
||||
|
||||
/* FIXME - create controls and initialize the application */
|
||||
|
||||
/* create the status bar */
|
||||
Info->hStatus = CreateWindowEx(0,
|
||||
STATUSCLASSNAME,
|
||||
NULL,
|
||||
WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | CCS_NOPARENTALIGN | SBARS_SIZEGRIP,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Info->hSelf,
|
||||
(HMENU)IDC_STATUSBAR,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
/* create the MDI client window */
|
||||
ccs.hWindowMenu = GetSubMenu(GetMenu(Info->hSelf),
|
||||
ID_MDI_WINDOWMENU);
|
||||
ccs.idFirstChild = ID_MDI_FIRSTCHILD;
|
||||
Info->hMdiClient = CreateWindowEx(WS_EX_ACCEPTFILES | WS_EX_CLIENTEDGE,
|
||||
TEXT("MDICLIENT"),
|
||||
NULL,
|
||||
WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
Info->hSelf,
|
||||
NULL,
|
||||
hInstance,
|
||||
&ccs);
|
||||
|
||||
TbdInitializeDocks(&Info->ToolDocks,
|
||||
Info->hSelf,
|
||||
Info,
|
||||
MainWndResize);
|
||||
|
||||
CreateToolbars(Info);
|
||||
}
|
||||
|
||||
static VOID
|
||||
MainWndCommand(PMAIN_WND_INFO Info,
|
||||
WORD CmdId,
|
||||
HWND hControl)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hControl);
|
||||
|
||||
switch (CmdId)
|
||||
{
|
||||
/* File Menu */
|
||||
case ID_NEW:
|
||||
{
|
||||
OPEN_IMAGE_EDIT_INFO OpenInfo;
|
||||
LPTSTR lpCaption = NULL;
|
||||
|
||||
LoadAndFormatString(hInstance,
|
||||
IDS_IMAGE_NAME,
|
||||
&lpCaption,
|
||||
++Info->ImagesCreated);
|
||||
|
||||
OpenInfo.CreateNew = TRUE;
|
||||
OpenInfo.New.Width = 400;
|
||||
OpenInfo.New.Height = 300;
|
||||
|
||||
CreateImageEditWindow(Info,
|
||||
lpCaption,
|
||||
&OpenInfo);
|
||||
|
||||
if (lpCaption != NULL)
|
||||
LocalFree((HLOCAL)lpCaption);
|
||||
break;
|
||||
}
|
||||
|
||||
case ID_EXIT:
|
||||
SendMessage(Info->hSelf,
|
||||
WM_CLOSE,
|
||||
0,
|
||||
0);
|
||||
break;
|
||||
|
||||
/* Window Menu */
|
||||
case ID_WINDOW_TILE_HORZ:
|
||||
SendMessage(Info->hMdiClient,
|
||||
WM_MDITILE,
|
||||
MDITILE_HORIZONTAL,
|
||||
0);
|
||||
break;
|
||||
|
||||
case ID_WINDOW_TILE_VERT:
|
||||
SendMessage(Info->hMdiClient,
|
||||
WM_MDITILE,
|
||||
MDITILE_VERTICAL,
|
||||
0);
|
||||
break;
|
||||
|
||||
case ID_WINDOW_CASCADE:
|
||||
SendMessage(Info->hMdiClient,
|
||||
WM_MDICASCADE,
|
||||
0,
|
||||
0);
|
||||
break;
|
||||
|
||||
case ID_WINDOW_ARRANGE:
|
||||
SendMessage(Info->hMdiClient,
|
||||
WM_MDIICONARRANGE,
|
||||
0,
|
||||
0);
|
||||
break;
|
||||
|
||||
case ID_WINDOW_NEXT:
|
||||
SendMessage(Info->hMdiClient,
|
||||
WM_MDINEXT,
|
||||
0,
|
||||
0);
|
||||
break;
|
||||
|
||||
/* Help Menu */
|
||||
case ID_ABOUT:
|
||||
DialogBox(hInstance,
|
||||
MAKEINTRESOURCE(IDD_ABOUTBOX),
|
||||
Info->hSelf,
|
||||
AboutDialogProc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static VOID
|
||||
DestroyMainWnd(PMAIN_WND_INFO Info)
|
||||
{
|
||||
/* FIXME - cleanup allocated resources */
|
||||
}
|
||||
|
||||
|
||||
static VOID
|
||||
UpdateMainStatusBar(PMAIN_WND_INFO Info)
|
||||
{
|
||||
if (Info->hStatus != NULL)
|
||||
{
|
||||
SendMessage(Info->hStatus,
|
||||
SB_SIMPLE,
|
||||
(WPARAM)Info->InMenuLoop,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
static BOOL
|
||||
MainWndMenuHint(PMAIN_WND_INFO Info,
|
||||
WORD CmdId,
|
||||
const MENU_HINT *HintArray,
|
||||
DWORD HintsCount,
|
||||
UINT DefHintId)
|
||||
{
|
||||
BOOL Found = FALSE;
|
||||
const MENU_HINT *LastHint;
|
||||
UINT HintId = DefHintId;
|
||||
|
||||
LastHint = HintArray + HintsCount;
|
||||
while (HintArray != LastHint)
|
||||
{
|
||||
if (HintArray->CmdId == CmdId)
|
||||
{
|
||||
HintId = HintArray->HintId;
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
HintArray++;
|
||||
}
|
||||
|
||||
StatusBarLoadString(Info->hStatus,
|
||||
SB_SIMPLEID,
|
||||
hInstance,
|
||||
HintId);
|
||||
|
||||
return Found;
|
||||
}
|
||||
|
||||
static LRESULT CALLBACK
|
||||
MainWndProc(HWND hwnd,
|
||||
UINT uMsg,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam)
|
||||
{
|
||||
PMAIN_WND_INFO Info;
|
||||
LRESULT Ret = 0;
|
||||
|
||||
/* Get the window context */
|
||||
Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA);
|
||||
if (Info == NULL && uMsg != WM_CREATE)
|
||||
{
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_SIZE:
|
||||
{
|
||||
MainWndResize(Info,
|
||||
LOWORD(lParam),
|
||||
HIWORD(lParam));
|
||||
/* NOTE - do *not* forward this message to DefFrameProc! Otherwise the MDI client
|
||||
will attempt to resize itself */
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
if (!TbdHandleNotifications(&Info->ToolDocks,
|
||||
(LPNMHDR)lParam,
|
||||
&Ret))
|
||||
{
|
||||
/* FIXME - handle other notifications */
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_COMMAND:
|
||||
{
|
||||
MainWndCommand(Info,
|
||||
LOWORD(wParam),
|
||||
(HWND)lParam);
|
||||
goto HandleDefaultMessage;
|
||||
}
|
||||
|
||||
case WM_MENUSELECT:
|
||||
{
|
||||
if (Info->hStatus != NULL)
|
||||
{
|
||||
if (!MainWndMenuHint(Info,
|
||||
LOWORD(wParam),
|
||||
MainMenuHintTable,
|
||||
sizeof(MainMenuHintTable) / sizeof(MainMenuHintTable[0]),
|
||||
IDS_READY))
|
||||
{
|
||||
MainWndMenuHint(Info,
|
||||
LOWORD(wParam),
|
||||
SystemMenuHintTable,
|
||||
sizeof(SystemMenuHintTable) / sizeof(SystemMenuHintTable[0]),
|
||||
IDS_READY);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_ENTERMENULOOP:
|
||||
{
|
||||
Info->InMenuLoop = TRUE;
|
||||
UpdateMainStatusBar(Info);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_EXITMENULOOP:
|
||||
{
|
||||
Info->InMenuLoop = FALSE;
|
||||
UpdateMainStatusBar(Info);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
DestroyWindow(hwnd);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_ACTIVATEAPP:
|
||||
{
|
||||
//TbdShowFloatingToolbars(&Info->ToolDocks,
|
||||
// (BOOL)wParam);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_CREATE:
|
||||
{
|
||||
Info = (PMAIN_WND_INFO)(((LPCREATESTRUCT)lParam)->lpCreateParams);
|
||||
|
||||
/* Initialize the main window context */
|
||||
Info->hSelf = hwnd;
|
||||
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
(LONG_PTR)Info);
|
||||
|
||||
InitMainWnd(Info);
|
||||
|
||||
/* Show the window */
|
||||
ShowWindow(hwnd,
|
||||
Info->nCmdShow);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
DestroyMainWnd(Info);
|
||||
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
SetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA,
|
||||
0);
|
||||
|
||||
/* Break the message queue loop */
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
HandleDefaultMessage:
|
||||
if (Info != NULL && Info->hMdiClient != NULL)
|
||||
{
|
||||
Ret = DefFrameProc(hwnd,
|
||||
Info->hMdiClient,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
Ret = DefWindowProc(hwnd,
|
||||
uMsg,
|
||||
wParam,
|
||||
lParam);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
MDI_EDITOR_TYPE
|
||||
MainWndGetCurrentEditor(PMAIN_WND_INFO MainWnd,
|
||||
PVOID *Info)
|
||||
{
|
||||
MDI_EDITOR_TYPE EditorType;
|
||||
|
||||
if (MainWnd->ActiveEditor != NULL)
|
||||
{
|
||||
EditorType = *((PMDI_EDITOR_TYPE)MainWnd->ActiveEditor);
|
||||
*Info = MainWnd->ActiveEditor;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorType = metUnknown;
|
||||
*Info = NULL;
|
||||
}
|
||||
|
||||
return EditorType;
|
||||
}
|
||||
|
||||
VOID
|
||||
MainWndSwitchEditorContext(PMAIN_WND_INFO Info,
|
||||
HWND hDeactivate,
|
||||
HWND hActivate)
|
||||
{
|
||||
PMDI_EDITOR_TYPE EditorType;
|
||||
|
||||
/* FIXME - optimize light weight switching
|
||||
when switching from and to an editor of same type */
|
||||
|
||||
if (hDeactivate != NULL)
|
||||
{
|
||||
EditorType = (PMDI_EDITOR_TYPE)GetWindowLongPtr(hDeactivate,
|
||||
GWLP_USERDATA);
|
||||
if (EditorType != NULL)
|
||||
{
|
||||
switch (*EditorType)
|
||||
{
|
||||
case metImageEditor:
|
||||
SetImageEditorEnvironment((PEDIT_WND_INFO)EditorType,
|
||||
FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Info->ActiveEditor = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (hActivate != NULL)
|
||||
{
|
||||
EditorType = (PMDI_EDITOR_TYPE)GetWindowLongPtr(hActivate,
|
||||
GWLP_USERDATA);
|
||||
if (EditorType != NULL)
|
||||
{
|
||||
Info->ActiveEditor = EditorType;
|
||||
|
||||
switch (*EditorType)
|
||||
{
|
||||
case metImageEditor:
|
||||
SetImageEditorEnvironment((PEDIT_WND_INFO)EditorType,
|
||||
TRUE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HWND
|
||||
CreateMainWindow(LPCTSTR lpCaption,
|
||||
int nCmdShow)
|
||||
{
|
||||
PMAIN_WND_INFO Info;
|
||||
HWND hMainWnd = NULL;
|
||||
|
||||
Info = HeapAlloc(ProcessHeap,
|
||||
0,
|
||||
sizeof(MAIN_WND_INFO));
|
||||
if (Info != NULL)
|
||||
{
|
||||
ZeroMemory(Info,
|
||||
sizeof(MAIN_WND_INFO));
|
||||
Info->nCmdShow = nCmdShow;
|
||||
|
||||
/* FIXME - load the window position from the registry */
|
||||
|
||||
hMainWnd = CreateWindowEx(WS_EX_WINDOWEDGE,
|
||||
szMainWndClass,
|
||||
lpCaption,
|
||||
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
Info);
|
||||
if (hMainWnd == NULL)
|
||||
{
|
||||
HeapFree(ProcessHeap,
|
||||
0,
|
||||
Info);
|
||||
}
|
||||
}
|
||||
|
||||
return hMainWnd;
|
||||
}
|
||||
|
||||
BOOL
|
||||
MainWndTranslateMDISysAccel(HWND hwnd,
|
||||
LPMSG lpMsg)
|
||||
{
|
||||
PMAIN_WND_INFO Info;
|
||||
|
||||
/* Get the window context */
|
||||
Info = (PMAIN_WND_INFO)GetWindowLongPtr(hwnd,
|
||||
GWLP_USERDATA);
|
||||
if (Info != NULL && Info->hMdiClient != NULL)
|
||||
{
|
||||
return TranslateMDISysAccel(Info->hMdiClient,
|
||||
lpMsg);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
InitMainWindowImpl(VOID)
|
||||
{
|
||||
WNDCLASSEX wc = {0};
|
||||
|
||||
wc.cbSize = sizeof(WNDCLASSEX);
|
||||
wc.lpfnWndProc = MainWndProc;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON));
|
||||
wc.hCursor = LoadCursor(NULL,
|
||||
IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
|
||||
wc.lpszMenuName = MAKEINTRESOURCE(IDR_MAINMENU);
|
||||
wc.lpszClassName = szMainWndClass;
|
||||
wc.hIconSm = (HICON)LoadImage(hInstance,
|
||||
MAKEINTRESOURCE(IDI_ICON),
|
||||
IMAGE_ICON,
|
||||
16,
|
||||
16,
|
||||
LR_SHARED);
|
||||
|
||||
return RegisterClassEx(&wc) != (ATOM)0;
|
||||
}
|
||||
|
||||
VOID
|
||||
UninitMainWindowImpl(VOID)
|
||||
{
|
||||
UnregisterClass(szMainWndClass,
|
||||
hInstance);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity
|
||||
version="1.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
name="ReactOS.VMware.SVGA.Installer"
|
||||
type="win32"
|
||||
/>
|
||||
<description>ReactOS VMware(r) SVGA driver Installer</description>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="X86"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|
||||
|
||||
<!-- EOF -->
|
||||
@@ -0,0 +1,160 @@
|
||||
#include <precomp.h>
|
||||
|
||||
static INT
|
||||
LengthOfStrResource(IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
HRSRC hrSrc;
|
||||
HGLOBAL hRes;
|
||||
LPWSTR lpName, lpStr;
|
||||
|
||||
if (hInst == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* There are always blocks of 16 strings */
|
||||
lpName = (LPWSTR)MAKEINTRESOURCE((uID >> 4) + 1);
|
||||
|
||||
/* Find the string table block */
|
||||
if ((hrSrc = FindResourceW(hInst, lpName, (LPWSTR)RT_STRING)) &&
|
||||
(hRes = LoadResource(hInst, hrSrc)) &&
|
||||
(lpStr = LockResource(hRes)))
|
||||
{
|
||||
UINT x;
|
||||
|
||||
/* Find the string we're looking for */
|
||||
uID &= 0xF; /* position in the block, same as % 16 */
|
||||
for (x = 0; x < uID; x++)
|
||||
{
|
||||
lpStr += (*lpStr) + 1;
|
||||
}
|
||||
|
||||
/* Found the string */
|
||||
return (int)(*lpStr);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
INT
|
||||
AllocAndLoadString(OUT LPTSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
IN UINT uID)
|
||||
{
|
||||
INT ln;
|
||||
|
||||
ln = LengthOfStrResource(hInst,
|
||||
uID);
|
||||
if (ln++ > 0)
|
||||
{
|
||||
(*lpTarget) = (LPWSTR)LocalAlloc(LMEM_FIXED,
|
||||
ln * sizeof(TCHAR));
|
||||
if ((*lpTarget) != NULL)
|
||||
{
|
||||
INT Ret;
|
||||
if (!(Ret = LoadString(hInst, uID, *lpTarget, ln)))
|
||||
{
|
||||
LocalFree((HLOCAL)(*lpTarget));
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
DWORD
|
||||
LoadAndFormatString(IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
OUT LPTSTR *lpTarget,
|
||||
...)
|
||||
{
|
||||
DWORD Ret = 0;
|
||||
LPTSTR lpFormat;
|
||||
va_list lArgs;
|
||||
|
||||
if (AllocAndLoadString(&lpFormat,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
va_start(lArgs, lpTarget);
|
||||
/* let's use FormatMessage to format it because it has the ability to allocate
|
||||
memory automatically */
|
||||
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
|
||||
lpFormat,
|
||||
0,
|
||||
0,
|
||||
(LPTSTR)lpTarget,
|
||||
0,
|
||||
&lArgs);
|
||||
va_end(lArgs);
|
||||
|
||||
LocalFree((HLOCAL)lpFormat);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
BOOL
|
||||
StatusBarLoadAndFormatString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
...)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
LPTSTR lpFormat, lpStr;
|
||||
va_list lArgs;
|
||||
|
||||
if (AllocAndLoadString(&lpFormat,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
va_start(lArgs, uID);
|
||||
/* let's use FormatMessage to format it because it has the ability to allocate
|
||||
memory automatically */
|
||||
Ret = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
|
||||
lpFormat,
|
||||
0,
|
||||
0,
|
||||
(LPTSTR)&lpStr,
|
||||
0,
|
||||
&lArgs);
|
||||
va_end(lArgs);
|
||||
|
||||
if (lpStr != NULL)
|
||||
{
|
||||
Ret = (BOOL)SendMessage(hStatusBar,
|
||||
SB_SETTEXT,
|
||||
(WPARAM)PartId,
|
||||
(LPARAM)lpStr);
|
||||
LocalFree((HLOCAL)lpStr);
|
||||
}
|
||||
|
||||
LocalFree((HLOCAL)lpFormat);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
BOOL
|
||||
StatusBarLoadString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID)
|
||||
{
|
||||
BOOL Ret = FALSE;
|
||||
LPTSTR lpStr;
|
||||
|
||||
if (AllocAndLoadString(&lpStr,
|
||||
hInstance,
|
||||
uID) > 0)
|
||||
{
|
||||
Ret = (BOOL)SendMessage(hStatusBar,
|
||||
SB_SETTEXT,
|
||||
(WPARAM)PartId,
|
||||
(LPARAM)lpStr);
|
||||
LocalFree((HLOCAL)lpStr);
|
||||
}
|
||||
|
||||
return Ret;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "imagesoft.h"
|
||||
#include <precomp.h>
|
||||
|
||||
static OPENFILENAME ofn;
|
||||
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
#ifndef __IMAGESOFT_PRECOMP_H
|
||||
#define __IMAGESOFT_PRECOMP_H
|
||||
|
||||
//#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <windowsx.h> /* GET_X/Y_LPARAM */
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
#include <commctrl.h>
|
||||
#include "resource.h"
|
||||
|
||||
/* FIXME - add to headers !!! */
|
||||
#ifndef SB_SIMPLEID
|
||||
#define SB_SIMPLEID 0xFF
|
||||
#endif
|
||||
#ifndef RBBS_USECHEVRON
|
||||
#define RBBS_USECHEVRON 0x200
|
||||
#endif
|
||||
#ifndef RBN_CHEVRONPUSHED
|
||||
#define RBN_CHEVRONPUSHED (RBN_FIRST - 10)
|
||||
#endif
|
||||
ULONG DbgPrint(PCH Format,...);
|
||||
|
||||
#define MAX_KEY_LENGTH 256
|
||||
#define NUM_BUTTONS 14
|
||||
|
||||
/* generic definitions and forward declarations */
|
||||
struct _MAIN_WND_INFO;
|
||||
struct _EDIT_WND_INFO;
|
||||
|
||||
typedef enum _MDI_EDITOR_TYPE {
|
||||
metUnknown = 0,
|
||||
metImageEditor,
|
||||
} MDI_EDITOR_TYPE, *PMDI_EDITOR_TYPE;
|
||||
|
||||
/* about.c */
|
||||
INT_PTR CALLBACK AboutDialogProc(HWND hDlg,
|
||||
UINT message,
|
||||
WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
|
||||
/* imagesoft.c */
|
||||
extern HINSTANCE hInstance;
|
||||
extern HANDLE ProcessHeap;
|
||||
|
||||
/* imgedwnd.c */
|
||||
typedef struct _OPEN_IMAGE_EDIT_INFO
|
||||
{
|
||||
BOOL CreateNew;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
LONG Width;
|
||||
LONG Height;
|
||||
} New;
|
||||
struct
|
||||
{
|
||||
LPCTSTR lpFileName;
|
||||
} Open;
|
||||
};
|
||||
} OPEN_IMAGE_EDIT_INFO, *POPEN_IMAGE_EDIT_INFO;
|
||||
|
||||
typedef struct _EDIT_WND_INFO
|
||||
{
|
||||
MDI_EDITOR_TYPE MdiEditorType; /* Must be first member! */
|
||||
|
||||
HWND hSelf;
|
||||
struct _MAIN_WND_INFO *MainWnd;
|
||||
struct _EDIT_WND_INFO *Next;
|
||||
POINT ScrollPos;
|
||||
USHORT Zoom;
|
||||
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo; /* Only valid during initialization */
|
||||
|
||||
/* Bitmap size */
|
||||
LONG Width;
|
||||
LONG Height;
|
||||
} EDIT_WND_INFO, *PEDIT_WND_INFO;
|
||||
|
||||
BOOL CreateImageEditWindow(struct _MAIN_WND_INFO *MainWnd,
|
||||
LPCTSTR lpCaption,
|
||||
POPEN_IMAGE_EDIT_INFO OpenInfo);
|
||||
VOID SetImageEditorEnvironment(PEDIT_WND_INFO Info,
|
||||
BOOL Setup);
|
||||
BOOL InitImageEditWindowImpl(VOID);
|
||||
VOID UninitImageEditWindowImpl(VOID);
|
||||
|
||||
/* tooldock.c */
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TOP_DOCK = 0,
|
||||
LEFT_DOCK,
|
||||
RIGHT_DOCK,
|
||||
BOTTOM_DOCK,
|
||||
NO_DOCK
|
||||
} DOCK_POSITION;
|
||||
|
||||
typedef struct _DOCKBAR
|
||||
{
|
||||
UINT BarId;
|
||||
LPCTSTR lpName;
|
||||
UINT DisplayTextId;
|
||||
DOCK_POSITION Position;
|
||||
} DOCKBAR, *PDOCKBAR;
|
||||
|
||||
struct _TOOLBAR_DOCKS;
|
||||
|
||||
typedef BOOL (CALLBACK *PDOCKBAR_CREATECLIENT)(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hParent,
|
||||
HWND *hwnd);
|
||||
typedef BOOL (CALLBACK *PDOCKBAR_DESTROYCLIENT)(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hwnd);
|
||||
typedef BOOL (CALLBACK *PDOCKBAR_INSERTBAND)(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
UINT *Index,
|
||||
LPREBARBANDINFO rbi);
|
||||
typedef VOID (CALLBACK *PDOCKBAR_DOCKBAND)(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
DOCK_POSITION DockFrom,
|
||||
DOCK_POSITION DockTo,
|
||||
LPREBARBANDINFO rbi);
|
||||
typedef VOID (CALLBACK *PDOCKBAR_CHEVRONPUSHED)(struct _TOOLBAR_DOCKS *TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
HWND hwndChild,
|
||||
LPNMREBARCHEVRON lpnm);
|
||||
|
||||
typedef struct _DOCKBAR_ITEM_CALLBACKS
|
||||
{
|
||||
PDOCKBAR_CREATECLIENT CreateClient;
|
||||
PDOCKBAR_DESTROYCLIENT DestroyClient;
|
||||
PDOCKBAR_INSERTBAND InsertBand;
|
||||
PDOCKBAR_DOCKBAND DockBand;
|
||||
PDOCKBAR_CHEVRONPUSHED ChevronPushed;
|
||||
} DOCKBAR_ITEM_CALLBACKS, *PDOCKBAR_ITEM_CALLBACKS;
|
||||
|
||||
typedef struct _DOCKBAR_ITEM
|
||||
{
|
||||
struct _DOCKBAR_ITEM *Next;
|
||||
DOCKBAR DockBar;
|
||||
PVOID Context;
|
||||
HWND hWndTool;
|
||||
HWND hWndClient;
|
||||
DOCK_POSITION PrevDock;
|
||||
UINT PrevBandIndex;
|
||||
const DOCKBAR_ITEM_CALLBACKS *Callbacks;
|
||||
} DOCKBAR_ITEM, *PDOCKBAR_ITEM;
|
||||
|
||||
typedef VOID (CALLBACK *PDOCKBAR_PARENTRESIZE)(PVOID Context,
|
||||
WORD cx,
|
||||
WORD cy);
|
||||
|
||||
#define DOCKS_COUNT 4
|
||||
typedef struct _TOOLBAR_DOCKS
|
||||
{
|
||||
HWND hParent;
|
||||
PVOID Context;
|
||||
HWND hRebar[DOCKS_COUNT];
|
||||
RECT rcRebar[DOCKS_COUNT];
|
||||
RECT rcClient;
|
||||
PDOCKBAR_ITEM Items;
|
||||
PDOCKBAR_PARENTRESIZE ParentResize;
|
||||
PDOCKBAR_ITEM Dragging;
|
||||
UINT DraggingBandId;
|
||||
TCHAR szTempText[255];
|
||||
} TOOLBAR_DOCKS, *PTOOLBAR_DOCKS;
|
||||
|
||||
VOID TbdInitializeDocks(PTOOLBAR_DOCKS TbDocks,
|
||||
HWND hWndParent,
|
||||
PVOID Context,
|
||||
PDOCKBAR_PARENTRESIZE ParentResizeProc);
|
||||
INT TbdAdjustUpdateClientRect(PTOOLBAR_DOCKS TbDocks,
|
||||
PRECT rcClient);
|
||||
HDWP TbdDeferDocks(HDWP hWinPosInfo,
|
||||
PTOOLBAR_DOCKS TbDocks);
|
||||
BOOL TbdAddToolbar(PTOOLBAR_DOCKS TbDocks,
|
||||
const DOCKBAR *Dockbar,
|
||||
PVOID Context,
|
||||
const DOCKBAR_ITEM_CALLBACKS *DockbarCallbacks);
|
||||
BOOL TbdHandleNotifications(PTOOLBAR_DOCKS TbDocks,
|
||||
LPNMHDR pnmh,
|
||||
LRESULT *Result);
|
||||
VOID TbdShowFloatingToolbars(PTOOLBAR_DOCKS TbDocks,
|
||||
BOOL Show);
|
||||
BOOL TbdInitImpl(VOID);
|
||||
VOID TbdUninitImpl(VOID);
|
||||
|
||||
/* mainwnd.c */
|
||||
typedef struct _MENU_HINT
|
||||
{
|
||||
WORD CmdId;
|
||||
UINT HintId;
|
||||
} MENU_HINT, *PMENU_HINT;
|
||||
|
||||
typedef struct _MAIN_WND_INFO
|
||||
{
|
||||
HWND hSelf;
|
||||
HWND hMdiClient;
|
||||
HWND hStatus;
|
||||
int nCmdShow;
|
||||
|
||||
TOOLBAR_DOCKS ToolDocks;
|
||||
|
||||
/* Editors */
|
||||
PEDIT_WND_INFO ImageEditors;
|
||||
UINT ImagesCreated;
|
||||
|
||||
PVOID ActiveEditor;
|
||||
|
||||
/* status flags */
|
||||
BOOL InMenuLoop : 1;
|
||||
} MAIN_WND_INFO, *PMAIN_WND_INFO;
|
||||
|
||||
BOOL InitMainWindowImpl(VOID);
|
||||
VOID UninitMainWindowImpl(VOID);
|
||||
HWND CreateMainWindow(LPCTSTR lpCaption,
|
||||
int nCmdShow);
|
||||
BOOL MainWndTranslateMDISysAccel(HWND hwnd,
|
||||
LPMSG lpMsg);
|
||||
VOID MainWndSwitchEditorContext(PMAIN_WND_INFO Info,
|
||||
HWND hDeactivate,
|
||||
HWND hActivate);
|
||||
MDI_EDITOR_TYPE MainWndGetCurrentEditor(PMAIN_WND_INFO MainWnd,
|
||||
PVOID *Info);
|
||||
|
||||
/* misc.c */
|
||||
INT AllocAndLoadString(OUT LPTSTR *lpTarget,
|
||||
IN HINSTANCE hInst,
|
||||
IN UINT uID);
|
||||
|
||||
DWORD LoadAndFormatString(IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
OUT LPTSTR *lpTarget,
|
||||
...);
|
||||
|
||||
BOOL StatusBarLoadAndFormatString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID,
|
||||
...);
|
||||
|
||||
BOOL StatusBarLoadString(IN HWND hStatusBar,
|
||||
IN INT PartId,
|
||||
IN HINSTANCE hInstance,
|
||||
IN UINT uID);
|
||||
|
||||
#endif /* __IMAGESOFT_PRECOMP_H */
|
||||
@@ -33,8 +33,11 @@
|
||||
|
||||
#define ID_REFRESH 3000
|
||||
#define ID_HELP 3001
|
||||
#define ID_WINDOW_TILE 3002
|
||||
#define ID_WINDOW_CASCADE 3003
|
||||
#define ID_WINDOW_TILE_HORZ 3002
|
||||
#define ID_WINDOW_TILE_VERT 3003
|
||||
#define ID_WINDOW_CASCADE 3004
|
||||
#define ID_WINDOW_NEXT 3005
|
||||
#define ID_WINDOW_ARRANGE 3006
|
||||
|
||||
/* Menu */
|
||||
#define IDR_MAINMENU 102
|
||||
@@ -72,7 +75,22 @@
|
||||
/* about box info */
|
||||
#define IDD_ABOUTBOX 200
|
||||
#define IDC_LICENSE_EDIT 201
|
||||
#define IDS_LICENSE 202
|
||||
|
||||
#define IDS_CURPOS 550
|
||||
#define IDS_READY 551
|
||||
#define IDS_APPNAME 101
|
||||
#define IDS_LICENSE 102
|
||||
#define IDS_READY 103
|
||||
#define IDS_TOOLBAR_STANDARD 201
|
||||
#define IDS_TOOLBAR_TEST 202
|
||||
#define IDS_IMAGE_NAME 203
|
||||
|
||||
/* menu hints */
|
||||
#define IDS_HINT_EXIT 20001
|
||||
|
||||
/* system menu hints */
|
||||
#define IDS_HINT_SYS_RESTORE 21001
|
||||
#define IDS_HINT_SYS_MOVE 21002
|
||||
#define IDS_HINT_SYS_SIZE 21003
|
||||
#define IDS_HINT_SYS_MINIMIZE 21004
|
||||
#define IDS_HINT_SYS_MAXIMIZE 21005
|
||||
#define IDS_HINT_SYS_CLOSE 21006
|
||||
#define IDS_HINT_SYS_NEXT 21007
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user