Пример #1
0
        // it is used only in desktop sharing (remote control)
        public void captureThreadFuncEx2()
        {
            try
            {
                //int nWidthBlocks=1;
                //int nHeightBlocks = 1;
                //int nBlocks=nHeightBlocks *nWidthBlocks;

                #region  Set window stuff
                // set window stuff
                Win32.USER32.GetWindowRect(sharedWnd, ref rect);

                //SetWindowPos((int)sharedWnd, (int)WindowPlacement.HWD_TOPMOST,rect.Left,rect.Top,
                //					rect.Right-rect.Left, rect.Bottom-rect.Top,0);

                //ShowWindow((IntPtr)sharedWnd, SW_SHOWMAXIMIZED);// new 5 dec

                //SetActiveWindow(sharedWnd);

                //SetForegroundWindow(sharedWnd);
                #endregion

                ImageConverter conv = new ImageConverter();

                #region Create screen bitmap

                // get window dimensions
                blockWidth = (rect.right - rect.left);//nWidthBlocks;
                blockHeight = (rect.bottom - rect.top);//nHeightBlocks;

                hdcSrc = (int)Win32.USER32.GetWindowDC((int)sharedWnd);
                int hdcDest =Win32.USER32.CreateCompatibleDC(hdcSrc);

                // create window bitmap
                int hBitmap = Win32.USER32.CreateCompatibleBitmap(hdcSrc,
                    blockWidth,blockHeight);
                Win32.USER32.SelectObject(hdcDest,hBitmap);

                #endregion

                #region Different initializations
                // get number of adjacent color bits for each pixel
                // in this we will get 4
                int nNumber = Win32.USER32.GetDeviceCaps(hdcSrc,Win32.USER32.BITSPIXEL);

                // calculate buffer size
                int bufferSize= blockWidth*blockHeight*nNumber / 8;

                // initialize buffer
                byte[] buffer = new byte[bufferSize];

                // initialiaze current block number
                //int nBlockNo = 0;

                // clear the hash array.
                //hashArray.Clear();

                // previous hash: this will contain, hash of previously captured blocks
                byte[] prevHash = new byte[blockWidth*blockHeight];

                // b containts a block data
                byte[] blockData=new byte[blockWidth*blockHeight];
                #endregion

                #region STEP1 Send Screen SIZE
                // send window size information
                SendSizeInformation((rect.right - rect.left),
                    (rect.bottom - rect.top));
                #endregion

                // variables to contain cursor position
                Win32.USER32.POINT cursorPosition = new Win32.USER32.POINT();

                Win32.USER32.POINT tempPosition = new Win32.USER32.POINT();
                Win32.USER32.RECT temprect = new Win32.USER32.RECT();

                // screen width and height,
                // these are used later to track whether the window has gone out of the screen or not
                // blocks that are out of screen are not painted or sent
                int _nScreenWidth = Screen.PrimaryScreen.Bounds.Width;
                int _nScreenHeight = Screen.PrimaryScreen.Bounds.Height;

                //int nTemp =0;

                // start coods
                int nStartX = 0,nStartY = 0;

                // current block width and height
                int nCurrentBlockWidth = blockWidth ,nCurrentBlockHeight=blockHeight;

                // hash of the current block
                //	byte[] hash = null;

                int nQuantizeCount=10; // set the quanization count as 10 initially

                //				bt = new StringBuilder(1024);

                //byte[] b;

                // get mouse coordinates
                Point lastMousePoint=new System.Drawing.Point(0,0);

                // create brush
                int _hBrush = Win32.USER32.CreateSolidBrush(0xffffff);

                Win32.USER32.RECT _tempRect = new Win32.USER32.RECT();

                //int nCopyX,  nCopyY;

                // this is not used anywhere so we will comment this coz this isnt used anywhere
                //int hBitmap_dummy = CreateCompatibleBitmap(hdcSrc,blockWidth,blockHeight);

                //bool bDifferenceFound = false;

                OctreeQuantizer quantizer = new OctreeQuantizer(255,8);

                while(m_bActive) // send data only if the window is active
                {
                    try
                    {
                        // whats quantizer count
                        if(nQuantizeCount > 5) // this will be true initially as the quantization count's been set to 10
                        {
                            nQuantizeCount=0; // reinitialize quantizer count
                            quantizer = null;
                            quantizer =new OctreeQuantizer (255,8);
                        }

                        nQuantizeCount++; // increment quantize count

                        /*
                        // get window rect again
                        GetWindowRect(sharedWnd, ref temprect);
                        int tempX= GetScrollPos(sharedWnd, SB_HORZ);
                        int tempY= GetScrollPos(sharedWnd, SB_VERT);
                    */
                        #region check if the window has been resized.
                        /*if(((temprect.Right - temprect.Left) != (rect.Right -rect.Left)) ||
                            ((temprect.Bottom - temprect.Top) != (rect.Bottom - rect.Top)) ||
                            (sPrevWindowText != oldString ) || (iPrev_HorXScroll != tempX) ||
                            (iPrev_VerXScroll != tempY))
                        {
                        #region WINDOW_RESIZED
                            //If the window has been resized
                            bool bRepeatIT = true;

                            while((bRepeatIT) && (m_bActive))
                            {
                                Trace.WriteLine("catptureThread: quantizer while((bRepeatIT) && (m_bActive)) ");
                                try
                                {
                                    rect = temprect;
                                    sPrevWindowText = oldString;
                                    iPrev_HorXScroll = tempX;
                                    iPrev_VerXScroll = tempY;

                                    blockWidth = (rect.Right - rect.Left)/nWidthBlocks;
                                    blockHeight = (rect.Bottom - rect.Top)/nHeightBlocks;

                                    hBitmap = CreateCompatibleBitmap(hdcSrc,blockWidth,blockHeight);
                                    SelectObject(hdcDest,hBitmap);

                                    // not used, not required
                                    //hBitmap_dummy = CreateCompatibleBitmap(hdcSrc,blockWidth,blockHeight);

                                    bufferSize=blockWidth*blockHeight*nNumber/8;//4;
                                    buffer = new byte[bufferSize];

                                    nBlockNo = 0;
                                    hashArray.Clear();
                                    b = null;

                                    b=new byte[blockWidth*blockHeight]; // reinitialize block data

                                    // send size information
                                    SendSizeInformation((rect.Right - rect.Left),
                                        (rect.Bottom - rect.Top));
                                    bRepeatIT = false;

                                }
                                catch(Exception )
                                {

                                    bRepeatIT = true;

                                }
                            }
                        #endregion
                        }
                        else if((temprect.Left != rect.Left) || (temprect.Top != rect.Top)  )
                        {
                        #region Window_Moved
                            //if the window has been moved
                            rect = temprect;

                        #endregion

                        }*/
                        #endregion

                        //nBlockNo = 0;

                        //for(int nRow = 0 ; nRow < nHeightBlocks ; nRow++)
                    {
                        // for each block
                        //for(int nColumn=0; nColumn< nWidthBlocks; nColumn++,nBlockNo++)
                    {
                        try
                        {
                            #region divided into blocks
                            /*
                                    // get start coods
                                    nStartX = nColumn * blockWidth;
                                    nStartY = nRow * blockHeight;

                                    // get block width
                                    nCurrentBlockWidth = blockWidth;
                                    nCurrentBlockHeight = blockHeight;

                                    //Tricking missing pisxels.
                                    // check if its the last column
                                    if(nColumn == (nWidthBlocks -1))
                                    {
                                        // if its the last column, append the remaining
                                        // bits with the rest of the stuff
                                        nTemp = nStartX + blockWidth;
                                        if(nTemp < (rect.Right - rect.Left))
                                            nCurrentBlockWidth += (rect.Right - rect.Left) - nTemp;

                                    }

                                    // if it's the last row
                                    if(nRow == (nHeightBlocks-1))
                                    {
                                        // increate the height
                                        nTemp = nStartY + blockHeight;

                                    }
                                    */
                            #endregion
                            #region BUILD_BITMAP
                            // build the bitmap

                            Win32.USER32.SelectObject(hdcDest,hBitmap);
                            /*
                                     * nCopyX = nCurrentBlockWidth;
                                    nCopyY = nCurrentBlockHeight;

                                    _tempRect.Left = 0;
                                    _tempRect.Top = 0;
                                    _tempRect.Right = nCurrentBlockWidth;
                                    _tempRect.Bottom = nCurrentBlockHeight;
                                    //								int startX=0;
                                    //								int startY=0;
                                    int endX=nCurrentBlockWidth;
                                    int endY=nCurrentBlockHeight;

                                    if(nCurrentBlockWidth + nStartX + temprect.Left > _nScreenWidth)
                                    {
                                        FillRect((IntPtr)hdcDest,ref _tempRect,(IntPtr)_hBrush);
                                        endX=(_nScreenWidth - nStartX- temprect.Left) % nCurrentBlockWidth;
                                        if(endX==0)
                                            endX=nCurrentBlockWidth;
                                    }
                                    else if(nStartX + temprect.Left < 0)
                                    {
                                        FillRect((IntPtr)hdcDest,ref _tempRect,(IntPtr)_hBrush);
                                        //startX=tempRect.Left;
                                    }
                                    else if(nCurrentBlockHeight + nStartY + temprect.Top > _nScreenHeight)
                                    {
                                        FillRect((IntPtr)hdcDest,ref _tempRect,(IntPtr)_hBrush);
                                        endY=(_nScreenHeight - nStartY- temprect.Top) % nCurrentBlockHeight;
                                        if(endY==0)
                                            endY=nCurrentBlockWidth;
                                    }
                                    else if(nStartY + temprect.Top < 0)
                                    {
                                        FillRect((IntPtr)hdcDest,ref _tempRect,(IntPtr)_hBrush);
                                    }
                                    */
                            /*BitBlt(hdcDest,0,0,endX,endY,
                                        hdcSrc,	nStartX,nStartY,
                                        0x00CC0020);
                                        */
                            Win32.USER32.BitBlt(hdcDest,0,0,blockWidth,blockHeight,
                                hdcSrc,	0,0,
                                0x00CC0020);

                            //GetBitmapBits((IntPtr)hBitmap,buffer.Length,buffer);

                            Image _image = Image.FromHbitmap((IntPtr)hBitmap);
                            using( Image _quantized = quantizer.Quantize(_image))
                            {
                                buffer =(byte[]) conv.ConvertTo(_quantized, typeof(byte[]));
                                //buffer = (byte[]) conv.ConvertTo(_image , typeof(byte[]));
                            }

                            _image.Dispose();

                            #endregion
                            #region hashing method
                            //Compute a hash for each image
                            SHA256Managed shaM = new SHA256Managed();
                            byte[] hash1 = shaM.ComputeHash(buffer);
                            byte[] hash2 = shaM.ComputeHash(prevHash );

                            //Compare the hash values
                            for (int i = 0; i < hash1.Length && i < hash2.Length  ; i++)
                            {
                                if (hash1[i] != hash2[i])
                                {								// image has changed
                                    Console.WriteLine(" new image has sent using hash  :  " + DateTime.Now.ToString()+ " " +DateTime.Now.Millisecond.ToString());
                                    int length2=buffer.Length;

                                    /*Image _image = Image.FromHbitmap((IntPtr)hBitmap);
                                            Image _quantized = quantizer.Quantize(_image);
                                            _image.Dispose();

                                            // convert quantized array to byte array
                                            b=(byte[]) conv.ConvertTo(_quantized, typeof(byte[]));
                                            length2 = b.Length;
                                            */
                                    // send image
                                    // note that image was added in the hash array list and
                                    // this data is sent,
                                    CompressAndSendBuffer(ref buffer,DataType.PictureBlock,
                                        ref nStartX,ref nStartY,ref nCurrentBlockWidth,
                                        ref nCurrentBlockHeight, ref length2);
                                    //_quantized.Dispose();
                                    prevHash = (byte[])buffer.Clone();
                                    break;
                                }
                            }

                            #endregion

                            /*int length2=buffer.Length;
                                    Image _image = Image.FromHbitmap((IntPtr)hBitmap);
                                    Image _quantized = quantizer.Quantize(_image);
                                    _image.Dispose();

                                    // convert quantized array to byte array
                                    b=(byte[]) conv.ConvertTo(_quantized, typeof(byte[]));
                                    length2 = b.Length;

                                    // send image
                                    // note that image was added in the hash array list and
                                    // this data is sent,
                                    CompressAndSendBuffer(ref b,DataType.PictureBlock,
                                        ref nStartX,ref nStartY,ref nCurrentBlockWidth,
                                        ref nCurrentBlockHeight,ref length2);

                                    _quantized.Dispose();*/

                        }
                        catch(Exception ex)
                        {
                            WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void captureThreadFuncEx2()",ex,"",false);
                        }
                    }
                        Thread.Sleep(500);
                    }

                    }
                    catch(Exception ex)
                    {
                        WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void captureThreadFuncEx2()",ex,"",false);
                    }
                }
            }
            catch(Exception ex)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void captureThreadFuncEx2()",ex,"",false);
            }
        }
