NO

Author Topic: Catch22 Splitter modified for Horizontal and Vertical splitter  (Read 5195 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2098
Catch22 Splitter modified for Horizontal and Vertical splitter
« on: January 14, 2013, 03:57:41 PM »
Here is Catch22 Splitter modified for Horizontal and Vertical splitter.
Still need some work to show splitter correctly.
« Last Edit: January 15, 2013, 06:07:32 PM by timovjl »
May the source be with you

sergey

  • Guest
Re: Catch22 Splitter modified for Horizontal and Vertical splitter
« Reply #1 on: January 15, 2013, 05:37:30 PM »
Possibly I have tired the author (timovjl) with the questions on a divider of windows:
http://forum.pellesc.de/index.php?topic=5099.0
and it has made an example with two dividers.

This example perfectly works with usual child windows in Pelles-C
Of what I also was convinced.
Thanks, timovjl!!!

My program creates 3 specific windows from LiteCAD.dll over lcCreateWindow()
Window-resizing and some callbacks is also from LiteCAD.dll
lcCreateXXXXwin(), lcWndSetXXXXwin(), lcPropwinResize(), lcWndResize(), lcCmdwinResize()

Therefore I have made specific for LiteCAD.dll changes:

1. Changes for splitter in function LRESULT CALLBACK WndProc ()
   case WM_CREATE:
      lcWndRedraw( hLcWnd );
      break;
   case WM_SIZE:
      Resize( wParam, LOWORD(lParam), HIWORD(lParam), true );
      return 0;
/* ================= new SPLITTER: DIVIDE-CURSOS ==================== */
        case WM_LBUTTONDOWN:
      Splitter_OnLButtonDown(hWnd, message, wParam, lParam);
      return 0;
        case WM_LBUTTONUP:
      Splitter_OnLButtonUp(hWnd, message, wParam, lParam);
      return 0;
        case WM_MOUSEMOVE:
      Splitter_OnMouseMove(hWnd, message, wParam, lParam);
      return 0;
/* ============== END of new SPLITTER: DIVIDE-CURSOS ================= */

2. for CAD-specific windows (lcCreateWindow() also from LiteCAD.dll)
Instead: create in calllback-function LRESULT CALLBACK WndProc()
         case WM_CREATE: hwndChild1 = CreateWindowEx()
         ... ... ...

Used: BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
  hInst = hInstance; // Store instance handle in our global variable
   //SNK: Create MAIN window
   hwMain = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL );
... ... ...
  // StatusBar
  hwStatBar = CreateWindow( STATUSCLASSNAME, TEXT("NULL"), WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, \
      0,0,60,20, hwMain, (HMENU)101, hInstance, NULL );
... ... ...
  SendMessage (hwStatBar, SB_SETPARTS, (WPARAM)2, (LPARAM)Parts );

  // define functions for events processing
  lcOnEventMouseMove( EventMouseMove );
  // create LiteCAD design window
  hLcWnd = lcCreateWindow( hwMain, LC_WS_DEFAULT | LC_WS_VIEWTABS, 8, 8, 400, 400 );
  lcWndSelectView(hLcWnd,0);
  // Command line window
  hLcCmd = lcCreateCmdwin( hwMain, 8, 8, 400, 400 );
  // Properties window
  hLcProp = lcCreatePropwin( hwMain, 8, 8, 400, 400 );

  // create a drawing
  hLcDrw = lcCreateDrawing();
  lcDrwNew( hLcDrw, L"", hLcWnd );
  lcWndSetCmdwin( hLcWnd, hLcCmd );
  lcWndSetPropwin( hLcWnd, hLcProp );

  ShowWindow( hwMain, nCmdShow );
  UpdateWindow( hwMain );
  lcWndSetFocus( hLcWnd ); 
  return TRUE;
}

3. Instead: void SizeWindowContents(int nWidth, int nHeight)

Used: void Resize (int SizeType, int nWidth, int nHeight, BOOL bFromEvent)
{
  int Hsb;
  int  DivSize = 3;  // Changed by SNK
  RECT rc;

  if (SizeType == SIZE_MINIMIZED){
    return;
  }
  if (nWidth==0 && nHeight==0){
    return;
  }
  // Statusbar position
  SendMessage( hwStatBar, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELONG(nWidth, nHeight) );
  GetWindowRect( hwStatBar, &rc );
  Hsb = rc.bottom - rc.top + 1;
  // Design window position
  lcWndResize( hLcWnd, nSplitterPosX + nSplitterBorder, 0, nWidth-nSplitterPosX-nSplitterBorder, nSplitterPosY);
  // "Command Line" position
  lcCmdwinResize( hLcCmd, nSplitterPosX + nSplitterBorder, nSplitterPosY + nSplitterBorder, nWidth-nSplitterPosX-nSplitterBorder, nHeight-nSplitterPosY-nSplitterBorder - Hsb );
  // "Properties" window position
  lcPropwinResize( hLcProp, 0, 0, nSplitterPosX, nHeight - Hsb );
}

But without an example Splitter2_2.zip from timovjl I couldn't solve this problem.
Once again thanks timovjl for its attention and patience.