******************************************************************************** * Program : SPLITTER.PRG * Launch SPLITTER.EXE * Aim : Show how to program Applications using Windows traditional manner, * ..........: with NTKCORE GUI (low level) set of functions for X/HARBOUR. * ..........: Here is a little sample to illustrate a simple 'Splitter Windows' management * Make......: Juste type MK splitter * Date : 29/03/05 * Author(s) : Jn DECHEREUX * Copyright : (c) 2005 - Jn DECHEREUX. Tous droits r‚serv‚s/All Rights Reserved. ******************************************************************************** * Remark: * I have to confess that English is not mother tongue. So, in case of * typo or misspelling, don't be too angry - just bear with me. * You have to know that i'll do consider any comment, correction, suggestion * with great pleasure and high kindliness. Just be polite ! ;-) * This remark is also available for bug notifications or any other kind of * contributions that can improve my product... ******************************************************************************** #include "\wntk4hrb\include\windows.ch" #include "\wntk4hrb\include\ntkgdi.ch" #include "\wntk4hrb\include\ntkmsg.ch" #include "\wntk4hrb\include\ntkacc.ch" #include "\wntk4hrb\include\wNtk.ch" #xtranslate MAKELONG(,) => (() + () * 65536) #define MAKELPARAM(nLow, nHigh) ((nLow) + (nHigh) * 65536) STATIC hCursor STATIC lSplitterMoving STATIC nSplitterPos STATIC hWnd1, hWnd2 STATIC hInst STATIC hIcon STATIC hCurs STATIC hBrush STATIC cWinTitle STATIC hWndDemo FUNCTION MAIN() LOCAL cMsg LOCAL NTK_aMSG := { 0,0,0,0,0,0,0 } // 7 elements, see NTKMSG.CH hInst := NTK_GetInstance() hIcon := NTK_LoadIcon( Nil , IDI_HAND) // IDI_APPLICATION) hCurs := NTK_LoadCursor( Nil , IDC_ARROW) hBrush := NTK_GetStockObject(LTGRAY_BRUSH) cWinTitle := "Splitter Example with NTKCore for X/HRB !" IF !NTK_RegisterClassEx( CS_HREDRAW + CS_VREDRAW,; // CS_OWNDC + CS_VREDRAW + CS_HREDRAW + CS_DBLCLKS,; hInst,; hIcon,; hCurs,; hBrush,; "NTKFEN",; { |hWnd, message, nwParam, nlParam|; SPLITWNDPROC(hWnd, message, nwParam, nlParam) } ) NTK_MsgBox( , "Can't register NTKFEN class..." ) RETURN Nil ENDIF hWndDemo = NTK_CreateWindow( "NTKFEN", cWinTitle, ; WS_OVERLAPPEDWINDOW + WS_CLIPCHILDREN,; 0, 0, 640, 480 ) // F_MIN+F_MAX+WS_SYSMENU,; IF hWndDemo == 0 NTK_MsgBox( , "Can not create Main Window..." ) RETURN Nil ENDIF NTK_ShowWindow( hWndDemo, SW_SHOW ) NTK_UpdateWindow( hWndDemo ) // ---------------------------------- NTK's Main Events (Windows Msg) Loop DO WHILE NTK_GetMessage( NTK_aMSG, 0 ) //,hWndDemo,0,0 ) NTK_TranslateMessage( NTK_aMSG ) NTK_DispatchMessage( NTK_aMSG ) ENDDO NTK_SelectWindow( hWndDemo ) NTK_DestroyWindow( hWndDemo ) NTK_UnregisterClass( "NTKFEN", hInst ) RETURN ****** ****** ****** FUNCTION SPLITWNDPROC( hWnd, message, nwParam, nlParam) //LOCAL aPS := { 0,.T.,0,0,0,0,.T.,.T.,nil } // 9 elements, see NTKGDI.CH //LOCAL hDC := 0 LOCAL aRect := {} DO CASE CASE message == WM_CREATE hWnd1 := NTK_CreateWindowEx( WS_EX_CLIENTEDGE,; "edit", "Multiline edit text #1",; WS_CHILD + WS_VISIBLE + WS_CLIPSIBLINGS + ES_MULTILINE + WS_VSCROLL,; 0, 0, 0, 0,; hWnd, 1,; hInst, NULL ) hWnd2 := NTK_CreateWindowEx( WS_EX_CLIENTEDGE,; "edit", "Multiline edit text #2",; WS_CHILD + WS_VISIBLE + WS_CLIPSIBLINGS + ES_MULTILINE + WS_VSCROLL,; 0, 0, 0, 0,; hWnd, 2,; hInst, NULL ) hCursor := NTK_LoadCursor(NULL, IDC_SIZENS ) lSplitterMoving := .F. nSplitterPos := 130 RETURN(0) CASE message == WM_SIZE // // If window is shrunk so that splitter now lies outside the // window boundaries, move the splitter within the window. // IF ((nwParam != SIZE_MINIMIZED) .AND. ( NTK_HiWord(nlParam) < nSplitterPos)) nSplitterPos := NTK_HiWord(nlParam) - 10 ENDIF // Adjust the children's size and position NTK_MoveWindow(hWnd1, 0, 0, NTK_Loword(nlParam), nSplitterPos - 1, .T. ) NTK_MoveWindow(hWnd2, 0, nSplitterPos+2, NTK_LoWord(nlParam), NTK_HiWord(nlParam) - nSplitterPos - 2, .T. ) RETURN(0) CASE message == WM_MOUSEMOVE aRect := NTK_GetClientRect(hWnd) IF ( NTK_Hiword(nlParam) > 15 ) .AND.; // do not allow above those marks ( NTK_Hiword(nlParam) < aRect[RECT_Bottom] - 15 ) NTK_SetCursor(hCursor) IF ( (nwParam == MK_LBUTTON) .AND. lSplitterMoving ) If ( NTK_HiWord(nlParam) > aRect[RECT_Bottom] ) RETURN(0) Endif nSplitterPos = NTK_HiWord(nlParam) NTK_SendMessage(hWnd, WM_SIZE, 0,; MAKELPARAM(aRect[RECT_Right], aRect[RECT_Bottom]) ) ENDIF ENDIF RETURN(0) CASE message == WM_LBUTTONDOWN NTK_SetCursor(hCursor) lSplitterMoving := .T. NTK_SetCapture(hWnd) RETURN( 0 ) CASE message == WM_LBUTTONUP NTK_ReleaseCapture() lSplitterMoving := .F. RETURN( 0 ) CASE message == WM_CHAR IF nwParam==27 // K_ESC IF NTK_MsgBox( hWnd,; "Do you really want to quit ?",; "Your Attention Please !",; MB_OKCANCEL+MB_ICONQUESTION ) == IDOK NTK_PostQuitMessage(0) ENDIF ENDIF CASE message == WM_RBUTTONDOWN IF NTK_MsgBox( hWnd,; "Do you really want to quit ?",; "Your Attention Please !",; MB_OKCANCEL+MB_ICONQUESTION ) == IDOK NTK_PostQuitMessage(0) RETURN(0) ENDIF CASE message == WM_SYSCOMMAND IF nwParam == SC_CLOSE // system menu double click, or Alt-F4 IF NTK_MsgBox( hWnd,; "Do you really want to quit ?",; "Your Attention Please !",; MB_OKCANCEL+MB_ICONQUESTION ) == IDOK tone(130,1) tone(130,1) NTK_PostQuitMessage(0) ENDIF RETURN(0) // According to M$ Win32 SDK Doc. We tell Windows we've processed the message ENDIF CASE message == WM_PAINT //hDC := NTK_BEGINPAINT( hWnd, aPS ) // //NTK_ENDPAINT( hWnd, aPS ) CASE message == WM_DESTROY NTK_PostQuitMessage(0) RETURN(0) ENDCASE RETURN( NTK_DEFWNDPROC(hWnd, message, nwParam, nlParam) ) //RETURN -1 // OR NTK_DEFWNDPROC( ... ) is the same ! ****** ****************************************************************************************** ****** ****** ******