// MainFrm.cpp : implementation of the CMainFrame class // #include "stdafx.h" #include "net.h" #include "MainFrm.h" #include "netDoc.h" #include "netView.h" #include "ConDlg.h" #include "defines.h" #include "MyList.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CNetApp theApp; #define PORT_NUMBER 1000 ///////////////////////////////////////////////////////////////////////////// // CMainFrame IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd) BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) //{{AFX_MSG_MAP(CMainFrame) ON_WM_CREATE() ON_COMMAND(ID_SERVER_STARTUP, OnServerStartup) ON_UPDATE_COMMAND_UI(ID_SERVER_STARTUP, OnUpdateServerStartup) ON_COMMAND(ID_SERVER_SHUTDOWN, OnServerShutdown) ON_UPDATE_COMMAND_UI(ID_SERVER_SHUTDOWN, OnUpdateServerShutdown) ON_COMMAND(ID_HELP_INSTRUCTIONS, OnHelpInstructions) ON_COMMAND(ID_SERVER_CONNECTTOREMOTESERVER, OnServerConnecttoremoteserver) ON_UPDATE_COMMAND_UI(ID_SERVER_CONNECTTOREMOTESERVER, OnUpdateServerConnecttoremoteserver) ON_COMMAND(ID_SERVER_DISCONNECTFROMREMOVESERVER, OnServerDisconnectfromremoveserver) ON_UPDATE_COMMAND_UI(ID_SERVER_DISCONNECTFROMREMOVESERVER, OnUpdateServerDisconnectfromremoveserver) ON_COMMAND(ID_SERVER_CLOSEALLCONNECTIONS, OnServerCloseallconnections) ON_UPDATE_COMMAND_UI(ID_SERVER_CLOSEALLCONNECTIONS, OnUpdateServerCloseallconnections) ON_COMMAND(ID_REMOTE_LOADBITMAP, OnRemoteLoadbitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_LOADBITMAP, OnUpdateRemoteLoadbitmap) ON_COMMAND(ID_REMOTE_CREATEWINDOW, OnRemoteCreatewindow) ON_UPDATE_COMMAND_UI(ID_REMOTE_CREATEWINDOW, OnUpdateRemoteCreatewindow) ON_COMMAND(ID_REMOTE_ATTACHBITMAPTOWINDOW, OnRemoteAttachbitmaptowindow) ON_UPDATE_COMMAND_UI(ID_REMOTE_ATTACHBITMAPTOWINDOW, OnUpdateRemoteAttachbitmaptowindow) ON_COMMAND(ID_REMOTE_FLIPBITMAP, OnRemoteFlipbitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_FLIPBITMAP, OnUpdateRemoteFlipbitmap) ON_COMMAND(ID_REMOTE_GETBITMAP, OnRemoteGetbitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_GETBITMAP, OnUpdateRemoteGetbitmap) ON_COMMAND(ID_REMOTE_SAVEBITMAP, OnRemoteSavebitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_SAVEBITMAP, OnUpdateRemoteSavebitmap) ON_COMMAND(ID_REMOTE_SENDSHOWWINCMD, OnRemoteSendshowwincmd) ON_COMMAND(ID_REMOTE_SENDCLOSEWINCMD, OnRemoteSendclosewincmd) ON_COMMAND(ID_REMOTE_SENDFREEBITMAPCMD, OnRemoteSendfreebitmapcmd) ON_COMMAND(ID_REMOTE_SENDSETRECTCMD, OnRemoteSendsetrectcmd) ON_UPDATE_COMMAND_UI(ID_REMOTE_SENDCLOSEWINCMD, OnUpdateRemoteSendclosewincmd) ON_UPDATE_COMMAND_UI(ID_REMOTE_SENDFREEBITMAPCMD, OnUpdateRemoteSendfreebitmapcmd) ON_UPDATE_COMMAND_UI(ID_REMOTE_SENDSETRECTCMD, OnUpdateRemoteSendsetrectcmd) ON_UPDATE_COMMAND_UI(ID_REMOTE_SENDSHOWWINCMD, OnUpdateRemoteSendshowwincmd) ON_COMMAND(ID_REMOTE_REVERSEBITMAP, OnRemoteReversebitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_REVERSEBITMAP, OnUpdateRemoteReversebitmap) ON_COMMAND(ID_REMOTE_90CLOCKWISE, OnRemote90clockwise) ON_UPDATE_COMMAND_UI(ID_REMOTE_90CLOCKWISE, OnUpdateRemote90clockwise) ON_COMMAND(ID_REMOTE_180CLOCKWISE, OnRemote180clockwise) ON_UPDATE_COMMAND_UI(ID_REMOTE_180CLOCKWISE, OnUpdateRemote180clockwise) ON_COMMAND(ID_REMOTE_SHEARBITMAP, OnRemoteShearbitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_SHEARBITMAP, OnUpdateRemoteShearbitmap) ON_COMMAND(ID_REMOTE_RESIZEBITMAP, OnRemoteResizebitmap) ON_UPDATE_COMMAND_UI(ID_REMOTE_RESIZEBITMAP, OnUpdateRemoteResizebitmap) ON_COMMAND(ID_REMOTE_POSTERIZE, OnRemotePosterize) ON_UPDATE_COMMAND_UI(ID_REMOTE_POSTERIZE, OnUpdateRemotePosterize) ON_COMMAND(ID_REMOTE_ADDNOISE, OnRemoteAddnoise) ON_UPDATE_COMMAND_UI(ID_REMOTE_ADDNOISE, OnUpdateRemoteAddnoise) ON_COMMAND(ID_REMOTE_OILIFY, OnRemoteOilify) ON_UPDATE_COMMAND_UI(ID_REMOTE_OILIFY, OnUpdateRemoteOilify) ON_COMMAND(ID_REMOTE_RESOLUTION, OnRemoteResolution) ON_UPDATE_COMMAND_UI(ID_REMOTE_RESOLUTION, OnUpdateRemoteResolution) ON_COMMAND(ID_REMOTE_INVERT, OnRemoteInvert) ON_UPDATE_COMMAND_UI(ID_REMOTE_INVERT, OnUpdateRemoteInvert) ON_COMMAND(ID_REMOTE_CONTRAST, OnRemoteContrast) ON_UPDATE_COMMAND_UI(ID_REMOTE_CONTRAST, OnUpdateRemoteContrast) ON_COMMAND(ID_REMOTE_SATURATION, OnRemoteSaturation) ON_UPDATE_COMMAND_UI(ID_REMOTE_SATURATION, OnUpdateRemoteSaturation) ON_COMMAND(ID_REMOTE_GAMMACORRECTION, OnRemoteGammacorrection) ON_UPDATE_COMMAND_UI(ID_REMOTE_GAMMACORRECTION, OnUpdateRemoteGammacorrection) ON_COMMAND(ID_REMOTE_LOADPATH, OnRemoteLoadpath) ON_UPDATE_COMMAND_UI(ID_REMOTE_LOADPATH, OnUpdateRemoteLoadpath) ON_COMMAND(ID_SERVER_IMAGESPATH, OnServerImagespath) ON_UPDATE_COMMAND_UI(ID_SERVER_IMAGESPATH, OnUpdateServerImagespath) ON_WM_PALETTECHANGED() ON_WM_SYSCOLORCHANGE() ON_WM_QUERYNEWPALETTE() //}}AFX_MSG_MAP END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator ID_SEPARATOR, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, }; ///////////////////////////////////////////////////////////////////////////// // CMainFrame construction/destruction CMainFrame::CMainFrame() { m_Inet.StartUp(); m_bServerStarted = FALSE; m_pBitmapBase = NULL; m_bCreateBitmapWindow = TRUE; //TRUE: allocate BitmapWindow when calling OnOpen() m_bLoadPathStarted = FALSE; m_strAddress = _T(""); m_strImageName = _T(""); InitializeVariables(); pImageListDlg = new CImageListDialog(); memset(m_szImageDir, '\0', sizeof(m_szImageDir)); memset(m_szRegKeyPath, 0, sizeof(m_szRegKeyPath)); wsprintf(m_szRegKeyPath,_T("Software\\LEAD Technologies, Inc.\\LEADTOOLS 14.0 Win32\\14\\NetCmd")); memset(m_szKeyClass, 0, sizeof(m_szKeyClass)); wsprintf(m_szKeyClass,_T("SERVER PATH")); m_hResultKey = NULL; DWORD dwType, dwData = L_MAXPATH*sizeof(L_TCHAR); BYTE byData[L_MAXPATH*sizeof(L_TCHAR)]; memset(byData,0,sizeof(byData)); if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_szRegKeyPath, 0, KEY_ALL_ACCESS, &m_hResultKey) == ERROR_SUCCESS && RegQueryValueEx(m_hResultKey, m_szKeyClass, NULL, &dwType, byData, &dwData) == ERROR_SUCCESS) lstrcpy(m_szImageDir, (L_TCHAR*)byData); } CMainFrame::~CMainFrame() { m_Inet.ShutDown(); if(pImageListDlg) { pImageListDlg->DestroyWindow(); } } int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.Create(this) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } UINT nItemID; UINT nItemStyle; L_INT cxItemWidth; m_wndStatusBar.GetPaneInfo(0, nItemID, nItemStyle, cxItemWidth); m_wndStatusBar.SetPaneInfo(0, nItemID, nItemStyle & (~SBPS_STRETCH), cxItemWidth = 240); m_wndStatusBar.GetPaneInfo(1, nItemID, nItemStyle, cxItemWidth); m_wndStatusBar.SetPaneInfo(1, nItemID, nItemStyle | SBPS_STRETCH, 0); // TODO: Remove this if you don't want tool tips or a resizeable toolbar m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); return 0; } BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIFrameWnd::PreCreateWindow(cs) ) return FALSE; // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs cs.x = 0; cs.y = 0; cs.cx = 600; cs.cy = 400; return TRUE; } ///////////////////////////////////////////////////////////////////////////// // CMainFrame diagnostics #ifdef _DEBUG void CMainFrame::AssertValid() const { CMDIFrameWnd::AssertValid(); } void CMainFrame::Dump(CDumpContext& dc) const { CMDIFrameWnd::Dump(dc); } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CMainFrame message handlers void CMainFrame::InitializeVariables() { m_pInetRemoteServer = NULL; m_bConnectedToRemoteServer = FALSE; m_bGetBitmap = TRUE; m_bBitmapAttachedToWindow = FALSE; m_nCommandID = 0; m_nImageIndex = 0; m_hLastLoadedWnd = NULL; m_uWindowID = NULL; m_uBitmapID = NO_BITMAP; } void CMainFrame::OnServerStartup() { L_INT nRet; nRet = m_Inet.ServerInit(PORT_NUMBER); if (nRet == SUCCESS) { UpdateStatusbar(_T("Success: Server Started")); m_bServerStarted = TRUE; } else { UpdateStatusbar(_T("Error[%d]: Starting Server")); } } void CMainFrame::OnUpdateServerStartup(CCmdUI* pCmdUI) { pCmdUI->Enable(!m_bServerStarted && !m_bConnectedToRemoteServer); } void CMainFrame::OnServerShutdown() { L_INT nRet; nRet = m_Inet.ServerShutdown(); if (nRet == SUCCESS) { UpdateStatusbar(_T("Success: Server Shut Down")); m_bServerStarted = FALSE; } else { UpdateStatusbar(_T("Error[%d]: Shutting Down Server")); } } void CMainFrame::OnUpdateServerShutdown(CCmdUI* pCmdUI) { pCmdUI->Enable(m_bServerStarted); } void CMainFrame::UpdateStatusbar(LPCTSTR lpszString) { this->m_wndStatusBar.SetPaneText(1, lpszString, TRUE); } void CMainFrame::UpdateStatusbar(LPCTSTR lpszString, L_INT nRet) { CString strMsg; strMsg.Format(lpszString, nRet); this->m_wndStatusBar.SetPaneText(1, strMsg, TRUE); } void CMainFrame::OnHelpInstructions() { CDialog MyDialog(IDD_INSTRUCTIONS, this); MyDialog.DoModal(); } void CMainFrame::OnServerConnecttoremoteserver() { L_TCHAR szMsg[200]; L_INT nRet; CConnectDialog ConnectDlg; ConnectDlg.m_strAddress = m_strAddress; if (IDOK == ConnectDlg.DoModal()) { m_strAddress = ConnectDlg.m_strAddress; InitializeVariables(); //Have a dialog box to get the URL #ifdef UNICODE { L_INT nSize = m_strAddress.GetLength()*sizeof(L_TCHAR); L_CHAR* pszTempURL = new L_CHAR[nSize] ; if(NULL==pszTempURL) { MessageBox(_T("No Enough Memory"), _T("Error") ); } memset (pszTempURL, 0, nSize); wcstombs(pszTempURL, m_strAddress.GetBuffer(m_strAddress.GetLength()), nSize); nRet = m_Inet.Connect(pszTempURL, PORT_NUMBER); if(NULL!=pszTempURL) { delete[] pszTempURL; pszTempURL = NULL; } } #else nRet = m_Inet.Connect(m_strAddress, PORT_NUMBER); #endif if(nRet == ERROR_HOST_RESOLVE) { wsprintf(szMsg, _T("Error[%d]: Failed to connect - bad URL"), nRet); AfxMessageBox(szMsg); } else if(nRet != SUCCESS) { wsprintf(szMsg, _T("Error[%d]: Connecting to Remote Server"), nRet); AfxMessageBox(szMsg); } } } void CMainFrame::OnUpdateServerConnecttoremoteserver(CCmdUI* pCmdUI) { pCmdUI->Enable(!m_bServerStarted && !m_bConnectedToRemoteServer); } void CMainFrame::OnServerDisconnectfromremoveserver() { L_INT nRet; nRet = m_Inet.Close(this->m_pInetRemoteServer); if (nRet == SUCCESS) { SetWindowText(_T("Connection to Remote Server Closed")); InitializeVariables(); UpdateStatusbar(_T("Success: Disconnected from Remote Server")); } else { UpdateStatusbar(_T("Error: Disconnect from Remote Server"), nRet); } } void CMainFrame::OnUpdateServerDisconnectfromremoveserver(CCmdUI* pCmdUI) { pCmdUI->Enable(m_bConnectedToRemoteServer); } void CMainFrame::OnServerCloseallconnections() { L_INT nRet = SUCCESS; nRet = m_Inet.CloseAll(CLIENT); if (nRet == SUCCESS) { UpdateStatusbar(_T("Success: Closed all connections")); } else { UpdateStatusbar(_T("Error[%d]: Failed to close all connections"), nRet); } } void CMainFrame::OnUpdateServerCloseallconnections(CCmdUI* pCmdUI) { L_INT uCount = m_Inet.GetItemsCount(); pCmdUI->Enable(m_bServerStarted && uCount != 0); } //This example sends a message to a remote connection to load a bitmap //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar void CMainFrame::OnRemoteLoadbitmap() { L_INT nRet = SUCCESS; CConnectDialog ConnectDlg; TCHAR sz[256]; ConnectDlg.m_strAddress = m_strImageName; ConnectDlg.m_bLoadDiaolg = TRUE; if (IDOK == ConnectDlg.DoModal()) { m_strImageName = ConnectDlg.m_strAddress; wsprintf(sz, m_strImageName); nRet = m_Inet.SendLoadCmd(m_pInetRemoteServer, GetNextCommandID(), sz); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteLoadbitmap"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteLoadbitmap")); } } } void CMainFrame::OnUpdateRemoteLoadbitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = (IsConnected() && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } L_INT CMainFrame::GetNextCommandID() { m_nCommandID++; return m_nCommandID; } //This example sends a message to a remote connection to create a window. //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() void CMainFrame::OnRemoteCreatewindow() { L_INT nRet = SUCCESS; L_INT nNotUsed = 0; nRet = m_Inet.SendCreateWinCmd( m_pInetRemoteServer, GetNextCommandID(), _T(""), _T("Window created by remote computer"), nNotUsed, nNotUsed, nNotUsed, 350, 300, 0); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d] OnRemoteCreatewindow"), nRet); } void CMainFrame::OnUpdateRemoteCreatewindow(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = (IsConnected() && m_uWindowID == NULL && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } //This example sends a message to a remote connection to attach a loaded bitmap to a created window. //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() //7. m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendLoadCmd() void CMainFrame::OnRemoteAttachbitmaptowindow() { L_INT nRet = SUCCESS; nRet = m_Inet.SendAttachBitmapCmd( m_pInetRemoteServer, GetNextCommandID(), m_uBitmapID, m_uWindowID); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteAttachbitmaptowindow"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteAttachbitmaptowindow")); } } void CMainFrame::OnUpdateRemoteAttachbitmaptowindow(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = (IsConnected() && (m_uBitmapID != NO_BITMAP) && (m_uWindowID != NULL) && (!m_bBitmapAttachedToWindow) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } //This example sends a message to a remote connection to flip a bitmap //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() //7. m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendLoadCmd() void CMainFrame::OnRemoteFlipbitmap() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_FLIP, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteFlipbitmap"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteFlipbitmap")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemoteFlipbitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } //This example sends a message to a remote connection to get a bitmap and send to the client //This example also sets extra data to a sample string //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() //7. m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendLoadCmd() void CMainFrame::OnRemoteGetbitmap() { L_INT nRet; LInetPacket InetPacket; InetPacket.SetFormats("%ud", m_uBitmapID); L_TCHAR *pszExtraData = _T("*** Sample Extra Data ***\n"); InetPacket.SetExtraData((lstrlen(pszExtraData) + 1)*sizeof(L_TCHAR), pszExtraData ); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_GET, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteGetbitmap"), nRet); } else if(nRet == SUCCESS) { theApp.CloseAllDocuments(FALSE); } //LInetPacket destructor called here ... } void CMainFrame::OnUpdateRemoteGetbitmap(CCmdUI* pCmdUI) { pCmdUI->Enable((IsConnected()) && (m_uBitmapID != NO_BITMAP) && !m_bLoadPathStarted); } //This example sends a message to a remote connection save a loaded bitmap locally //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendLoadCmd() void CMainFrame::OnRemoteSavebitmap() { L_INT nRet; nRet = m_Inet.SendSaveCmd( m_pInetRemoteServer, GetNextCommandID(), _T("remote.tif"), //save in remote app's current working folder m_uBitmapID, FILE_TIF); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d]: OnRemoteSavebitmap"), nRet); } void CMainFrame::OnUpdateRemoteSavebitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } L_BOOL CMainFrame::IsConnected() { return m_pInetRemoteServer != NULL; } //This example sends a message to a remote connection to maximize a window //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() void CMainFrame::OnRemoteSendshowwincmd() { L_INT nRet = SUCCESS; nRet = m_Inet.SendShowWinCmd( m_pInetRemoteServer, GetNextCommandID(), m_uWindowID, SW_SHOWMAXIMIZED ); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d] OnRemoteSendshowwincmd"), nRet); } //This example sends a message to a remote connection to close a window //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() void CMainFrame::OnRemoteSendclosewincmd() { L_INT nRet = SUCCESS; nRet = m_Inet.SendCloseWinCmd( m_pInetRemoteServer, GetNextCommandID(), m_uWindowID ); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d] OnRemoteSendclosewincmd"), nRet); } //This example sends a message to a remote connection to free a bitmap //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uBitmapID is a bitmap id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendLoadCmd() void CMainFrame::OnRemoteSendfreebitmapcmd() { L_INT nRet = SUCCESS; nRet = m_Inet.SendFreeBitmapCmd( m_pInetRemoteServer, GetNextCommandID(), m_uBitmapID ); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d] OnRemoteSendfreebitmapcmd"), nRet); } //This example sends a message to a remote connection to zoom to the rectangle (30,30,80,80) //It assumed that: //1. m_Inet is an object of the class LInet. //2. the network as been started (LInet::StartUp()) //3. a connection has been established with a remote server (LInet::m_Inet.Connect()) //4. GetNextCommandID() is a function that returns a unique command identifier //5. UpdateStatusbar() is a function that displays a message in the status bar //6. m_uWindowID is a window id that is received in the LInet::ResponseCallBack() as a result // of a call to m_Inet.SendCreateWinCmd() void CMainFrame::OnRemoteSendsetrectcmd() { L_INT nRet = SUCCESS; nRet = m_Inet.SendSetRectCmd( m_pInetRemoteServer, GetNextCommandID(), m_uWindowID, RECT_SRCALL, 30, //left 30, //top 80, //width 80 //height ); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) UpdateStatusbar(_T("Error[%d] OnRemoteSendsetrectcmd"), nRet); } void CMainFrame::OnUpdateRemoteSendclosewincmd(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uWindowID != NULL) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnUpdateRemoteSendfreebitmapcmd(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnUpdateRemoteSendsetrectcmd(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (m_uWindowID != NULL) && (m_bBitmapAttachedToWindow) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnUpdateRemoteSendshowwincmd(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uWindowID != NULL) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnUpdateRemoteSendsizewincmd(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uWindowID != NULL)); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteReversebitmap() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_REVERSE, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteReversebitmap"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteReversebitmap")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemoteReversebitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemote90clockwise() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_90, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemote90clockwise"), nRet); } else { UpdateStatusbar(_T("Success: OnRemote90clockwise")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemote90clockwise(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemote180clockwise() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_180, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemote180clockwise"), nRet); } else { UpdateStatusbar(_T("Success: OnRemote180clockwise")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemote180clockwise(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteShearbitmap() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_SHEAR, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteShearbitmap"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteShearbitmap")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemoteShearbitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteResizebitmap() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); RESIZEDLGPARAMS DlgParams; memset(&DlgParams,0,sizeof(RESIZEDLGPARAMS)); DlgParams.uStructSize = sizeof ( RESIZEDLGPARAMS ) ; DlgParams.uOriginalWidth = pDocument->m_pBitmapWindow->GetWidth(); DlgParams.uOriginalHeight = pDocument->m_pBitmapWindow->GetHeight(); DlgParams.uOriginalResolutionX = pDocument->m_pBitmapWindow->GetXResolution(); DlgParams.uOriginalResolutionY = pDocument->m_pBitmapWindow->GetYResolution(); DlgParams.uOriginalBitsPerPixel = pDocument->m_pBitmapWindow->GetBitsPerPixel(); DlgParams.uNewWidth = pDocument->m_pBitmapWindow->GetWidth(); DlgParams.uNewHeight = pDocument->m_pBitmapWindow->GetHeight(); DlgParams.uNewResolutionX = pDocument->m_pBitmapWindow->GetXResolution(); DlgParams.uNewResolutionY = pDocument->m_pBitmapWindow->GetYResolution(); DlgParams.uResize = SIZE_NORMAL ; DlgParams.uDlgFlags = DLG_RESIZE_SHOW_PERCENTAGE | DLG_RESIZE_SHOW_IDENTICALVALUE | DLG_RESIZE_SHOW_MAINTAINASPECT | DLG_RESIZE_SHOW_RESOLUTIONGRP; pDocument->m_pBitmapWindow->DialogImage()->EnableAutoProcess(FALSE); pDocument->m_pBitmapWindow->DialogImage()->EnableCallBack(FALSE); pDocument->m_pBitmapWindow->DialogImage()->SetResizeParams(&DlgParams) ; if(SUCCESS_DLG_OK == pDocument->m_pBitmapWindow->DialogImage()->DoModalResize(m_hWnd)) { pDocument->m_pBitmapWindow->DialogImage()->GetResizeParams(&DlgParams, sizeof(DlgParams)); L_INT nWidth = DlgParams.uNewWidth; L_INT nHeight = DlgParams.uNewHeight; L_UINT uResizeMethod = DlgParams.uResize; L_INT nXResolution = pDocument->m_pBitmapWindow->GetXResolution(); L_INT nYResolution = pDocument->m_pBitmapWindow->GetYResolution(); LInetPacket InetPacket(NULL, NULL, "%ud%d%d%ud%d%d", m_uBitmapID, nWidth, nHeight, uResizeMethod, nXResolution, nYResolution); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_RESIZE, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteResizebitmap"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteResizebitmap")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteResizebitmap(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemotePosterize() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogColor dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); POSTERIZEDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( POSTERIZEDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( POSTERIZEDLGPARAMS ) ; DlgParams.nLevels = 2 ; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); //dialog.EnableAutoProcess(TRUE); dialog.EnableToolbar(TRUE); dialog.SetPosterizeParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalPosterize(m_hWnd)) { dialog.GetPosterizeParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%d", m_uBitmapID, DlgParams.nLevels); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_POSTERIZE, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemotePosterize"), nRet); } else { UpdateStatusbar(_T("Success: OnRemotePosterize")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemotePosterize(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteAddnoise() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogImageEffect dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); ADDNOISEDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( ADDNOISEDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( ADDNOISEDLGPARAMS ) ; DlgParams.uRange = 100 ; DlgParams.uChannel = CHANNEL_MASTER ; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetAddNoiseParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalAddNoise(m_hWnd)) { dialog.GetAddNoiseParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%ud%ud", m_uBitmapID, DlgParams.uRange, DlgParams.uChannel); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_NOISE, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteAddnoise"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteAddnoise")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteAddnoise(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteOilify() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogImageEffect dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); OILIFYDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( OILIFYDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( OILIFYDLGPARAMS ) ; DlgParams.uDim = 3 ; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetOilifyParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalOilify(m_hWnd)) { dialog.GetOilifyParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%d", m_uBitmapID, DlgParams.uDim); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_OILIFY, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteOilify"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteOilify")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteOilify(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteResolution() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogColor dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); COLORRESDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( COLORRESDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( COLORRESDLGPARAMS ) ; DlgParams.uDlgFlagsEx = DLG_COLORRES_SHOW_BITALL | DLG_COLORRES_SHOW_DITHER_ALL | DLG_COLORRES_SHOW_PAL_ALL ; DlgParams.uDlgFlags = DLG_COLORRES_SHOW_OPENPALFILE | DLG_COLORRES_SHOW_ORDER; DlgParams.nBitsPerPixel = pDocument->m_pBitmapWindow->GetBitsPerPixel(); dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetColorResParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalColorRes(m_hWnd)) { dialog.GetColorResParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%d%ud", m_uBitmapID, DlgParams.nBitsPerPixel, DlgParams.uColorResFlags); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_RESOLUTION, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteResolution"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteResolution")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteResolution(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteInvert() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%ud", m_uBitmapID); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_INVERT, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteInvert"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteInvert")); } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemoteInvert(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteContrast() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogColor dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); CONTRASTDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( CONTRASTDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( CONTRASTDLGPARAMS ) ; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetContrastParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalContrast(m_hWnd)) { dialog.GetContrastParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%d", m_uBitmapID, DlgParams.nChange); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_CONTRAST, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteContrast"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteContrast")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteContrast(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteSaturation() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogColor dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); SATURATIONDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( SATURATIONDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( SATURATIONDLGPARAMS ) ; DlgParams.nChange = 0; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetSaturationParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalSaturation(m_hWnd)) { dialog.GetSaturationParams(&DlgParams, sizeof(DlgParams)) ; LInetPacket InetPacket(NULL, NULL, "%ud%d", m_uBitmapID, DlgParams.nChange); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_SATURATION, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteSaturation"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteSaturation")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteSaturation(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteGammacorrection() { L_INT nRet; CMDIChildWnd* pChild = MDIGetActive(); CNetView* pView = (CNetView*)pChild->GetActiveView(); do { if(pView) { if (pView->m_hWnd == m_hLastLoadedWnd) { pChild->MDIActivate(); break; } } pChild = (CMDIChildWnd*) pChild->GetWindow(GW_HWNDNEXT); pView = (CNetView*)pChild->GetActiveView(); } while (pChild); if(pView) { CNetDoc* pDocument; pDocument = (CNetDoc*) pView->GetDocument(); LDialogColor dialog; dialog.SetBitmap(pDocument->m_pBitmapWindow); GAMMAADJUSTMENTDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( GAMMAADJUSTMENTDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( GAMMAADJUSTMENTDLGPARAMS ) ; DlgParams.nRedValue = 150 ; DlgParams.nGreenValue = 150 ; DlgParams.nBlueValue = 150 ; dialog.EnableCallBack(FALSE); dialog.EnablePreview(TRUE); dialog.EnableToolbar(TRUE); dialog.SetGammaAdjustmentParams(&DlgParams) ; if(SUCCESS_DLG_OK == dialog.DoModalGammaAdjustment(m_hWnd)) { dialog.GetGammaAdjustmentParams(&DlgParams, sizeof(DlgParams)) ; L_INT nRedValue = DlgParams.nRedValue; L_INT nGreenValue = DlgParams.nGreenValue; L_INT nBlueValue = DlgParams.nBlueValue; LInetPacket InetPacket(NULL, NULL, "%ud%d%d%d", m_uBitmapID, nRedValue, nGreenValue, nBlueValue); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_GAMMA, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteGammacorrection"), nRet); } else { UpdateStatusbar(_T("Success: OnRemoteGammacorrection")); } //LInetPacket::~LInetPacket() destructor gets called here ... } } } void CMainFrame::OnUpdateRemoteGammacorrection(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = ((IsConnected()) && (m_uBitmapID != NO_BITMAP) && (!m_bGetBitmap) && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnRemoteLoadpath() { L_INT nRet; LInetPacket InetPacket(NULL, NULL, "%d", 1); nRet = m_Inet.SendCmd(m_pInetRemoteServer, (CMDTYPE)CMD_LOADPATH, GetNextCommandID(), &InetPacket); if(nRet != SUCCESS && nRet != ERROR_DATA_QUEUED) { UpdateStatusbar(_T("Error[%d]: OnRemoteLoadpath"), nRet); m_bLoadPathStarted = FALSE; } else if(nRet == SUCCESS) { UpdateStatusbar(_T("Success: OnRemoteLoadpath")); m_bLoadPathStarted = TRUE; memset(m_ImageNameList, 0, (sizeof(L_TCHAR) * L_MAXPATH * 80)); m_nImageIndex = 0; pImageListDlg->DoModal(); if (!pImageListDlg->m_bInit) { AfxMessageBox(_T("Error when creating dialog to load images from remote path"), MB_ICONSTOP); } } //LInetPacket::~LInetPacket() destructor gets called here ... } void CMainFrame::OnUpdateRemoteLoadpath(CCmdUI* pCmdUI) { L_BOOL bEnable; bEnable = (IsConnected() && !m_bLoadPathStarted); pCmdUI->Enable(bEnable); } void CMainFrame::OnServerImagespath() { L_INT nIndex = 1; LDialogFile lDlg; L_INT nRet = 0; GETDIRECTORYDLGPARAMS DlgParams; memset ( &DlgParams, 0, sizeof ( GETDIRECTORYDLGPARAMS ) ) ; DlgParams.uStructSize = sizeof ( GETDIRECTORYDLGPARAMS ) ; DlgParams.pszDirectory = m_szImageDir; DlgParams.nBuffSize = sizeof(m_szImageDir); DlgParams.pszFilter = _T("ALL\0*.*\0LEAD\0*.cmp\0JPEG\0*.JPG\0") ; DlgParams.nFilterIndex = 1 ; DlgParams.pszTitle = _T("Select a Directory Please"); lDlg.SetDirectoryParams(&DlgParams) ; if(lDlg.DoModalGetDirectory(m_hWnd) == SUCCESS_DLG_OK) { if(RegCreateKeyEx(HKEY_LOCAL_MACHINE, m_szRegKeyPath, 0, m_szKeyClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &m_hResultKey, NULL) == ERROR_SUCCESS) { RegSetValueEx(m_hResultKey, _T("Server Path"), 0, REG_SZ, (LPBYTE)m_szImageDir, ((lstrlen(m_szImageDir) + 1) * sizeof(L_TCHAR))); } } } void CMainFrame::OnUpdateServerImagespath(CCmdUI* pCmdUI) { pCmdUI->Enable(m_bServerStarted); } void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) { if(pFocusWnd!=NULL) SendMessageToDescendants(WM_HANDLEPALETTE,(WPARAM)pFocusWnd->m_hWnd,TRUE); } void CMainFrame::OnSysColorChange() { OnQueryNewPalette(); } BOOL CMainFrame::OnQueryNewPalette() { CMDIChildWnd* pMDIChildWnd = MDIGetActive(); if (pMDIChildWnd) { CView* pView = pMDIChildWnd->GetActiveView(); if(pView) { pView->SendMessage(WM_HANDLEPALETTE,0,FALSE); return TRUE; } } return FALSE; }