- close single or all MDI client windows - add edit colour dialog - switch menus on/off according to status - add open / saveas dialogs Modified: trunk/reactos/base/applications/imagesoft/about.c Modified: trunk/reactos/base/applications/imagesoft/en.rc Added: trunk/reactos/base/applications/imagesoft/opensave.c Modified: trunk/reactos/base/applications/imagesoft/paint.c Modified: trunk/reactos/base/applications/imagesoft/paint.h Modified: trunk/reactos/base/applications/imagesoft/resource.h _____
Modified: trunk/reactos/base/applications/imagesoft/about.c --- trunk/reactos/base/applications/imagesoft/about.c 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/about.c 2006-02-15 17:58:49 UTC (rev 114) @@ -1,4 +1,3 @@
- #include "paint.h"
extern HINSTANCE hInstance; _____
Modified: trunk/reactos/base/applications/imagesoft/en.rc --- trunk/reactos/base/applications/imagesoft/en.rc 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/en.rc 2006-02-15 17:58:49 UTC (rev 114) @@ -3,8 +3,9 @@
POPUP "&File" BEGIN MENUITEM "New...", ID_NEW - MENUITEM "Open...", ID_OPEN, GRAYED - MENUITEM "Close...", ID_CLOSE, GRAYED + MENUITEM "Open...", ID_OPEN + MENUITEM "Close", ID_CLOSE, GRAYED + MENUITEM "Close all", ID_CLOSEALL, GRAYED MENUITEM SEPARATOR MENUITEM "Save", ID_SAVE, GRAYED MENUITEM "Save As", ID_SAVEAS, GRAYED @@ -16,7 +17,7 @@ MENUITEM SEPARATOR MENUITEM "E&xit", ID_EXIT END - POPUP "Edit", GRAYED + POPUP "Edit" BEGIN MENUITEM "Undo", ID_UNDO, GRAYED MENUITEM "Redo", ID_REDO, GRAYED @@ -28,7 +29,7 @@ MENUITEM SEPARATOR MENUITEM "Select All", ID_SELALL, GRAYED END - POPUP "Image", GRAYED + POPUP "Image" BEGIN MENUITEM "Crop", -1, GRAYED MENUITEM "Resize", -1, GRAYED @@ -40,8 +41,12 @@ MENUITEM SEPARATOR MENUITEM "Attributes", -1, GRAYED END - POPUP "Window", GRAYED + POPUP "Colours" BEGIN + MENUITEM "Edit Colours...", ID_EDITCOLOURS + END + POPUP "Window" + BEGIN MENUITEM "Tile", -1 MENUITEM "Cascade", -1 END @@ -85,3 +90,18 @@ IDS_CURPOS "Cursor : %d,%d" IDS_READY "Ready" END + +/* Tooltips */ +STRINGTABLE DISCARDABLE +BEGIN + IDS_TOOLTIP_NEW "New" + IDS_TOOLTIP_OPEN "Open" + IDS_TOOLTIP_SAVE "Save" + IDS_TOOLTIP_PRINTPRE "Print preview" + IDS_TOOLTIP_PRINT "Print" + IDS_TOOLTIP_CUT "Cut" + IDS_TOOLTIP_COPY "Copy" + IDS_TOOLTIP_PASTE "Paste" + IDS_TOOLTIP_UNDO "Undo" + IDS_TOOLTIP_REDO "Redo" +END _____
Added: trunk/reactos/base/applications/imagesoft/opensave.c --- trunk/reactos/base/applications/imagesoft/opensave.c 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/opensave.c 2006-02-15 17:58:49 UTC (rev 114) @@ -0,0 +1,90 @@
+#include "paint.h" + +static OPENFILENAME ofn; + +/* + * Initialize file open / save structure + */ +VOID FileInitialize(HWND hwnd) +{ + ZeroMemory(&ofn, sizeof(ofn)); + ofn.lStructSize = sizeof(OPENFILENAME); + ofn.hwndOwner = hwnd; + ofn.nMaxFile = MAX_PATH; + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = _T("bmp"); + +} + +/* + * Write the file to disk + */ +BOOL DoWriteFile(LPCTSTR pszFileName) +{ + return TRUE; +} + +/* + * Read the file from disk + */ +BOOL DoReadFile(LPCTSTR pszFileName) +{ + return TRUE; +} + + +/* + * Show the file open dialog + */ +VOID DoOpenFile(HWND hwnd) +{ + TCHAR szFileName[MAX_PATH] = _T(""); + static TCHAR Filter[] = _T("All image files (*.gif,*.bmp,*.jpg,*.jpeg,*.tif,*.png)\0*.gif,*.bmp,*.jpg,*.jpeg,*.tif,* .png\0") \ + _T("All files (*.*)\0*.*\0") \ + _T("Graphics Interchange format (*gif)\0*.gif\0") \ + _T("Windows Bitmap (*bmp)\0*.bmp\0") \ + _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \ + _T("TAG Image File Format (*tif)\0*.tif\0") \ + _T("Portable Network Graphics (*png)\0*.png\0\0"); + + ofn.lpstrFilter = Filter; + ofn.lpstrFile = szFileName; + ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + + if (GetOpenFileName(&ofn)) + { + if (DoReadFile(szFileName)) + return; + } + + if (CommDlgExtendedError() != CDERR_GENERALCODES) + MessageBox(NULL, _T("Open file failed"), NULL, 0); +} + + +/* + * Show the file saveas dialog + */ +VOID DoSaveFile(HWND hwnd) +{ + TCHAR szFileName[MAX_PATH] = _T(""); + static TCHAR Filter[] = _T("Graphics Interchange format (*gif)\0*.gif\0") \ + _T("Windows Bitmap (*bmp)\0*.bmp\0") \ + _T("JPEG File Interchange Format (*jpg,*.jpeg)\0*.jpg,*.jpeg\0") \ + _T("TAG Image File Format (*tif)\0*.tif\0") \ + _T("Portable Network Graphics (*png)\0*.png\0\0"); + + ofn.lpstrFilter = Filter; + ofn.lpstrFile = szFileName; + ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + + if (GetSaveFileName(&ofn)) + { + if (DoWriteFile(szFileName)) + return; + } + + if (CommDlgExtendedError() != CDERR_GENERALCODES) + MessageBox(NULL, _T("Save to file failed"), NULL, 0); +} + _____
Modified: trunk/reactos/base/applications/imagesoft/paint.c --- trunk/reactos/base/applications/imagesoft/paint.c 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/paint.c 2006-02-15 17:58:49 UTC (rev 114) @@ -1,12 +1,3 @@
-/* - * PROJECT: ReactOS Services - * LICENSE: GPL - See COPYING in the top level directory - * FILE: base/system/servman/servman.c - * PURPOSE: Main window message handler - * COPYRIGHT: Copyright 2005 - 2006 Ged Murphy gedmurphy@gmail.com - * - */ - #include "paint.h"
#define ID_MDI_FIRSTCHILD 50000 @@ -20,39 +11,46 @@ HWND hMDIClient; HWND hStatus; HWND hTool; +HWND hwndRebar; HMENU hShortcutMenu;
+/* + * 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; + MDICREATESTRUCT mcs; + HWND hChild; + TCHAR Buf[15]; + static DWORD MDINum = 1;
- _sntprintf(Buf, sizeof(Buf) / sizeof(TCHAR), _T("Untitled%d"), MDINum); + _sntprintf(Buf, sizeof(Buf) / sizeof(TCHAR), _T("Untitled%d"), MDINum);
- mcs.szTitle = Buf; - mcs.szClass = ChildClassName; - mcs.hOwner = hInstance; - mcs.x = mcs.cx = CW_USEDEFAULT; - mcs.y = mcs.cy = CW_USEDEFAULT; - mcs.style = MDIS_ALLCHILDSTYLES; + mcs.szTitle = Buf; + mcs.szClass = ChildClassName; + mcs.hOwner = hInstance; + mcs.x = mcs.cx = CW_USEDEFAULT; + mcs.y = mcs.cy = CW_USEDEFAULT; + mcs.style = MDIS_ALLCHILDSTYLES;
- hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs); - if(!hChild) - { - MessageBox(hMDIClient, _T("MDI Child creation failed."), _T("Error!"), - MB_ICONEXCLAMATION | MB_OK); + hChild = (HWND)SendMessage(hMDIClient, WM_MDICREATE, 0, (LONG)&mcs); + if(!hChild) + { + MessageBox(hMDIClient, _T("MDI Child creation failed."), _T("Error!"), + MB_ICONEXCLAMATION | MB_OK); return hChild; - } + }
- MDINum++; - return hChild; + MDINum++; + return hChild; }
- +/* + * Main program message handler + */ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) @@ -70,28 +68,28 @@ { /* 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_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* save */ + {STD_FILESAVE, ID_SAVE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0}, /* save */
/* Note: First item for a seperator is its width in pixels */ {10, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
- {STD_PRINTPRE, ID_PRINTPRE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print */ - {STD_PRINT, ID_PRINT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* print preview */ + {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_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* cut */ - {STD_COPY, ID_COPY, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* copy */ - {STD_PASTE, ID_PASTE, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* paste */ + {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_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* undo */ - {STD_REDOW, ID_REDO, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0 }, /* redo */ + {STD_UNDO, ID_UNDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* undo */ + {STD_REDOW, ID_REDO, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* redo */ };
-/* ======================== Create Toolbar ============================== */ +/* ======================== Create Std Toolbar ============================== */
/* Create Toolbar */ hTool = CreateWindowEx(0, @@ -132,6 +130,11 @@
+/* ======================== Create Floating Toolbar ============================== */ + + + + /* ======================== Create Status Bar ============================== */
hStatus = CreateWindowEx(0, @@ -144,10 +147,10 @@ hInstance, NULL); if(hStatus == NULL) - MessageBox(hwnd, _T("Could not create status bar."), + MessageBox(hwnd, _T("Could not create status bar."), _T("Error!"), MB_OK | MB_ICONERROR);
- SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths); + SendMessage(hStatus, SB_SETPARTS, sizeof(statwidths)/sizeof(int), (LPARAM)statwidths);
/* ======================== Create Popup Menu ============================== */ @@ -158,73 +161,78 @@
/* ======================= Create MDI Client ============================= */
- /* Find window menu where children will be listed */ - ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 3); - ccs.idFirstChild = ID_MDI_FIRSTCHILD; + /* Find window menu where children will be listed */ + ccs.hWindowMenu = GetSubMenu(GetMenu(hwnd), 4); + 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); + 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); + if(hMDIClient == NULL) + MessageBox(hwnd, _T("Could not create MDI client."), + _T("Error!"), MB_OK | MB_ICONERROR);
+/* ======================= Miscelaneous ============================= */ + /* 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); + } break;
case WM_SIZE: { - RECT rcTool; - int iToolHeight; + RECT rcTool; + int iToolHeight;
- RECT rcStatus; - int iStatusHeight; + RECT rcStatus; + int iStatusHeight;
- HWND hMDI; - int iMDIHeight; - RECT rcClient; + HWND hMDI; + int iMDIHeight; + RECT rcClient;
- /* Size toolbar and get height */ + /* Size toolbar and get height */ hTool = GetDlgItem(hwnd, IDC_TOOLBAR); - SendMessage(hTool, TB_AUTOSIZE, 0, 0); + SendMessage(hTool, TB_AUTOSIZE, 0, 0);
- GetWindowRect(hTool, &rcTool); - iToolHeight = rcTool.bottom - rcTool.top; + GetWindowRect(hTool, &rcTool); + iToolHeight = rcTool.bottom - rcTool.top;
- /* Size status bar and get height */ - hStatus = GetDlgItem(hwnd, IDC_STATUSBAR); - SendMessage(hStatus, WM_SIZE, 0, 0); + /* Size status bar and get height */ + hStatus = GetDlgItem(hwnd, IDC_STATUSBAR); + SendMessage(hStatus, WM_SIZE, 0, 0);
- GetWindowRect(hStatus, &rcStatus); - iStatusHeight = rcStatus.bottom - rcStatus.top; + GetWindowRect(hStatus, &rcStatus); + iStatusHeight = rcStatus.bottom - rcStatus.top;
- /* Calculate remaining height and size list view */ - GetClientRect(hwnd, &rcClient); + /* Calculate remaining height and size for the MDI frame */ + GetClientRect(hwnd, &rcClient);
- iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight; + iMDIHeight = rcClient.bottom - iToolHeight - iStatusHeight;
- hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI); - SetWindowPos(hMDIClient, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER); - } - break; + hMDI = GetDlgItem(hwnd, IDC_MAIN_MDI); + SetWindowPos(hMDIClient, NULL, 0, iToolHeight, rcClient.right, iMDIHeight, SWP_NOZORDER); + } + break;
- case WM_NOTIFY: + case WM_NOTIFY: { NMHDR* nm = (NMHDR*) lParam;
@@ -243,43 +251,43 @@ switch (idButton) { case ID_NEW: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PROP); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW); break;
case ID_OPEN: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REFRESH); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_OPEN); break;
case ID_SAVE: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXPORT); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_SAVE); break;
case ID_PRINTPRE: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_NEW); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINTPRE); break;
case ID_PRINT: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_START); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PRINT); break;
case ID_CUT: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_STOP); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_CUT); break;
case ID_COPY: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PAUSE); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_COPY); break;
case ID_PASTE: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_RESTART); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_PASTE); break;
case ID_UNDO: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_HELP); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_UNDO); break;
case ID_REDO: - lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_EXIT); + lpttt->lpszText = MAKEINTRESOURCE(IDS_TOOLTIP_REDO); break;
} @@ -306,25 +314,67 @@
case WM_COMMAND:
- switch(LOWORD(wParam)) - { - case ID_NEW: - CreateNewMDIChild(hMDIClient); - break; + switch(LOWORD(wParam)) + { + case ID_NEW: + CreateNewMDIChild(hMDIClient); + break;
- case ID_REFRESH: + case ID_OPEN: + DoOpenFile(hwnd); break;
- - case ID_HELP: - MessageBox(NULL, _T("Help is not yet implemented\n"), - _T("Note!"), MB_OK | MB_ICONINFORMATION); + 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_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; @@ -340,67 +390,50 @@ (DLGPROC)AboutDialogProc); break;
- default: - { - 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); - } - } - } + 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: + case WM_CLOSE: DestroyMenu(hShortcutMenu); - DestroyWindow(hwnd); - break; + DestroyWindow(hwnd); + break;
- case WM_DESTROY: - PostQuitMessage(0); - break; + case WM_DESTROY: + PostQuitMessage(0); + break;
- default: - return DefFrameProc(hwnd, hMDIClient, msg, wParam, lParam); + 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; + static BOOL fLeftButtonDown, fRightButtonDown; + static HDC hdcMem; + static INT cxClient, cyClient, xMouse, yMouse; + HDC hdc; + PAINTSTRUCT ps;
switch(msg) { @@ -428,16 +461,20 @@ SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)Buf); }
- EnableMenuItem(hMenu, 1, MF_BYPOSITION | EnableFlag); - EnableMenuItem(hMenu, 2, MF_BYPOSITION | EnableFlag); - EnableMenuItem(hMenu, 3, MF_BYPOSITION | EnableFlag); + 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_FILE_SAVEAS, MF_BYCOMMAND | EnableFlag); + EnableMenuItem(hFileMenu, ID_SAVEAS, MF_BYCOMMAND | EnableFlag);
-// EnableMenuItem(hFileMenu, ID_FILE_CLOSE, MF_BYCOMMAND | EnableFlag); -// EnableMenuItem(hFileMenu, ID_FILE_CLOSEALL, 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; @@ -523,21 +560,7 @@ case WM_COMMAND: switch(LOWORD(wParam)) { -/* case ID_OPEN: - DoFileOpen(hwnd); - break; - case ID_SAVEAS: - DoFileSave(hwnd); - break; - case ID_CUT: - SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_CUT, 0, 0); - break; - case ID_COPY: - SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_COPY, 0, 0); - break; - case ID_PASTE: - SendDlgItemMessage(hwnd, IDC_CHILD_EDIT, WM_PASTE, 0, 0); -*/ break; + } break;
@@ -545,38 +568,49 @@ return DefMDIChildProc(hwnd, msg, wParam, lParam);
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 = LoadIcon(NULL, IDI_APPLICATION); + 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; + if(!RegisterClassEx(&wc)) + { + MessageBox(0, _T("Could Not Register Child Window"), _T("Error!"), + MB_ICONEXCLAMATION | MB_OK); + return FALSE; + } + else + return TRUE; }
#ifdef _MSC_VER @@ -587,10 +621,13 @@ { WNDCLASSEX wc; MSG Msg; + INITCOMMONCONTROLSEX icex;
hInstance = hThisInstance;
- InitCommonControls(); + icex.dwSize = sizeof(INITCOMMONCONTROLSEX); + icex.dwICC = ICC_BAR_CLASSES; + InitCommonControlsEx(&icex);
wc.cbSize = sizeof(WNDCLASSEX); wc.style = 0; @@ -616,19 +653,18 @@ 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); + hMainWnd = CreateWindowEx(0, + AppClassName, + _T("ImageSoft"), + WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN, + CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, + NULL, NULL, hInstance, NULL);
if(hMainWnd == NULL) { - MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"), - MB_ICONEXCLAMATION | MB_OK); - return 0; + MessageBox(NULL, _T("Window Creation Failed!"), _T("Error!"), + MB_ICONEXCLAMATION | MB_OK); + return 0; }
ShowWindow(hMainWnd, nCmdShow); _____
Modified: trunk/reactos/base/applications/imagesoft/paint.h --- trunk/reactos/base/applications/imagesoft/paint.h 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/paint.h 2006-02-15 17:58:49 UTC (rev 114) @@ -14,4 +14,8 @@
BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
+VOID FileInitialize (HWND hwnd); +VOID DoOpenFile(HWND hwnd); +VOID DoSaveFile(HWND hwnd); + #endif /* __SERVMAN_H */ _____
Modified: trunk/reactos/base/applications/imagesoft/resource.h --- trunk/reactos/base/applications/imagesoft/resource.h 2006-02-14 17:39:13 UTC (rev 113) +++ trunk/reactos/base/applications/imagesoft/resource.h 2006-02-15 17:58:49 UTC (rev 114) @@ -7,19 +7,21 @@
#define ID_NEW 2000 #define ID_OPEN 2001 #define ID_CLOSE 2002 -#define ID_SAVE 2003 -#define ID_SAVEAS 2004 -#define ID_PRINTPRE 2005 -#define ID_PRINT 2006 -#define ID_PROP 2007 -#define ID_CUT 2008 -#define ID_COPY 2009 -#define ID_PASTE 2010 -#define ID_PASTENEWIMAGE 2011 -#define ID_UNDO 2012 -#define ID_REDO 2013 -#define ID_SELALL 2014 -#define ID_EXIT 2015 +#define ID_CLOSEALL 2003 +#define ID_SAVE 2004 +#define ID_SAVEAS 2005 +#define ID_PRINTPRE 2006 +#define ID_PRINT 2007 +#define ID_PROP 2008 +#define ID_CUT 2009 +#define ID_COPY 2010 +#define ID_PASTE 2011 +#define ID_PASTENEWIMAGE 2012 +#define ID_UNDO 2013 +#define ID_REDO 2014 +#define ID_SELALL 2015 +#define ID_EXIT 2016 +#define ID_EDITCOLOURS 2017
#define ID_REFRESH 3000 #define ID_HELP 3001 @@ -33,18 +35,18 @@
/* tooltips */ -#define IDS_TOOLTIP_PROP 6000 -#define IDS_TOOLTIP_REFRESH 6001 -#define IDS_TOOLTIP_EXPORT 6002 -#define IDS_TOOLTIP_START 6003 -#define IDS_TOOLTIP_STOP 6004 -#define IDS_TOOLTIP_PAUSE 6005 -#define IDS_TOOLTIP_RESTART 6006 -#define IDS_TOOLTIP_NEW 6007 -#define IDS_TOOLTIP_HELP 6008 -#define IDS_TOOLTIP_EXIT 6009 +#define IDS_TOOLTIP_NEW 6000 +#define IDS_TOOLTIP_OPEN 6001 +#define IDS_TOOLTIP_SAVE 6002 +#define IDS_TOOLTIP_PRINTPRE 6003 +#define IDS_TOOLTIP_PRINT 6004 +#define IDS_TOOLTIP_CUT 6005 +#define IDS_TOOLTIP_COPY 6006 +#define IDS_TOOLTIP_PASTE 6007 +#define IDS_TOOLTIP_UNDO 6008 +#define IDS_TOOLTIP_REDO 6009
-#define IDI_ICON 50 +#define IDI_ICON 50 #define IDB_BUTTONS 51
/* toolbar buttons */