Пример #2
0
        public void Terminate()
        {
            m_bActive = false;
            try
            {
                if(captureThread!= null)
                {
                    captureThread.Abort();
                    captureThread.Join();

                }
            }
            catch(Exception ex)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void Terminate()",ex,"",false);
            }
            try
            {
                Win32.USER32.RECT rect = new Win32.USER32.RECT();
                if(sharedWnd != IntPtr.Zero)
                {
                    Win32.USER32.GetWindowRect(sharedWnd, ref rect);
                    //SetWindowPos((int)sharedWnd,(int)WindowPlacement.HWD_NOTOPMOST,rect.Left,rect.Top,rect.Right-rect.Left,rect.Bottom-rect.Top,0);

                    //					StringBuilder bt2 = new StringBuilder( oldString);
                    //            		SetWindowText(sharedWnd,bt2);
                }
            }
            catch(Exception ex)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void Terminate()",ex,"",false);
            }
        }
Пример #3
0
        /*run in the case of the App sharing*/
        public void captureThreadFuncEx()
        {
            try
            {
                int nBlocks=nHeightBlocks *nWidthBlocks;
                /*
                 * Intialize Mouse Relevant Stuff
                 */
                IntializeMouseCoordinates();
                /*s
                 * set windows relevant stuff,like get its rectangle,its title,activate it etc..
                 * for more detail go to method header
                 */
                SetWindowStuff();
                /*
                 * initialize imageconverter object
                 * this will be used to convert image into byte array
                 */
                conv=new ImageConverter();
                /*
                 * create window bitmap sturcture on the shared window architecture
                 */
                CreateBitmapStructureForSharedWindow();
                /*
                 * initialize the buffer
                 */
                Initialize_buffer();
                /*
                 * send picture size
                 */
                SendSizeInformation(blockWidth,blockHeight);

                // variables to contain cursor position
                Win32.USER32.POINT cursorPosition = new Win32.USER32.POINT();

                Win32.USER32.RECT temprect = new Win32.USER32.RECT();

                // screen width and height,
                // these are used later to track whether the window has gone out of the screen or not
                // blocks that are out of screen are not painted or sent
                int _nScreenWidth = Screen.PrimaryScreen.Bounds.Width;
                int _nScreenHeight = Screen.PrimaryScreen.Bounds.Height;

                //int nTemp =0;

                // start coods
                int nStartX = 0,nStartY = 0;

                // current block width and height
                //int nCurrentBlockWidth = 0,nCurrentBlockHeight=0;

                // hash of the current block
                //byte[] hash = null;

                //int nQuantizeCount=10; // set the quanization count as 10 initially

                bt = new StringBuilder(1024);

                byte[] b;

                //PitchBlack = 0xffffff

                // create brush
                int _hBrush = Win32.USER32.CreateSolidBrush(0xffffff);

                Win32.USER32.RECT _tempRect = new Win32.USER32.RECT();

                //				int nCopyX,  nCopyY;

                // this is not used anywhere so we will comment this coz this isnt used anywhere
                //int hBitmap_dummy = CreateCompatibleBitmap(hdcSrc,blockWidth,blockHeight);

                //			int nBlockNo = 0;

                OctreeQuantizer quantizer = new OctreeQuantizer(255,8);

                // When u close App share it becomes  false
                // else it remain true uptill the App share is true

                while(m_bActive) // send data only if the window is active
                {
                    try
                    {
                        /*
                         * check window exist if not found then close app share process
                         */
                        if(!bCloseAppshare())
                        {
                            break;
                        }

                        /*
                         * check working window is not shared  then flush and continue
                         */

                        //Zaeem Addition

                        // In previous case thte Sleep was not added here , so that
                        //when it reaches the continue statement, it will skip all the next statement including the
                        // for loop , so that no Sleep in the way , which makes the processing very high
                        // Yet an other Stupid piece of code
                        // Another Check which zaeem is Adding is if the current tab is Appsharing then the image shd be send and same for receiving

                        Thread.Sleep(2000);
                        if(bFlashWindow())
                        {
                            continue;
                        }

                        quantizer =new OctreeQuantizer (255,8);

                        // get server full bitmap
                        if(staticImage!=null)
                        {
                            staticImage.Dispose();
                            staticImage=null;
                        }
                        staticImage= GetServerFullBitmap();
                        /*
                         * this function check last and current coordinate then check
                         * the window coordinate
                         */

                        SendMouseMovements();

                        // If window is inactive then we flush it
                        //
                        //						if(bFlashWindow())
                        //						{
                        //							continue;
                        //							/*
                        //									again return to while loop skip all next instruction in a while
                        //									block.
                        //								*/
                        //						}

                        int length2;//=buffer_CaptureThread.Length;
                        Image _quantized;
                        if(this.staticImage!=null)
                        {
                            _quantized = quantizer.Quantize(staticImage);
                        }
                        else
                            continue;

                        // convert quantized array to byte array
                        b=null;
                        b=(byte[]) conv.ConvertTo(_quantized, typeof(byte[]));

                        length2 = b.Length;

                        // send image
                        // note that image was added in the hash array list and
                        // this data is sent,
                        CompressAndSendBuffer(ref b,DataType.PictureBlock,
                            ref nStartX,ref nStartY,ref this.width_Bitmap,
                            ref this.height_Bitmap,ref length2);
                        SendDummyMouseMovements();
                        _quantized.Dispose();

                        Thread.Sleep(2000);
                    }
                    catch(Exception ex)
                    {
                        WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void captureThreadFuncEx()",ex,"",false);
                    }
                }

            }
            catch(Exception ex)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: AppShare public void captureThreadFuncEx()",ex,"",false);
            }
        }
