//..................................................................................................................... // // Main Frame Window : Implementation file. // // Copyright (C) 1990, 1999 LEAD Technologies, Inc. // All rights reserved. // //..................................................................................................................... //..................................................................................................................... // INCLUDES //..................................................................................................................... #include "StdSDK.h" // Standard application includes #include "About.h" #include "resource.h" // For resource identifiers #include "mdi.h" #include "paint.h" //..................................................................................................................... // CONSTANTS //..................................................................................................................... #define MAX_STRING_BUFFER 255 #define MAXFILENAME _MAX_PATH #define MAX_PAINTBRUSH_TOUCH_BITMAP 1 #define MAX_PAINTBRUSH_TEXTURE_BITMAP 1 typedef struct { L_UINT cBitsPerPixel ; L_UINT cxScreen ; L_UINT cyScreen ; } DISPLAYDATA ; //..................................................................................................................... // TYPES //..................................................................................................................... //..................................................................................................................... // VARIABLES //..................................................................................................................... pAUTOMATIONHANDLE g_pAutomation ; pTOOLBARHANDLE g_pToolbar ; HWND g_MDIClientWnd ; HWND g_hMainFrame ; HMENU g_hMainMenu ; // main menu for child-free MDI app HACCEL g_hMainAccel ; // accelerators for child-free MDI app HACCEL g_hAccel; // Current accelerator table in use PAINTBRUSH g_Paintbrush ; PAINTSHAPE g_PaintShape ; PAINTREGION g_PaintRegion ; PAINTFILL g_PaintFill ; PAINTTEXT g_PaintText ; BITMAPHANDLE g_hBackTileBitmap ; BITMAPHANDLE g_hPaperTextureBitmap ; BITMAPHANDLE g_hBrushBitmap ; HBITMAP g_hBorderTileBitmap ; L_UINT g_PrevButton; L_TCHAR g_szCurrentText [ 255 ] ; static L_BOOL g_fViewToolbar = TRUE ; static L_BOOL g_fViewStatueLine = TRUE ; //..................................................................................................................... // FUNCTIONS //..................................................................................................................... LRESULT CALLBACK MainFrameWndProc ( HWND hWnd, L_UINT message, WPARAM wParam, LPARAM lParam ) ; //..................................................................................................................... // Function prototypes for static functions. //..................................................................................................................... static L_BOOL Mainframe_DisplayContextMenu (HWND hWnd, POINT pt) ; //..................................................................................................................... // Function prototypes for callback functions. //..................................................................................................................... static L_BOOL CALLBACK Mainframe_SysColorChangeEnumeration ( HWND hWnd, LPARAM lParam ) ; static L_BOOL CALLBACK Mainframe_SysColorChangeNotification ( HWND hWnd, LPARAM lParam ) ; static L_BOOL CALLBACK Mainframe_DisplayChangeNotification ( HWND hWnd, LPARAM lParam ) ; static L_BOOL CALLBACK Mainframe_PaletteChanged ( HWND hWnd, LPARAM lParam ) ; //..................................................................................................................... // Function prototypes for message handlers //..................................................................................................................... static L_VOID Mainframe_OnActivateApp ( HWND hWnd, L_BOOL activate, DWORD threadid ) ; static L_VOID Mainframe_OnCommand ( HWND hWnd, L_INT id, HWND hwndCtl, L_UINT codeNotify ) ; static L_BOOL Mainframe_OnContextMenu ( HWND hWnd, HWND hwndCtl, L_INT xPos, L_INT yPos ) ; static L_BOOL Mainframe_OnCreate ( HWND hWnd, LPCREATESTRUCT lpCreateStruct ) ; static L_VOID Mainframe_OnDestroy ( HWND hWnd ) ; static L_VOID Mainframe_OnDisplayChange ( HWND hWnd, L_UINT cBitsPerPixel, L_UINT cxScreen, L_UINT cyScreen ) ; static L_VOID Mainframe_OnFileClose ( HWND hWnd ) ; static L_VOID Mainframe_OnInitMenuPopup ( HWND hWnd, HMENU hmenu, L_UINT item, L_BOOL sysmenu ) ; static L_VOID Mainframe_OnMenuSelect ( HWND hWnd, HMENU hmenu, L_INT item, HMENU hmenuPopup, L_UINT flags ) ; static L_VOID Mainframe_OnNCRButtonUp ( HWND hWnd, L_INT x, L_INT y, L_UINT codeMouseMove ) ; static L_VOID Mainframe_OnPaint ( HWND hWnd ) ; static L_BOOL Mainframe_OnQueryEndSession ( HWND hWnd ) ; static L_VOID Mainframe_OnRButtonDown ( HWND hWnd, L_BOOL fDoubleClick, L_INT x, L_INT y, L_UINT keyFlags ) ; static HACCEL Mainframe_OnSetAccel ( HWND hWnd, HACCEL g_hAccel ) ; static L_VOID Mainframe_OnSize ( HWND hWnd, L_UINT state, L_INT cx, L_INT cy ) ; static L_VOID Mainframe_OnCloseAll ( HWND hWnd ) ; static L_BOOL Mainframe_OnSetCursor ( HWND hWnd, HWND hwndCursor, L_UINT codeHitTest, L_UINT msg ) ; static L_VOID Mainframe_OnSysColorChange ( HWND hWnd ) ; static L_VOID Mainframe_OnUserChanged ( HWND hWnd ) ; static L_VOID Mainframe_OnWinIniChange ( HWND hWnd, LPCTSTR pszSection ) ; static LRESULT Mainframe_OnMDIDestroy ( HWND hWnd ) ; static L_VOID Mainframe_OnUpdateToolbar ( HWND hWnd ) ; static L_VOID Mainframe_OnViewToolBar ( HWND hWnd ) ; static L_VOID Mainframe_OnViewStatus ( HWND hWnd ) ; static L_VOID Mainframe_OnPropBrush ( HWND hWnd ) ; static L_VOID Mainframe_OnPropShape ( HWND hWnd ) ; static L_VOID Mainframe_OnPropRegion ( HWND hWnd ) ; static L_VOID Mainframe_OnPropFill ( HWND hWnd ) ; static L_VOID Mainframe_OnPropText ( HWND hWnd ) ; static L_VOID Mainframe_OnPaletteChanged ( HWND hWnd, HWND hwndPaletteChange ); static L_BOOL Mainframe_OnQueryNewPalette ( HWND hWnd ) ; static L_VOID Mainframe_OnPaletteChanging ( HWND hwnd, HWND hwndPaletteChange ); static LRESULT MainFrame_SendMessageToActiveMDI ( HWND mdiclient, L_INT message, WPARAM wParam, LPARAM lParam ) ; static L_BOOL Mainframe_GetBrushProperties ( HWND hWnd, pPAINTBRUSH Paintbrush ) ; static L_BOOL Mainframe_GetShapeProperties ( HWND hWnd, pPAINTSHAPE PainShape ) ; static L_BOOL Mainframe_GetRegionProperties ( HWND hWnd, pPAINTREGION PaintRegion ) ; static L_BOOL Mainframe_GetFillProperties ( HWND hWnd, pPAINTFILL PaintFill ) ; static L_BOOL Mainframe_GetTextProperties ( HWND hWnd, pPAINTTEXT PaintText ) ; static HWND Mainframe_CreateStatusLine ( HWND hWnd ) ; static L_VOID Mainframe_SetStatusBarText ( LPTSTR szText ) ; static L_VOID Mainframe_ResizeFrame ( HWND hWnd ) ; //..................................................................................................................... // Typedefs //..................................................................................................................... LRESULT ForwardFrameProc(HWND hWnd, L_UINT message, WPARAM wParam, LPARAM lParam) { return DefFrameProc ( hWnd, g_MDIClientWnd, message, wParam, lParam ) ; } LRESULT CALLBACK MainFrameWndProc (HWND hWnd, L_UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: { L_DlgInit(DLG_INIT_COLOR); return HANDLE_WM_CREATE ( hWnd, wParam, lParam, Mainframe_OnCreate ) ; } case WM_DESTROY: { L_DlgFree(); return HANDLE_WM_DESTROY ( hWnd, wParam, lParam, Mainframe_OnDestroy ) ; } case WM_CLOSE: { Mainframe_OnCloseAll ( hWnd ) ; if ( GetFirstChild ( g_MDIClientWnd ) ) { return TRUE ; } } break ; case WM_PAINT: { return HANDLE_WM_PAINT ( hWnd, wParam, lParam, Mainframe_OnPaint ) ; } case WM_COMMAND: { return HANDLE_WM_COMMAND ( hWnd, wParam, lParam, Mainframe_OnCommand ) ; } case WM_SIZE: { return HANDLE_WM_SIZE ( hWnd, wParam, lParam, Mainframe_OnSize ) ; } case WM_ACTIVATEAPP: { return HANDLE_WM_ACTIVATEAPP ( hWnd, wParam, lParam, Mainframe_OnActivateApp ) ; } case WM_NCRBUTTONUP: { return HANDLE_WM_NCRBUTTONUP ( hWnd, wParam, lParam, Mainframe_OnNCRButtonUp ) ; } case WM_RBUTTONDOWN: { return HANDLE_WM_RBUTTONDOWN ( hWnd, wParam, lParam, Mainframe_OnRButtonDown ) ; } case WM_INITMENUPOPUP: { return HANDLE_WM_INITMENUPOPUP ( hWnd, wParam, lParam, Mainframe_OnInitMenuPopup ) ; } case WM_MENUSELECT: { return HANDLE_WM_MENUSELECT ( hWnd, wParam, lParam, Mainframe_OnMenuSelect ) ; } case WM_CONTEXTMENU: { return HANDLE_WM_CONTEXTMENU ( hWnd, wParam, lParam, Mainframe_OnContextMenu ) ; } case WM_DISPLAYCHANGE: { return HANDLE_WM_DISPLAYCHANGE ( hWnd, wParam, lParam, Mainframe_OnDisplayChange ) ; } case WM_SYSCOLORCHANGE: { return HANDLE_WM_SYSCOLORCHANGE ( hWnd, wParam, lParam, Mainframe_OnSysColorChange ) ; } case WM_PALETTEISCHANGING: { return HANDLE_WM_PALETTEISCHANGING ( hWnd, wParam, lParam, Mainframe_OnPaletteChanging ) ; } case WM_CTLCOLOREDIT: case WM_CTLCOLORMSGBOX: case WM_CTLCOLORLISTBOX: case WM_CTLCOLORBTN: case WM_CTLCOLORDLG: case WM_CTLCOLORSCROLLBAR: case WM_CTLCOLORSTATIC: case WM_QUERYNEWPALETTE: { HANDLE_WM_QUERYNEWPALETTE(hWnd, wParam, lParam, Mainframe_OnQueryNewPalette); } break ; case WM_USERCHANGED: { HANDLE_WM_USERCHANGED ( hWnd, wParam, lParam, Mainframe_OnUserChanged ) ;\ } break ; case WM_PALETTECHANGED: { HANDLE_WM_PALETTECHANGED ( hWnd, wParam, lParam, Mainframe_OnPaletteChanged ) ; } break ; case UWM_MDI_DESTROY: { return Mainframe_OnMDIDestroy ( hWnd ) ; } case UWM_UPDATE_TOOLBAR: { Mainframe_OnUpdateToolbar ( hWnd ) ; return 0 ; } case UWM_SET_ACCELERATOR: { HANDLE_UWM_SET_ACCELERATOR ( hWnd, wParam, lParam, Mainframe_OnSetAccel ) ; return 0 ; } case WM_QUERYENDSESSION: { return HANDLE_WM_QUERYENDSESSION ( hWnd, wParam, lParam, Mainframe_OnQueryEndSession ) ; } } return DefFrameProc (hWnd, g_MDIClientWnd, message, wParam, lParam) ; } L_VOID CleanOpenDlgParam(LPOPENDLGPARAMS pFOParam) { int i=0; if(pFOParam!=NULL && pFOParam->pFileData!= NULL ) { for(i=0; i < pFOParam->nNumOfFiles; ++i ) { if(pFOParam->pFileData[i].pBitmap != NULL) { L_FreeBitmap(pFOParam->pFileData[i].pBitmap); GlobalFreePtr(pFOParam->pFileData[i].pBitmap); } if(pFOParam->pFileData[i].pThumbnail != NULL) { L_FreeBitmap(pFOParam->pFileData[i].pThumbnail); GlobalFreePtr(pFOParam->pFileData[i].pThumbnail); } if(pFOParam->pFileData[i].pFileInfo != NULL) { GlobalFreePtr(pFOParam->pFileData[i].pFileInfo); } } GlobalFreePtr(pFOParam->pFileData); pFOParam->pFileData =NULL; pFOParam->nNumOfFiles = 0; } } static L_VOID Mainframe_OnOpen(HWND hWnd) { static L_INT nOpenIndex = 0 ; L_INT nRet; OPENFILENAME OpenFileName ; L_TCHAR szFileTitle [ L_MAXPATH ] = TEXT("\0") ; L_TCHAR szOpenFileFilter [ ] = {TEXT("ALL\0")TEXT("*.*\0")} ; OPENDLGPARAMS FileOpenParams ; BITMAPHANDLE hBitmap ; _fmemset ( &FileOpenParams, 0, sizeof ( OPENDLGPARAMS ) ) ; _fmemset ( &OpenFileName,0, sizeof(OpenFileName)); FileOpenParams.uStructSize = sizeof(OPENDLGPARAMS); L_InitBitmap ( &hBitmap, sizeof(BITMAPHANDLE), 0, 0, 0 ) ; OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.hwndOwner = hWnd; OpenFileName.lpstrFilter = szOpenFileFilter; OpenFileName.lpstrCustomFilter = NULL; OpenFileName.nMaxCustFilter = 0; OpenFileName.nFilterIndex = nOpenIndex; OpenFileName.nMaxFileTitle = sizeof(szFileTitle)/sizeof(L_TCHAR); OpenFileName.lpstrFileTitle = szFileTitle; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = TEXT("Open a File"); OpenFileName.nFileOffset = 0; OpenFileName.nFileExtension = 0; OpenFileName.lpstrDefExt = NULL; OpenFileName.lpfnHook = NULL; OpenFileName.Flags = OFN_LONGNAMES ; FileOpenParams.uDlgFlags = DLG_OPEN_ENABLESIZING | DLG_OPEN_LOADBITMAP | DLG_OPEN_SHOW_PREVIEW | DLG_OPEN_SHOW_FILEINFO; FileOpenParams.bPreviewEnabled = TRUE ; if ( ( nRet = L_DlgOpen ( hWnd, &OpenFileName, &FileOpenParams ) ) == SUCCESS_DLG_OK ) { // check for unsported file formats. if ( 1 != FileOpenParams.pFileData[0].pBitmap->BitsPerPixel && 4 != FileOpenParams.pFileData[0].pBitmap->BitsPerPixel && 8 != FileOpenParams.pFileData[0].pBitmap->BitsPerPixel && 16 != FileOpenParams.pFileData[0].pBitmap->BitsPerPixel && 24 != FileOpenParams.pFileData[0].pBitmap->BitsPerPixel ) { MessageBox ( hWnd, TEXT("Can't paint to this image."), TEXT("Error:"), MB_OK | MB_ICONSTOP ) ; } else { nOpenIndex = OpenFileName.nFilterIndex; L_CopyBitmapHandle(&hBitmap, FileOpenParams.pFileData[0].pBitmap, sizeof(BITMAPHANDLE)); L_ChangeBitmapViewPerspective ( NULL, &hBitmap, sizeof(BITMAPHANDLE), TOP_LEFT ); memset(FileOpenParams.pFileData[0].pBitmap,0,sizeof(BITMAPHANDLE)); Paint_OnOpen ( hWnd, FileOpenParams.pFileData[0].szFileName, OpenFileName.lpstrFileTitle, FileOpenParams.pFileData[0].pFileInfo->Format, &hBitmap ) ; } CleanOpenDlgParam(&FileOpenParams); } else if(nRet == ERROR_PDF_BAD_INITIALIZATION_FILES) { if( IDYES == MessageBox( hWnd, TEXT("LEADTOOLS PDF plugin is not found, do you want to download the plugin now?"), TEXT("Open file"),MB_ICONEXCLAMATION | MB_YESNO)) ShellExecute(hWnd, TEXT("open"), TEXT("http://www.leadtools.com/ReleaseDownloads/v14/LEADTOOLSPDFRuntime.exe"), NULL, NULL, SW_SHOWNORMAL); } } static L_VOID Mainframe_OnSave ( ) { HWND hwndChild ; hwndChild = FORWARD_WM_MDIGETACTIVE ( g_MDIClientWnd, SendMessage ) ; Paint_OnSave ( hwndChild ) ; } static L_VOID Mainframe_OnSaveAs ( HWND hWnd ) { static L_INT nSaveIndex = 0 ; OPENFILENAME SaveFileName ; SAVEDLGPARAMS FSParm ; SAVEFILEOPTION SaveFileOption ; L_TCHAR buf [ 80 ] ; HCURSOR hCursor ; L_INT nRet ; HWND child ; _fmemset ( &SaveFileName, 0, sizeof ( OPENFILENAME ) ) ; _fmemset ( &FSParm, 0, sizeof ( SAVEDLGPARAMS ) ) ; FSParm.uStructSize = sizeof(SAVEDLGPARAMS); FSParm.nQFactor = 2 ; SaveFileName.lpstrInitialDir = NULL ; SaveFileName.lStructSize = sizeof ( OPENFILENAME ) ; SaveFileName.lpstrInitialDir = NULL ; SaveFileName.lpstrTitle = TEXT("Save As") ; SaveFileName.lpstrFileTitle = FSParm.szFileName ; SaveFileName.nMaxFileTitle = sizeof ( FSParm.szFileName ) /sizeof(L_TCHAR); SaveFileName.nFilterIndex = nSaveIndex ; SaveFileName.nFileOffset = 0 ; SaveFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_LONGNAMES | OFN_NOREADONLYRETURN | OFN_OVERWRITEPROMPT ; nRet = L_DlgSave ( hWnd, &SaveFileName, &FSParm ) ; if ( nRet == SUCCESS_DLG_OK ) { nSaveIndex = SaveFileName.nFilterIndex ; L_GetDefaultSaveFileOption ( &SaveFileOption, sizeof(SAVEFILEOPTION) ) ; SaveFileOption.Flags &= ~ ( ESO_REPLACEPAGE | ESO_INSERTPAGE ) ; switch ( FSParm.uSaveMulti ) { case MULTIPAGE_OPERATION_OVERWRITE: SaveFileOption.PageNumber = 1 ; break; case MULTIPAGE_OPERATION_APPEND: SaveFileOption.PageNumber = 2 ; break; case MULTIPAGE_OPERATION_REPLACE: SaveFileOption.PageNumber = FSParm.nPageNumber ; SaveFileOption.Flags |= ESO_REPLACEPAGE ; break; case MULTIPAGE_OPERATION_INSERT: SaveFileOption.PageNumber = FSParm.nPageNumber ; SaveFileOption.Flags |= ESO_INSERTPAGE ; break; } SaveFileOption.Passes = FSParm.nPasses ; hCursor = SetCursor ( LoadCursor ( NULL, IDC_WAIT ) ) ; child = FORWARD_WM_MDIGETACTIVE ( g_MDIClientWnd, SendMessage ) ; Paint_OnSaveAs ( child, FSParm.szFileName, FSParm.nFormat, FSParm.nBitsPerPixel, FSParm.nQFactor, &SaveFileOption ) ; SetCursor ( hCursor ) ; if ( SUCCESS_DLG_OK != nRet ) { wsprintf ( buf, TEXT("ERROR %d saving the file %s."), nRet, ( LPSTR ) FSParm.szFileName ) ; MessageBox ( hWnd, buf, TEXT("ERROR"), MB_OK ) ; } else { return ; } } } static L_BOOL Mainframe_OnQueryEndSession ( HWND hWnd ) { // First, check this out with all child windows. // Try to close all child windows. FORWARD_WM_COMMAND ( hWnd, ID_CLOSE_ALL, 0, 0, SendMessage ) ; // If all child windows agreed to close, // they are destroyed by now. // If GetFirstChild returns a window handle, it means // not all windows were destroyed. // one still left if ( GetFirstChild ( g_MDIClientWnd ) ) { // At least one child window still exists. // Don't permit the session to end or the // application to close. return FALSE ; // Don't pass to DefFrameProc. } return TRUE ; } static L_VOID Mainframe_OnAbout ( HWND hWnd ) { doAbout ( hWnd ) ; } static L_VOID Mainframe_OnExit ( HWND hWnd ) { Mainframe_OnCloseAll ( hWnd ) ; if ( NULL == GetFirstChild ( g_MDIClientWnd ) ) { DestroyWindow ( hWnd ) ; } } static L_BOOL CALLBACK CloseEnumProc ( HWND hWnd, LPARAM lParam ) { // Ignore the caption windows for iconized child windows if ( GetWindowOwner ( hWnd ) == NULL ) { // Ignore any window which is not a direct descendant of the // frame window if ( GetParent ( hWnd ) != ( HWND ) lParam ) { return TRUE ; // ignore, but continue iteration } FORWARD_WM_MDIRESTORE ( g_MDIClientWnd, hWnd, SendMessage ) ; if( FORWARD_WM_QUERYENDSESSION ( hWnd, SendMessage ) ) { FORWARD_WM_MDIDESTROY ( g_MDIClientWnd, hWnd, SendMessage ) ; return TRUE ; } else { return FALSE ; } } return TRUE; } static L_VOID Mainframe_OnCloseAll ( HWND hWnd ) { UNREFERENCED_PARAMETER ( hWnd ) ; EnumChildWindows ( g_MDIClientWnd, ( WNDENUMPROC ) CloseEnumProc, ( LPARAM ) g_MDIClientWnd ) ; } static L_VOID Mainframe_OnHelpTopics(HWND hWnd) { L_BOOL bGotHelp = WinHelp ( hWnd, GetHelpFileName ( ), HELP_FINDER, ( DWORD ) 0 ) ; TCHAR msg [ 256 ] ; if ( ! bGotHelp ) { // HELP FAILED LoadString ( GetWindowInstance ( hWnd ), IDS_HELP_FAILED,msg, DIM ( msg ) ) ; MessageBox ( GetFocus ( ), msg, GetAppName ( ), MB_OK|MB_ICONHAND ) ; } // HELP FAILED } static L_VOID Mainframe_OnCommand (HWND hWnd, L_INT id, HWND hwndCtl, L_UINT codeNotify) { switch (id) { // id case ID_APP_ABOUT: { Mainframe_OnAbout ( hWnd ) ; return ; } case ID_APP_EXIT: { Mainframe_OnExit ( hWnd ) ; return ; } case ID_HELP_HELP_TOPICS: { Mainframe_OnHelpTopics ( hWnd ) ; return ; } case ID_WINDOW_ARRANGE: { FORWARD_WM_MDIICONARRANGE ( g_MDIClientWnd, SendMessage ) ; return ; } case ID_WINDOW_TILE_HORZ: { FORWARD_WM_MDITILE ( g_MDIClientWnd, MDITILE_HORIZONTAL, SendMessage ) ; return ; } case ID_WINDOW_TILE_VERT: { FORWARD_WM_MDITILE ( g_MDIClientWnd, MDITILE_VERTICAL, SendMessage ) ; return ; } case ID_WINDOW_CASCADE: { FORWARD_WM_MDICASCADE ( g_MDIClientWnd, 0, SendMessage ) ; return ; } case ID_CLOSE_ALL: { Mainframe_OnCloseAll ( hWnd ) ; } break ; // Here are all the other possible menu options, // all of these are currently disabled: case ID_FILE_OPEN: { Mainframe_OnOpen ( hWnd ) ; } break ; case ID_FILE_SAVE: { Mainframe_OnSave ( ) ; } break ; case ID_FILE_SAVE_AS: { Mainframe_OnSaveAs ( hWnd ) ; } break ; case ID_FILE_SAVE_ALL: case ID_FILE_PRINT: case ID_FILE_PAGE_SETUP: break ; case ID_FILE_CLOSE: { Mainframe_OnFileClose ( hWnd ) ; } break ; case ID_EDIT_UNDO: case ID_EDIT_REDO: case ID_EDIT_CUT: case ID_EDIT_COPY: case ID_EDIT_PASTE: case ID_EDIT_CLEAR: case ID_EDIT_PROPERTIES: break ; case ID_VIEW_TOOL_BAR: { Mainframe_OnViewToolBar ( hWnd ) ; } break ; case ID_VIEW_STATUS_BAR: { Mainframe_OnViewStatus ( hWnd ) ; } break; case IDM_PROPS_BRUSH: { Mainframe_OnPropBrush ( hWnd ) ; } break ; case IDM_PROPS_SHAPE: { Mainframe_OnPropShape ( hWnd ) ; } break ; case IDM_PROPS_REGION: { Mainframe_OnPropRegion ( hWnd ) ; } break ; case IDM_PROPS_FILL: { Mainframe_OnPropFill ( hWnd ) ; } break ; case IDM_PROPS_TEXT: { Mainframe_OnPropText ( hWnd ) ; } break ; default: { if( IDM_FIRSTDOCUMENT <= id && id <= IDM_LASTDOCUMENT ) { // activate document HWND ChildWnd; ChildWnd = GetDlgItem ( g_MDIClientWnd, id ) ; if ( IsWindow ( ChildWnd ) ) { FORWARD_WM_MDIACTIVATE ( g_MDIClientWnd, FALSE, NULL, ChildWnd, SendMessage ) ; } return ; } // activate document } } // id // Warning: Failure to pass the command on to the frame procedure means // the child windows will never see WM_COMMAND messages, and key // functionality such as the system menu on a maximized child window will // be missing. FORWARD_WM_COMMAND ( hWnd, id, hwndCtl, codeNotify, ForwardFrameProc ) ; FORWARD_WM_COMMAND ( g_MDIClientWnd, id, hwndCtl, codeNotify, MainFrame_SendMessageToActiveMDI ) ; } static L_VOID Mainframe_OnFileClose ( HWND hWnd ) { UNREFERENCED_PARAMETER ( hWnd ) ; MainFrame_SendMessageToActiveMDI ( g_MDIClientWnd, WM_CLOSE, 0, 0 ) ; } static L_VOID Mainframe_OnActivateApp ( HWND hWnd, L_BOOL activate, DWORD threadid ) { if ( activate ) { // activating MainFrame_SendMessageToActiveMDI ( g_MDIClientWnd, UWM_UPDATE_MENU, 0, 0 ) ; } // activating FORWARD_WM_ACTIVATEAPP ( hWnd, activate, threadid, DefWindowProc ) ; } static L_BOOL Mainframe_OnContextMenu ( HWND hWnd, HWND hwndCtl, L_INT xPos, L_INT yPos ) { POINT pt ; RECT rc ; // client area of window pt.x = xPos ; pt.y = yPos ; // location of mouse click if ( FORWARD_UWM_CONTEXTMENU ( g_MDIClientWnd, hwndCtl, xPos, yPos, MainFrame_SendMessageToActiveMDI ) ) { return TRUE ; } // Get the bounding rectangle of the client area. GetClientRect ( hWnd, &rc ) ; // Convert the mouse position to client coordinates. ScreenToClient ( hWnd, &pt ) ; // If the mouse click was in the client area, // display the appropriate floating popup menu. if ( PtInRect ( &rc, pt ) ) { if ( Mainframe_DisplayContextMenu ( hWnd, pt ) ) { return TRUE ; } } // Otherwise forward the message for default processing return FORWARD_WM_CONTEXTMENU ( hWnd, hwndCtl, xPos, yPos, DefWindowProc ) ; } static L_BOOL Mainframe_OnCreate ( HWND hWnd, LPCREATESTRUCT lpCreateStruct ) { CLIENTCREATESTRUCT ccs ; UNREFERENCED_PARAMETER ( lpCreateStruct ) ; ccs.hWindowMenu = NULL ; ccs.idFirstChild = IDM_FIRSTDOCUMENT ; if ( ! Mainframe_CreateStatusLine ( hWnd ) ) { return FALSE ; } g_MDIClientWnd = CreateWindow ( _T("MDICLIENT"), NULL, WS_CHILD | WS_CLIPCHILDREN | WS_VISIBLE, 0, 0, 0, 0, hWnd, ( HMENU ) 1, GetWindowInstance ( hWnd ), ( LPSTR ) &ccs ) ; if( g_MDIClientWnd == NULL ) { return FALSE ; } ShowWindow ( g_MDIClientWnd, SW_SHOW ) ; return TRUE ; } static L_VOID Mainframe_OnDestroy ( HWND hWnd ) { HWND hwndStatus ; HFONT hfont ; hwndStatus = GetDlgItem ( hWnd, IDC_STATUS ) ; hfont = GetWindowFont ( hwndStatus ) ; if ( hfont ) { DeleteObject ( ( HFONT ) hfont ) ; } // Tell WinHelp we don't need it any more... WinHelp ( hWnd, GetHelpFileName ( ), HELP_QUIT, ( DWORD ) 0 ) ; PostQuitMessage ( 0 ) ; } static L_VOID Mainframe_OnDisplayChange ( HWND hWnd, L_UINT cBitsPerPixel, L_UINT cxScreen, L_UINT cyScreen ) { DISPLAYDATA dd ; dd.cBitsPerPixel = cBitsPerPixel ; dd.cxScreen = cxScreen ; dd.cyScreen = cyScreen ; EnumChildWindows ( hWnd, ( WNDENUMPROC ) Mainframe_DisplayChangeNotification, ( LPARAM ) &dd ) ; } static L_BOOL CALLBACK Mainframe_DisplayChangeNotification ( HWND hWnd, LPARAM lParam ) { DISPLAYDATA *pdd ; pdd = ( DISPLAYDATA * ) lParam ; // Forward the message to a child window FORWARD_WM_DISPLAYCHANGE ( hWnd, pdd->cBitsPerPixel, pdd->cxScreen, pdd->cyScreen, SendMessage ) ; // Keep on enumerating... return TRUE ; } static L_VOID Mainframe_OnNCRButtonUp ( HWND hWnd, L_INT x, L_INT y, L_UINT codeMouseMove ) { switch (codeMouseMove) { case HTSYSMENU: // Windows NT note: // The user just clicked the right mouse button on the // application's title bar icon. Normally you would now alter // the default system menu however your application requires. // See the Explorer for an example. return ; case HTCAPTION: case HTREDUCE: case HTZOOM: // Windows NT note: // The user just clicked the right mouse button on the // application's title bar , excluding the title bar icon. // Normally you would now display the window popup menu. return ; } // Allow default message processing regardless FORWARD_WM_NCRBUTTONUP ( hWnd, x, y, codeMouseMove, ForwardFrameProc ) ; } static L_VOID Mainframe_OnPaint ( HWND hWnd ) { HDC hdc ; PAINTSTRUCT ps ; hdc = BeginPaint ( hWnd, &ps) ; // Your drawing code goes here... EndPaint ( hWnd, &ps ) ; } static L_VOID Mainframe_OnRButtonDown ( HWND hWnd, L_BOOL fDoubleClick, L_INT x, L_INT y, L_UINT keyFlags ) { POINT pt ; UNREFERENCED_PARAMETER ( keyFlags ) ; UNREFERENCED_PARAMETER ( fDoubleClick ) ; pt.x = x ; pt.y = y ; Mainframe_DisplayContextMenu ( hWnd, pt ) ; } static HACCEL Mainframe_OnSetAccel ( HWND hWnd, HACCEL hNewaccel ) { HACCEL hOldaccel ; hOldaccel = g_hAccel ; g_hAccel = hNewaccel ; UNREFERENCED_PARAMETER ( hWnd ) ; return hOldaccel ; } static L_VOID Mainframe_OnSize ( HWND hWnd, L_UINT state, L_INT cx, L_INT cy ) { HWND hwndStatus ; RECT rcRect ; L_INT height ; hwndStatus = GetDlgItem ( hWnd, IDC_STATUS ) ; ASSERT ( NULL != hwndStatus ) ; GetWindowRect ( hwndStatus, &rcRect ) ; height = rcRect.bottom - rcRect.top ; SetWindowPos ( hwndStatus, NULL, 0, cy - height, cx, height, SWP_NOZORDER ) ; if ( state != SIZE_MINIMIZED ) { // ADJUST SIZE Mainframe_ResizeFrame ( hWnd ) ; } // ADJUST SIZE } static L_BOOL Mainframe_OnSetCursor ( HWND hWnd, HWND hwndCursor, L_UINT codeHitTest, L_UINT msg ) { UNREFERENCED_PARAMETER ( hWnd ) ; UNREFERENCED_PARAMETER ( msg ) ; UNREFERENCED_PARAMETER ( codeHitTest ) ; UNREFERENCED_PARAMETER ( hwndCursor ) ; return FALSE ; } static L_VOID Mainframe_OnSysColorChange ( HWND hWnd ) { Mainframe_OnQueryNewPalette(hWnd); } static L_VOID Mainframe_OnPaletteChanging (HWND hWnd, HWND hWndPaletteChange) { Mainframe_OnPaletteChanged (hWnd, hWndPaletteChange); } static L_BOOL CALLBACK Mainframe_SysColorChangeNotification ( HWND hWnd, LPARAM lParam ) { UNREFERENCED_PARAMETER ( lParam ) ; // Forward the message to a child window FORWARD_WM_SYSCOLORCHANGE ( hWnd, SendMessage ) ; // Keep on enumerating... return TRUE ; } static L_VOID Mainframe_OnUserChanged ( HWND hWnd ) { UNREFERENCED_PARAMETER ( hWnd ) ; } static L_BOOL Mainframe_OnQueryNewPalette ( HWND hWnd ) { HWND hWndChild = FORWARD_WM_MDIGETACTIVE (g_MDIClientWnd, SendMessage); UNREFERENCED_PARAMETER(hWnd); if (IsWindow (hWndChild)) FORWARD_WM_QUERYNEWPALETTE (hWndChild, SendMessage); return(TRUE); } static L_VOID Mainframe_OnPaletteChanged ( HWND hWnd, HWND hwndPaletteChange ) { EnumChildWindows ( hWnd, ( WNDENUMPROC ) Mainframe_PaletteChanged, ( LPARAM ) hwndPaletteChange ) ; } static L_BOOL CALLBACK Mainframe_PaletteChanged ( HWND hWnd, LPARAM lParam ) { // Forward the message to a child window FORWARD_WM_PALETTECHANGED ( hWnd, ( HWND ) lParam, SendMessage ) ; // Keep on enumerating... return TRUE ; } L_BOOL Mainframe_DisplayContextMenu ( HWND hWnd, POINT pt ) { HMENU hmenuBar, hmenuPopup ; L_INT nItems ; // Determine the appropriate context menu to display. // generally using the application state and mouse click coordinates. // Bring up the 'Help' popup menu for lack of a better solution // Get main menu handle hmenuBar = GetMenu ( hWnd ) ; ASSERT ( NULL != hmenuBar ) ; // Get the count of items on the main menu nItems = GetMenuItemCount ( hmenuBar ) ; ASSERT ( -1 != nItems ) ; // ASSUMPTION: Help menu is the rightmost on the menu bar hmenuPopup = GetSubMenu ( hmenuBar, nItems - 1 ) ; ASSERT ( NULL != hmenuPopup ) ; // Convert click location to screen coordinates ClientToScreen ( hWnd, &pt ) ; // Display the floating popup menu at the mouse click location // Track the right mouse as this function is called during // WM_CONTEXTMENU message processing. return TrackPopupMenu ( hmenuPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL) ; } static LRESULT Mainframe_OnMDIDestroy ( HWND hWnd ) { HWND child = FORWARD_WM_MDIGETACTIVE ( g_MDIClientWnd, SendMessage ) ; UNREFERENCED_PARAMETER ( hWnd ) ; if ( child == NULL ) { // POST MINIMAL FORWARD_WM_MDISETMENU ( g_MDIClientWnd, TRUE, g_hMainMenu, NULL, SendMessage ) ; SendMessage ( g_hMainFrame, UWM_SET_ACCELERATOR, 0, ( LPARAM ) g_hMainAccel ) ; DrawMenuBar ( g_hMainFrame ) ; // PostMessage ( g_hMainFrame, UWM_UPDATE_TOOLBAR, 0, 0 ) ; } // POST MINIMAL return 0 ; } static L_VOID Mainframe_OnUpdateToolbar ( HWND hWnd ) { UNREFERENCED_PARAMETER ( hWnd ) ; } static L_VOID Mainframe_OnInitMenuPopup ( HWND hWnd, HMENU hmenu, L_UINT item, L_BOOL sysmenu ) { // ... do any frame-specific initialization here HWND child ; L_BOOL fCanUndo, fCanRedo ; UNREFERENCED_PARAMETER ( hWnd ) ; child = FORWARD_WM_MDIGETACTIVE ( g_MDIClientWnd, SendMessage ) ; EnableMenuItem ( hmenu, ID_FILE_SAVE, ( child != NULL ) ? MF_ENABLED : MF_GRAYED ) ; EnableMenuItem ( hmenu, ID_FILE_SAVE_AS, ( child != NULL ) ? MF_ENABLED : MF_GRAYED ) ; EnableMenuItem ( hmenu, ID_FILE_CLOSE, ( child != NULL ) ? MF_ENABLED : MF_GRAYED ) ; EnableMenuItem ( hmenu, ID_FILE_PRINT, ( child != NULL ) ? MF_ENABLED : MF_GRAYED ) ; L_AutCanUndo ( g_pAutomation, &fCanUndo ) ; L_AutCanRedo ( g_pAutomation, &fCanRedo ) ; EnableMenuItem ( hmenu, ID_EDIT_UNDO, fCanUndo ? MF_ENABLED : MF_GRAYED ) ; EnableMenuItem ( hmenu, ID_EDIT_REDO, fCanRedo ? MF_ENABLED : MF_GRAYED ) ; CheckMenuItem ( hmenu, ID_VIEW_TOOL_BAR, ( g_fViewToolbar ? MF_CHECKED:MF_UNCHECKED ) | MF_BYCOMMAND ) ; CheckMenuItem ( hmenu, ID_VIEW_STATUS_BAR, ( g_fViewStatueLine ? MF_CHECKED:MF_UNCHECKED ) | MF_BYCOMMAND ) ; // Now forward it to the child window, which will do its own // handling of the popup menu initialization. FORWARD_WM_INITMENUPOPUP ( g_MDIClientWnd, hmenu, item, sysmenu, MainFrame_SendMessageToActiveMDI ) ; } static L_VOID Mainframe_OnViewToolBar ( HWND hWnd ) { UNREFERENCED_PARAMETER ( hWnd ) ; g_fViewToolbar = ! g_fViewToolbar ; L_TBSetVisible ( g_pToolbar, g_fViewToolbar ) ; } static L_VOID Mainframe_OnViewStatus ( HWND hWnd ) { RECT rcRect ; HWND hwndStatus ; hwndStatus = GetDlgItem ( hWnd, IDC_STATUS ) ; g_fViewStatueLine = ! g_fViewStatueLine ; ShowWindow ( hwndStatus, g_fViewStatueLine ? SW_SHOW : SW_HIDE ) ; GetWindowRect ( hWnd, &rcRect ) ; Mainframe_ResizeFrame ( hWnd ) ; } static L_VOID Mainframe_OnPropBrush ( HWND hWnd ) { if ( Mainframe_GetBrushProperties ( hWnd, &g_Paintbrush ) ) { if ( g_Paintbrush.pTexture ) { g_Paintbrush.pTexture = &g_hPaperTextureBitmap ; } L_AutSetPaintProperty ( g_pAutomation, PAINT_GROUP_BRUSH, &g_Paintbrush ) ; } } static L_VOID Mainframe_OnPropShape ( HWND hWnd ) { if ( Mainframe_GetShapeProperties ( hWnd, &g_PaintShape ) ) { if ( g_PaintShape.pTexture ) { g_PaintShape.pTexture = &g_hPaperTextureBitmap ; } L_AutSetPaintProperty ( g_pAutomation, PAINT_GROUP_SHAPE, &g_PaintShape ) ; } } static L_VOID Mainframe_OnPropRegion ( HWND hWnd ) { if ( Mainframe_GetRegionProperties ( hWnd, &g_PaintRegion ) ) { L_AutSetPaintProperty ( g_pAutomation, PAINT_GROUP_REGION, &g_PaintRegion ) ; } } static L_VOID Mainframe_OnPropFill ( HWND hWnd ) { if ( Mainframe_GetFillProperties ( hWnd, &g_PaintFill ) ) { if ( g_PaintFill.pTexture ) { g_PaintFill.pTexture = &g_hPaperTextureBitmap ; } L_AutSetPaintProperty ( g_pAutomation, PAINT_GROUP_FILL, &g_PaintFill ) ; } } static L_VOID Mainframe_OnPropText ( HWND hWnd ) { if ( Mainframe_GetTextProperties ( hWnd, &g_PaintText ) ) { if ( g_PaintText.pTexture ) { g_PaintText.pTexture = &g_hPaperTextureBitmap ; } L_AutSetPaintProperty ( g_pAutomation, PAINT_GROUP_TEXT, &g_PaintText ) ; } } L_INT EXT_CALLBACK ProcessToolbarEvents ( pTOOLBARHANDLE pToolbar, TOOLBARBUTTONID nButtonID, L_UINT32 dwData, L_VOID L_FAR *pUserData ) { L_TCHAR buffer [ MAX_STRING_BUFFER ] ; L_INT nID=ID_TOOL_BRUSH; UNREFERENCED_PARAMETER ( pToolbar ) ; UNREFERENCED_PARAMETER ( dwData ) ; UNREFERENCED_PARAMETER ( pUserData ) ; if ( nButtonID > 0 ) { g_PrevButton = nButtonID ; } switch ( nButtonID ) { case ID_TOOL_PAINT_BRUSH: { nID = ID_TOOL_BRUSH ; } break ; case ID_TOOL_PAINT_SHAPE_LINE: { nID = ID_TOOL_SHAPE_LINE ; } break ; case ID_TOOL_PAINT_SHAPE_RECT: { nID = ID_TOOL_SHAPE_RECT ; } break ; case ID_TOOL_PAINT_SHAPE_ROUNDRECT: { nID = ID_TOOL_SHAPE_ROUNDRECT ; } break ; case ID_TOOL_PAINT_SHAPE_ELLIPSE: { nID = ID_TOOL_SHAPE_ELLIPSE ; } break ; case ID_TOOL_PAINT_SHAPE_POLYGON: { nID = ID_TOOL_SHAPE_POLYGON ; } break ; case ID_TOOL_PAINT_SHAPE_BEZIER: { nID = ID_TOOL_SHAPE_BEZIER ; } break ; case ID_TOOL_PAINT_REGION_RECT: { nID = ID_TOOL_REGION_RECT ; } break ; case ID_TOOL_PAINT_REGION_ROUNDRECT: { nID = ID_TOOL_REGION_ROUNDRECT ; } break ; case ID_TOOL_PAINT_REGION_ELLIPSE: { nID = ID_TOOL_REGION_ELLIPSE ; } break ; case ID_TOOL_PAINT_REGION_POLYGON: { nID = ID_TOOL_REGION_POLYGON ; } break ; case ID_TOOL_PAINT_REGION_SURFACE: { nID = ID_TOOL_REGION_SURFACE ; } break ; case ID_TOOL_PAINT_REGION_BORDER: { nID = ID_TOOL_REGION_BORDER ; } break ; case ID_TOOL_PAINT_REGION_COLOR: { nID = ID_TOOL_REGION_COLOR ; } break ; case ID_TOOL_PAINT_FILL_SURFACE: { nID = ID_TOOL_FILL_SURFACE ; } break ; case ID_TOOL_PAINT_FILL_BORDER: { nID = ID_TOOL_FILL_BORDER ; } break ; case ID_TOOL_PAINT_FILL_COLORREPLACE: { nID = ID_TOOL_FILL_COLORREPLACE ; } break ; case ID_TOOL_PAINT_TEXT: { nID = ID_TOOL_TEXT ; } break ; case ID_TOOL_PAINT_ZOOM: { nID = ID_TOOL_ZOOM ; } break ; case ID_TOOL_PAINT_BORDERCOLORPICKER: { nID = ID_TOOL_BORDERCOLORPICKER ; } break ; case ID_TOOL_PAINT_MOVER: { nID = ID_TOOL_MOVER ; } break ; default: { g_fViewToolbar = FALSE ; L_TBSetButtonChecked ( g_pToolbar, g_PrevButton ) ; } } LoadString ( GetWindowInstance ( g_hMainFrame ), nID, buffer, MAX_STRING_BUFFER ) ; Mainframe_SetStatusBarText ( buffer ) ; return SUCCESS ; } static LRESULT MainFrame_SendMessageToActiveMDI ( HWND mdiclient, L_INT message, WPARAM wParam, LPARAM lParam ) { HWND child ; child = FORWARD_WM_MDIGETACTIVE ( mdiclient, SendMessage ) ; if ( child == NULL ) { return 0 ; } return SendMessage ( child, message, wParam, lParam ) ; } static L_VOID Mainframe_OnMenuSelect ( HWND hWnd, HMENU hmenu, L_INT item, HMENU hmenuPopup, L_UINT flags ) { TCHAR prompt [ 256 ] ; HWND hwndStatus ; UNREFERENCED_PARAMETER ( hmenu ) ; UNREFERENCED_PARAMETER ( hmenuPopup ) ; hwndStatus = GetDlgItem ( hWnd, IDC_STATUS ) ; if ( ( L_UINT ) -1 == flags ) { // MENU DISMISSED SetWindowText ( hwndStatus, _T ( "" ) ) ; return ; } // MENU DISMISSED if ( flags & MF_POPUP ) { return; // top-level menu item } LoadString ( GetWindowInstance ( hWnd ), item, prompt, DIM ( prompt ) ) ; SetWindowText ( hwndStatus, prompt ) ; } L_BOOL Mainframe_GetBrushProperties ( HWND hWnd, pPAINTBRUSH pPaintbrush ) { PAINTDLGBRUSHINFO BrushDlgInfo ; L_INT nRet ; L_TCHAR* TouchBitmap [ ] = { TEXT("Leaf") } ; L_TCHAR* TextureBitmap [ ] = { TEXT("Texture-00") } ; BrushDlgInfo.dwFlags = PAINT_DLG_BRUSH_SHOWTOUCHCONTENT | PAINT_DLG_BRUSH_SHOWTOUCHCOLOR | PAINT_DLG_BRUSH_SHOWTOUCHIMAGE | PAINT_DLG_BRUSH_SHOWDIAMETER | PAINT_DLG_BRUSH_SHOWHARDNESS | PAINT_DLG_BRUSH_SHOWSPACING | PAINT_DLG_BRUSH_SHOWOPACITY | PAINT_DLG_BRUSH_SHOWDENSITY | PAINT_DLG_BRUSH_SHOWFADEOUTRATE | PAINT_DLG_BRUSH_SHOWTEXTURE | PAINT_DLG_BRUSH_SHOWDEFAULT ; BrushDlgInfo.pszTitle = TEXT("Paintbrush Properties") ; BrushDlgInfo.nContentsType = pPaintbrush->Touch.nContentsType ; BrushDlgInfo.crColor = pPaintbrush->Touch.crColor ; BrushDlgInfo.ppszTouchImage = TouchBitmap ; BrushDlgInfo.uTouchImageCount = 1 ; BrushDlgInfo.nActiveTouchImageItem = 0 ; BrushDlgInfo.crTransparentColor = RGB ( 0, 0, 0 ) ; BrushDlgInfo.nDiameter = pPaintbrush->nDiameter ; BrushDlgInfo.nHardnessValue = pPaintbrush->Hardness.nValue ; BrushDlgInfo.nSpacing = pPaintbrush->nSpacing ; BrushDlgInfo.nDensity = pPaintbrush->nDensity ; BrushDlgInfo.nOpacity = pPaintbrush->nOpacity ; BrushDlgInfo.nFadeOutRate = pPaintbrush->nFadeOutRate ; BrushDlgInfo.ppszPaperTexture = TextureBitmap ; BrushDlgInfo.uPaperTextureCount = 1 ; BrushDlgInfo.nActivePaperTextureItem = ( ( pPaintbrush->pTexture != NULL ) ? 0 : -1 ) ; nRet = L_PntDlgBrush ( hWnd, &BrushDlgInfo ) ; if ( SUCCESS == nRet ) { pPaintbrush->nSize = sizeof ( PAINTBRUSH ) ; pPaintbrush->dwMask = PBF_ALL ; pPaintbrush->Touch.nContentsType = BrushDlgInfo.nContentsType ; pPaintbrush->Touch.crColor = BrushDlgInfo.crColor ; pPaintbrush->Touch.nShape = PAINT_TOUCH_SHAPE_CIRCLE ; pPaintbrush->Touch.pBitmap = ( ( BrushDlgInfo.nActiveTouchImageItem != -1 ) ? &g_hBrushBitmap : NULL ) ; pPaintbrush->Touch.crTransparentColor = RGB ( 0, 0, 0 ) ; pPaintbrush->nDiameter = BrushDlgInfo.nDiameter ; pPaintbrush->Hardness.nDistributionType = PAINT_HARDNESS_DISTRB_TYPE_0 ; pPaintbrush->Hardness.nValue = BrushDlgInfo.nHardnessValue ; pPaintbrush->nSpacing = BrushDlgInfo.nSpacing ; pPaintbrush->nDensity = BrushDlgInfo.nDensity ; pPaintbrush->nOpacity = BrushDlgInfo.nOpacity ; pPaintbrush->nFadeOutRate = BrushDlgInfo.nFadeOutRate ; pPaintbrush->pTexture = ( ( BrushDlgInfo.nActivePaperTextureItem != -1 ) ? &g_hPaperTextureBitmap : NULL ) ; return TRUE ; } else { return FALSE ; } } L_BOOL Mainframe_GetShapeProperties ( HWND hWnd, pPAINTSHAPE pPaintShape ) { PAINTDLGSHAPEINFO ShapeDlgInfo ; L_INT nRet ; L_TCHAR* BKTileBitmap [ ] = { TEXT("Blocks") } ; L_TCHAR* BorderTileBitmap [ ] = { TEXT("Border-00") } ; L_TCHAR* TextureBitmap [ ] = { TEXT("Texture-00") } ; ShapeDlgInfo.dwFlags = PAINT_DLG_SHAPE_SHOWALL ; ShapeDlgInfo.pszTitle = TEXT("Shape Properties") ; ShapeDlgInfo.nBackgroundStyle = pPaintShape->nBackgroundStyle ; ShapeDlgInfo.crBackgroundColor = pPaintShape->crBackgroundColor ; ShapeDlgInfo.ppszBackgroundTileBitmap = BKTileBitmap ; ShapeDlgInfo.uBackgroundTileBitmapCount = 1 ; ShapeDlgInfo.nActiveBackgroundTileBitmapItem = 0 ; ShapeDlgInfo.nBorderStyle = pPaintShape->nBorderStyle ; ShapeDlgInfo.nBorderBrushStyle = pPaintShape->nBorderBrushStyle ; ShapeDlgInfo.crBorderColor = pPaintShape->crBorderColor ; ShapeDlgInfo.ppszBorderTileBitmap = BorderTileBitmap ; ShapeDlgInfo.uBorderTileBitmapCount = 1 ; ShapeDlgInfo.nActiveBorderTileBitmapItem = 0 ; ShapeDlgInfo.nBorderWidth = pPaintShape->nBorderWidth ; ShapeDlgInfo.nBorderEndCap = pPaintShape->nBorderEndCap ; ShapeDlgInfo.nGradientStyle = pPaintShape->nGradientStyle ; ShapeDlgInfo.crGradientStartColor = pPaintShape->crGradientStartColor ; ShapeDlgInfo.crGradientEndColor = pPaintShape->crGradientEndColor ; ShapeDlgInfo.uGradientSteps = pPaintShape->uGradientSteps ; ShapeDlgInfo.nRoundRectEllipseWidth = pPaintShape->nRoundRectEllipseWidth ; ShapeDlgInfo.nRoundRectEllipseHeight = pPaintShape->nRoundRectEllipseHeight ; ShapeDlgInfo.nOpacity = pPaintShape->nOpacity ; ShapeDlgInfo.ppszPaperTexture = TextureBitmap ; ShapeDlgInfo.uPaperTextureCount = 1 ; ShapeDlgInfo.nActivePaperTextureItem = ( ( pPaintShape->pTexture != NULL ) ? 0 : -1 ) ; nRet = L_PntDlgShape ( hWnd, &ShapeDlgInfo ) ; if ( SUCCESS == nRet ) { pPaintShape->nSize = sizeof ( PAINTSHAPE ) ; pPaintShape->dwMask = PSF_ALL ; pPaintShape->nBackgroundStyle = ShapeDlgInfo.nBackgroundStyle ; pPaintShape->crBackgroundColor = ShapeDlgInfo.crBackgroundColor ; pPaintShape->pBackgroundTileBitmap = ( ( ShapeDlgInfo.nActiveBackgroundTileBitmapItem != -1 ) ? &g_hBackTileBitmap : NULL ) ; pPaintShape->nBorderStyle = ShapeDlgInfo.nBorderStyle ; pPaintShape->nBorderBrushStyle = ShapeDlgInfo.nBorderBrushStyle ; pPaintShape->crBorderColor = ShapeDlgInfo.crBorderColor ; pPaintShape->hBorderTileBitmap = ( ( ShapeDlgInfo.nActiveBorderTileBitmapItem != -1 ) ? g_hBorderTileBitmap : NULL ) ; pPaintShape->nBorderWidth = ShapeDlgInfo.nBorderWidth ; pPaintShape->nBorderEndCap = ShapeDlgInfo.nBorderEndCap ; pPaintShape->nGradientStyle = ShapeDlgInfo.nGradientStyle ; pPaintShape->crGradientStartColor = ShapeDlgInfo.crGradientStartColor ; pPaintShape->crGradientEndColor = ShapeDlgInfo.crGradientEndColor ; pPaintShape->uGradientSteps = ShapeDlgInfo.uGradientSteps ; pPaintShape->nRoundRectEllipseWidth = ShapeDlgInfo.nRoundRectEllipseWidth ; pPaintShape->nRoundRectEllipseHeight = ShapeDlgInfo.nRoundRectEllipseHeight ; pPaintShape->nOpacity = ShapeDlgInfo.nOpacity ; pPaintShape->pTexture = ( ( ShapeDlgInfo.nActivePaperTextureItem != -1 ) ? &g_hPaperTextureBitmap : NULL ) ; return TRUE ; } else { return FALSE ; } } L_BOOL Mainframe_GetRegionProperties ( HWND hWnd, pPAINTREGION pPaintRegion ) { PAINTDLGREGIONINFO RegionDlgInfo ; L_INT nRet ; RegionDlgInfo.dwFlags = PAINT_DLG_REGION_SHOWALL ; RegionDlgInfo.pszTitle = TEXT("Region Properties") ; RegionDlgInfo.crLowerTolerance = pPaintRegion->crLowerTolerance ; RegionDlgInfo.crUpperTolerance = pPaintRegion->crUpperTolerance ; RegionDlgInfo.nRoundRectEllipseWidth = pPaintRegion->nRoundRectEllipseWidth ; RegionDlgInfo.nRoundRectEllipseHeight = pPaintRegion->nRoundRectEllipseHeight ; nRet = L_PntDlgRegion ( hWnd, &RegionDlgInfo ) ; if ( SUCCESS == nRet ) { pPaintRegion->nSize = sizeof ( PAINTREGION ) ; pPaintRegion->dwMask = PRF_ALL ; pPaintRegion->crLowerTolerance = RegionDlgInfo.crLowerTolerance ; pPaintRegion->crUpperTolerance = RegionDlgInfo.crUpperTolerance ; pPaintRegion->nRoundRectEllipseWidth = RegionDlgInfo.nRoundRectEllipseWidth ; pPaintRegion->nRoundRectEllipseHeight = RegionDlgInfo.nRoundRectEllipseHeight ; return TRUE ; } else { return FALSE ; } } L_BOOL Mainframe_GetFillProperties ( HWND hWnd, pPAINTFILL pPaintFill ) { PAINTDLGFILLINFO FillDlgInfo ; L_INT nRet ; L_TCHAR* BKTileBitmap [ ] = { TEXT("Blocks") } ; L_TCHAR* TextureBitmap [ ] = { TEXT("Texture-00") } ; FillDlgInfo.dwFlags = PAINT_DLG_FILL_SHOWALL ; FillDlgInfo.pszTitle = TEXT("Fill Properties") ; FillDlgInfo.nStyle = pPaintFill->nStyle ; FillDlgInfo.crSolidFillColor = pPaintFill->crSolidFillColor ; FillDlgInfo.ppszBackgroundTileBitmap = BKTileBitmap ; FillDlgInfo.uBackgroundTileBitmapCount = 1 ; FillDlgInfo.nActiveBackgroundTileBitmapItem = 0 ; FillDlgInfo.nGradientStyle = pPaintFill->nGradientStyle ; FillDlgInfo.crGradientStartColor = pPaintFill->crGradientStartColor ; FillDlgInfo.crGradientEndColor = pPaintFill->crGradientEndColor ; FillDlgInfo.uGradientSteps = pPaintFill->uGradientSteps ; FillDlgInfo.crUpperTolerance = pPaintFill->crUpperTolerance ; FillDlgInfo.crLowerTolerance = pPaintFill->crLowerTolerance ; FillDlgInfo.nOpacity = pPaintFill->nOpacity ; FillDlgInfo.ppszPaperTexture = TextureBitmap ; FillDlgInfo.uPaperTextureCount = 1 ; FillDlgInfo.nActivePaperTextureItem = ( ( pPaintFill->pTexture != NULL ) ? 0 : -1 ) ; nRet = L_PntDlgFill ( hWnd, &FillDlgInfo ) ; if ( SUCCESS == nRet ) { pPaintFill->nSize = sizeof ( PAINTFILL ) ; pPaintFill->dwMask = PFF_ALL ; pPaintFill->nStyle = FillDlgInfo.nStyle ; pPaintFill->crSolidFillColor = FillDlgInfo.crSolidFillColor ; pPaintFill->pBackgroundTileBitmap = ( ( FillDlgInfo.nActiveBackgroundTileBitmapItem != -1 ) ? &g_hBackTileBitmap : NULL ) ; pPaintFill->nGradientStyle = FillDlgInfo.nGradientStyle ; pPaintFill->crGradientStartColor = FillDlgInfo.crGradientStartColor ; pPaintFill->crGradientEndColor = FillDlgInfo.crGradientEndColor ; pPaintFill->uGradientSteps = FillDlgInfo.uGradientSteps ; pPaintFill->crUpperTolerance = FillDlgInfo.crUpperTolerance ; pPaintFill->crLowerTolerance = FillDlgInfo.crLowerTolerance ; pPaintFill->nOpacity = FillDlgInfo.nOpacity ; pPaintFill->pTexture = ( ( FillDlgInfo.nActivePaperTextureItem != -1 ) ? &g_hPaperTextureBitmap : NULL ) ; return TRUE ; } else { return FALSE ; } } L_BOOL Mainframe_GetTextProperties ( HWND hWnd, pPAINTTEXT pPaintText ) { PAINTDLGTEXTINFO TextDlgInfo ; L_INT nRet ; LOGFONT lf ; L_TCHAR* BKTileBitmap [ ] = { TEXT("Blocks") } ; L_TCHAR* TextureBitmap [ ] = { TEXT("Texture-00") } ; if ( NULL != pPaintText->hFont ) { GetObject ( pPaintText->hFont, sizeof ( LOGFONT ), &lf ) ; TextDlgInfo.dwFlags = PAINT_DLG_TEXT_SHOWALL ; TextDlgInfo.pszTitle = TEXT("Text Properties") ; TextDlgInfo.pszText = pPaintText->pszText ; TextDlgInfo.logFont = lf ; TextDlgInfo.nBorderBrushStyle = pPaintText->nBorderBrushStyle ; TextDlgInfo.nBorderWidth = pPaintText->nBorderWidth ; TextDlgInfo.crBorderColor = pPaintText->crBorderColor ; TextDlgInfo.nBackgroundStyle = pPaintText->nBackgroundStyle ; TextDlgInfo.crBackgroundColor = pPaintText->crBackgroundColor ; TextDlgInfo.ppszBackgroundTileBitmap = BKTileBitmap ; TextDlgInfo.uBackgroundTileBitmapCount = 1 ; TextDlgInfo.nActiveBackgroundTileBitmapItem = 0 ; TextDlgInfo.nAlignment = pPaintText->nAlignment ; TextDlgInfo.nOpacity = pPaintText->nOpacity ; TextDlgInfo.ppszPaperTexture = TextureBitmap ; TextDlgInfo.uPaperTextureCount = 1 ; TextDlgInfo.nActivePaperTextureItem = ( ( pPaintText->pTexture != NULL ) ? 0 : -1 ) ; TextDlgInfo.TransformInfo = pPaintText->TransformInfo ; nRet = L_PntDlgText ( hWnd, &TextDlgInfo ) ; if ( SUCCESS == nRet ) { pPaintText->nSize = sizeof ( PAINTTEXT ) ; pPaintText->dwMask = PTF_ALL ; pPaintText->pszText = TextDlgInfo.pszText ; if ( NULL != pPaintText->hFont ) { DeleteFont ( pPaintText->hFont ) ; } pPaintText->hFont = CreateFontIndirect ( &TextDlgInfo.logFont ) ; pPaintText->nBorderBrushStyle = TextDlgInfo.nBorderBrushStyle ; pPaintText->nBorderWidth = TextDlgInfo.nBorderWidth ; pPaintText->crBorderColor = TextDlgInfo.crBorderColor ; pPaintText->nBackgroundStyle = TextDlgInfo.nBackgroundStyle ; pPaintText->crBackgroundColor = TextDlgInfo.crBackgroundColor ; pPaintText->pBackgroundTileBitmap = ( ( TextDlgInfo.nActiveBackgroundTileBitmapItem != -1 ) ? &g_hBackTileBitmap : NULL ) ; pPaintText->nAlignment = TextDlgInfo.nAlignment ; pPaintText->nOpacity = TextDlgInfo.nOpacity ; pPaintText->pTexture = ( ( TextDlgInfo.nActivePaperTextureItem != -1 ) ? &g_hPaperTextureBitmap : NULL ) ; pPaintText->TransformInfo = TextDlgInfo.TransformInfo ; return TRUE ; } else { return FALSE ; } } else { return FALSE ; } } L_VOID Mainframe_SetStatusBarText ( LPTSTR szText ) { HWND hwndStatus = GetDlgItem ( g_hMainFrame, IDC_STATUS ) ; SetWindowText ( hwndStatus, szText ) ; UNREFERENCED_PARAMETER(szText); } static L_VOID Mainframe_ResizeFrame ( HWND hWnd ) { RECT client; // Get client rectangle GetClientRect( hWnd, &client ) ; // Compute the size of the hwndStatus line (which is drawn on the main frame itself). if ( g_fViewStatueLine ) { RECT sr ; GetWindowRect ( GetDlgItem ( hWnd, IDC_STATUS ), &sr ) ; client.bottom -= ( sr.bottom - sr.top ) ; } if ( g_MDIClientWnd != NULL ) { MoveWindow ( g_MDIClientWnd, client.left, client.top, client.right - client.left, client.bottom - client.top, TRUE ) ; } } HWND Mainframe_CreateStatusLine ( HWND hWnd ) { RECT r ; HWND hwndStatus ; TEXTMETRIC tm ; HDC dc ; L_INT height ; LOGFONT lf ; HFONT hfont ; lf.lfHeight = 14 ; lf.lfWidth = 0 ; lf.lfEscapement = 0 ; lf.lfOrientation = 0; lf.lfWeight = FW_NORMAL ; lf.lfItalic = FALSE ; lf.lfUnderline = FALSE ; lf.lfStrikeOut = FALSE ; lf.lfCharSet = ANSI_CHARSET ; lf.lfOutPrecision = OUT_DEFAULT_PRECIS ; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS ; lf.lfQuality = DEFAULT_QUALITY ; lf.lfPitchAndFamily = FF_DONTCARE ; lstrcpy(lf.lfFaceName, TEXT("MS Sans Serif")) ; hfont = CreateFontIndirect ( &lf ) ; dc = GetDC ( hWnd ) ; SaveDC ( dc ) ; SelectObject ( dc, ( HFONT ) hfont ) ; GetTextMetrics ( dc, &tm ) ; height = tm.tmHeight + tm.tmExternalLeading ; GetClientRect ( hWnd, &r ) ; hwndStatus = CreateWindowEx ( 0, _T("STATIC"), NULL, SS_LEFT | WS_VISIBLE | WS_CHILD, r.left, r.bottom - height, r.right - r.left, height, hWnd, ( HMENU ) IDC_STATUS, GetWindowInstance ( hWnd ), ( L_VOID L_FAR * ) NULL ) ; SetWindowFont ( hwndStatus, hfont, TRUE ) ; RestoreDC ( dc, -1 ) ; ReleaseDC ( hWnd, dc ) ; return hwndStatus; }