Пример #4
0
        private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)
        {
            haveFrames = false;

            try
            {

                try
                {
                    //Trace.WriteLine("\n Tracing Message of Repain Window When something change"+Msg.ToString("X"));
                    if(this.chkWm_Size==true)
                    {
                        this.chkWm_Size=false;
                    }

                    switch(Msg)
                    {
            //						case WM_NCPAINT:    // it paint clientarea when we minimize,maximize but the only prob
                                            //is that when we collapse right pane and botton pane then there
                                            //is problem of redraw, by junaid.
            //							this.bScrollDraw=true;
                            //RepaintObjects(-1);
                            //break;
                        case Win32.USER32.WM_LBUTTONDBLCLK:
                            return 0;
                            #region case WM_SIZE :
                        /// This evernt occurs on the size chagew when ever you change the size of the bowser
                        case Win32.USER32.WM_SIZE :
                             //If m.Msg = WM_SIZE Then
                             System.Drawing.Size wnd_size;
                             wnd_size = new  System.Drawing.Size(new System.Drawing.Point(lParam));
                            // this.nSize_heigth=wnd_size.Height;
                            // this.nSize_width=wnd_size.Width;

                            if(wnd_size.Width!=0 && wnd_size.Height!=0 )
                            {
                                if(this.nSize_width < wnd_size.Width  || this.nSize_heigth < wnd_size.Height)
                                {
                                    this.nSize_width=wnd_size.Width;
                                    this.nSize_heigth=wnd_size.Height;
                                    this.chkWm_Size=true;
                                    this.checkDrawPaint=true;
                                }
                                else
                                {
                                    this.nSize_width=wnd_size.Width;
                                    this.nSize_heigth=wnd_size.Height;
                                    this.chkWm_Size=false;
                                    this.checkDrawPaint=false;
                                }
                            }
                            else
                            {
                                this.nSize_heigth=0;
                                this.nSize_width=0;
                                this.checkDrawPaint=false;
                                this.chkWm_Size=false;
                            }

                            //Trace.WriteLine("height : " + wnd_size.Height.ToString() + "Width : " + wnd_size.Width.ToString());
                            return 0;
                            //wnd_size=null;
                            //End If
                            #endregion

                        // This function of scrolling doesn't work
                        case Win32.USER32.WM_VSCROLL :
                            //Trace.WriteLine("WM_VSCROLL is fired");
                            FireScrollEvent();
                            break;
                            #region case WM_PAINT:
                        case Win32.USER32.WM_PAINT:
                            try
                            {

                                if(bOnlyDrawParent)
                                {
                                    bOnlyDrawParent = false;
                                    return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
                                }
                                if((haveFrames) && (!IsExcel))
                                    return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);

                                Point p = GetCurrentScrollPositionBrowser(browserControl);
                                if(p != lastScrollPosition)
                                {
                                    checkmsg=true;

                                    System.Drawing.Graphics glocal;
                                    try
                                    {
                                        if(this.bScrollDraw==false)
                                        {
                                            myTimer = new System.Timers.Timer();
                                            myTimer.Interval = 200;
                                            myTimer.Elapsed += new System.Timers.ElapsedEventHandler(DisplayTimeEvent);
                                            myTimer.Start();
                                            this.bScrollDraw=true;
                                        }
                                        glocal = Graphics.FromHwnd(hWnd);
                                        if(g!=null)
                                        {
                                            lock(g)
                                            {
                                                g = glocal;
                                            }
                                        }
                                        else
                                        {
                                            g=glocal;
                                        }
                                        browserHandle = hWnd;

                                        Size s = browserControl.ClientSize;
                                        this.bodyClientHeight=getBodyClientHeight().Y;

                                        int pixels = Win32.USER32.GetSystemMetrics(Win32.USER32.SM_CXVSCROLL)+2 ;
                                        int pixels2 = Win32.USER32.GetSystemMetrics(3);

                                        s.Width -= pixels ;
                                        //s.Height -= pixels ; // by kamran

                                        //store the previous screen point, help in at the While of WM_SIZE
                                        s.Width -= pixels ;
                                        s.Height -= pixels ; // by kamran
                                        nSize_width=s.Width;
                                        nSize_heigth=this.bodyClientHeight; //;this.browserControl.Height;
                                        /*
                                            Tracing exception of the getBodyClientHeight
                                            WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam) wrong parameter WebSharing Region Parameters :::: X=0,Y=0; "+ "Width ::: " + s.Width.ToString()+ " Height ::: " + this.bodyClientHeight.ToString(),new Exception(" annotation problem in document sharing"),"",false);
                                            WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam) correct parameter WebSharing Region Parameters :::: X=0,Y=0; "+ "Width ::: " + s.Width.ToString()+ " Height ::: " + (s.Height-2).ToString(),new Exception(" annotation problem in document sharing"),"",false);
                                        */

                                        /*
                                         * this check is due to the exception of the getBodyClientHeight
                                         */
                                        if(this.bodyClientHeight==0)
                                        {
                                            lock(g)
                                            {
                                                g.Clip = new Region(new Rectangle(0,0,s.Width,s.Height-2));
                                            }
                                        }
                                        else
                                        {
                                            lock(g)
                                            {
                                                g.Clip = new Region(new Rectangle(0,0,s.Width,this.bodyClientHeight));
                                            }
                                        }

                                        //g.Clip = new Region(new Rectangle(0,0,s.Width,this.bodyClientHeight));
                                        IsWMSizeProcessed=true;
                                        //g.Clip = new Region(new Rectangle(0,0,s.Width,s.Height));
                                    }
                                    catch(Exception ex)// ee)
                                    {
                                        WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: WebSharing  private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)",ex,"",false);
                                    }

                                    DrawNow=true;
                                    FireScrollEvent();
                                    //this.bScrollDraw=true;
                                }
                                else
                                {
                                    this.checkmsg=false;
                                }
                                //Trace.WriteLine("lastScrollPosition" + lastScrollPosition.ToString() + "p" + p.ToString());
                                lastScrollPosition = p;

                                //repaint non-client area when WM_SIZE messages intercept and WM_SIZE width,heigth not equal
                                // to zero and current width screen size is greater than the new WM_SIZE width,height

                                if(this.checkDrawPaint==true )
                                {
                                    //Trace.WriteLine("Now graphics will appear");
                                    p = GetCurrentScrollPositionBrowser(browserControl);
                                    System.Drawing.Graphics glocal;
                                    glocal = Graphics.FromHwnd(hWnd);
                                    if(g==null)
                                    {
                                        g = glocal;
                                    }
                                    else
                                    {
                                        lock(g)
                                        {
                                            g = glocal;
                                        }
                                    }
                                    browserHandle = hWnd;

                                    Size s = browserControl.ClientSize;
                                    this.bodyClientHeight=getBodyClientHeight().Y;
                                    int pixels = Win32.USER32.GetSystemMetrics(Win32.USER32.SM_CXVSCROLL)+2 ;
                                    //SM_CXHSCROLL 21 for getting scroll
                                    int pixels2 = Win32.USER32.GetSystemMetrics(3);

                                    s.Width -= pixels ;
                                    s.Height -= pixels ; // by kamran
                                    //this.browserControl.ClientToWindow;

                                    //store the previous screen point, help in at the While of WM_SIZE
                                    nSize_width=s.Width;
                                    nSize_heigth=this.bodyClientHeight;
                                    if(this.bodyClientHeight==0)
                                    {
                                        lock(g)
                                        {
                                            g.Clip = new Region(new Rectangle(0,0,s.Width,s.Height-2));
                                        }
                                    }
                                    else
                                    {
                                        lock(g)
                                        {
                                            g.Clip = new Region(new Rectangle(0,0,s.Width,this.bodyClientHeight));
                                        }
                                    }
                                    //Trace.WriteLine(s.Width.ToString()+"  " +this.bodyClientHeight.ToString()+" " +s.Height.ToString());
                                    //g.Clip = new Region(new Rectangle(0,0,s.Width,this.bodyClientHeight));
                                    //Trace.WriteLine("Now graphics will appear2");
                                    //g.Clip = new Region(new Rectangle(0,0,s.Width,s.Height));
                                    this.DrawNow=true;
                                    this.chkWm_Size=false;
                                    this.checkDrawPaint=false;
                                    //Trace.WriteLine("In Size Handle");
                                    IsWMSizeProcessed=true;
                                    RepaintObjects(-1);
                                }
                                else
                                {
                                    if((this.IsWMSizeProcessed==false))
                                    {
                                        if(this.bScrollDraw==false)
                                        {
            //											if(this.IsScrollProcessed==true)
            //											{
                                                Win32.USER32.RECT update = new Win32.USER32.RECT();
                                            if(Win32.USER32.GetUpdateRect(browserHandle,ref update,
                                                false)==0)
                                            {
                                                //Trace.WriteLine("there is no Update Region Is available");
                                            }
                                            else
                                            {

                                                if(this.IsPaintingStarted==true)
                                                {
                                                    IsPaintingStarted=false;
                                                    this.DrawNow=true;
                                                    RepaintObjects(-1);
                                                    //Trace.WriteLine("Update Region is available for painting");
                                                    this.IsPaintingStarted=true;
                                                }
                                            }
            //											}
                                        }
                                    }
                                    else
                                    {
                                    //	if(this.IsScrollProcessed==true)this.IsScrollProcessed=false;
                                        if(this.IsWMSizeProcessed==true)this.IsWMSizeProcessed=false;
                                    }
                                }
            //								if((DrawNow) && (this.bScrollDraw==true))
            //								{
            //								//	this.bScrollDraw=true;
            //									if(showAnnotations)
            //									{
            //										//System.Diagnostics.Debug.Write("calling from mywnd proc\n");
            //										//RepaintObjects(-1);
            //									}
            //								}

                            }
                            catch(Exception ex)
                            {
                                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: WebSharing  private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)",ex,"",false);
                            }
                            Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
                            return 0;
                            #endregion
                        case Win32.USER32.WM_RBUTTONDOWN:
                            return 0;
                        case Win32.USER32.WM_RBUTTONDBLCLK:
                            return 0;
                            #region case WM_LBUTTONDOWN:

                        case Win32.USER32.WM_LBUTTONDOWN:
                            try
                            {
                                haveFrames = false;
                                if((haveFrames) && (!IsExcel))
                                    return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
                                if((addAnnotations) && ( navigationCompleted))
                                {

                                    Point p = new Point();
                                    Win32.USER32.GetCursorPos(ref p);
                                    Win32.USER32.ScreenToClient(browserControl.Handle.ToInt32(), ref p);

                                    Size s = browserControl.ClientSize;
                                    int pixels = Win32.USER32.GetSystemMetrics(Win32.USER32.SM_CXVSCROLL)+2 ;
                                    int pixels2 = Win32.USER32.GetSystemMetrics(3);

                                    s.Width -= pixels ;
                                    s.Height -= pixels ; // by kamran

                                    if(IsExcel)
                                    {
                                        if(haveFrames)
                                        {
                                            int nHeight = GetExcelLowerFrameHeight(browserControl);
                                            s.Height -= nHeight;
                                        }

                                    }

                                    if(p.X > s.Width)//, 384
                                    {
                                        InvalidMousedown = true;
                                        return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
                                    }
                                    if(p.Y > s.Height)
                                    {
                                        InvalidMousedown = true;
                                        return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);

                                    }
                                    InvalidMousedown = false;
                                    OnMouseDown(p);
                                    ButtonPressed= true;
                                    return 0;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            catch(Exception ex)// ee)
                            {
                                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: WebSharing  private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)",ex,"",false);
                            }
                            break;
                            #endregion
                            #region case WM_MOUSEMOVE:
                        case Win32.USER32.WM_MOUSEMOVE:

                            if((haveFrames) && (!IsExcel))
                                return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);

                            Point p2 = new Point();
                            Win32.USER32.GetCursorPos(ref p2);
                            Win32.USER32.ScreenToClient((int)browserHandle,ref p2);
                            FireMouseMove(p2.X,p2.Y);

                            if((addAnnotations)&& ( navigationCompleted))
                            {
                                bool once=false;
                                if(ButtonPressed)
                                {
                                    Point  p1 = new Point();
                                    Win32.USER32.GetCursorPos(ref p1);
                                    Win32.USER32.ScreenToClient(browserControl.Handle.ToInt32(), ref p1);
                                    //bOnlyDrawParent = true;
                                    if(this.tool==WhiteboardToolCode.Eraser)
                                    {

                                        OnMouseMove(p1);
                                        return 0;
                                    }

                                    if(this.tool != WhiteboardToolCode.Pencil)
                                    {
                                        //browserControl.Refresh();
                                        //this.Refresh();
                                        OnMouseMove(p1);
                                        //this.Refresh();
                                    }
                                    else
                                        OnMouseMove(p1);
                                    if(this.tool == WhiteboardToolCode.Text)
                                        ButtonPressed=false;

                                    return 0;
            //									Point  p1 = new Point();
            //									GetCursorPo s(ref p1);
            //									ScreenToClient(browserControl.Handle.ToInt32(), ref p1);
            //									//bOnlyDrawParent = true;
            //									if(WebMeeting.Client.ClientUI.getInstance().tabBody.SelectedTab.Title=="Web Sharing")
            //									{
            //										browserControl.Refresh();
            //										//this.Refresh();
            //										OnMouseMove(p1);
            //									}
            //									else
            //									{
            //										browserControl.Refresh();
            //										OnMouseMove(p1);
            //									}
            //									if(this.tool == WhiteboardToolCode.Text)
            //										ButtonPressed=false;
            //
            //									return 0;
                                }
                                if(bBlockMouseMovment)
                                    return 0;
                            }
                            break;
                            #endregion
                            #region case WM_LBUTTONUP:

                        case Win32.USER32.WM_LBUTTONUP:

                            if((haveFrames) && (!IsExcel))
                                return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
                            if(InvalidMousedown)
                                return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);

                            if((addAnnotations)&& ( navigationCompleted))
                            {
                                Point p1 = new Point();
                                Win32.USER32.GetCursorPos(ref p1);
                                Win32.USER32.ScreenToClient(browserControl.Handle.ToInt32(),ref p1);

                                //Excel Check
                                if(IsExcel)
                                {
                                    if(haveFrames)
                                    {
                                        int nHeight = GetExcelLowerFrameHeight(browserControl);
                                        Size s = browserControl.ClientSize;
                                        int pixels = Win32.USER32.GetSystemMetrics(Win32.USER32.SM_CXVSCROLL)+2 ;
                                        int pixels2 = Win32.USER32.GetSystemMetrics(3);

                                        s.Width -= pixels ;
                                        s.Height -= pixels ; // by kamran

                                        s.Height -= nHeight;

                                        if(p1.Y > s.Height)
                                            return 0;
                                    }
                                }
                                //OnMouseMove(p1);
                                if(this.tool == WhiteboardToolCode.Eraser)
                                    this.sendEraserPacket();
                                else if(this.tool == WhiteboardToolCode.Brush)
                                {
                                    this.sendBrushPacket();

                                }
                                else if(this.tool != WhiteboardToolCode.Pencil)
                                {
                                    if(this.tool!= WhiteboardToolCode.Text)
                                        NewOnMouseUp(p1);
                                }
                                else
                                {
                                    sendPencilPacket();
                                    //Trace.WriteLine("PENCIL MESSAGE COUNT" + this.msgPencilMessage.endPoints.Count.ToString()  );
                                }
                                //OnMouseUp(p1);

                                ButtonPressed= false;
                                //System.Diagnostics.Debug.Write("calling wm_paint from mywndproc");
                                Win32.USER32.PostMessage(hWnd,Win32.USER32.WM_PAINT,new IntPtr(),new IntPtr());	// by kamran

                                return 0;
                            }
                            else
                            {
                                break;
                            }
                            #endregion
                        default:
                            break;
                    }
                }
                catch(Exception ex)
                {
                    WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: WebSharing  private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)",ex,"",false);

                }
            }
            catch(Exception ex)// ee)
            {
                WebMeeting.Client.ClientUI.getInstance().ShowExceptionMessage("Module ::: WebSharing  private int MyWndProc(IntPtr hWnd, int Msg, int wParam, int lParam)",ex,"",false);
            }
            return Win32.USER32.CallWindowProc(oldWndProc, hWnd, Msg, wParam, lParam);
        }