NTK and The NTK Project
are properties of Jn Dechereux
Home | Documentation | FAQ.
Vanilla 1.1.8 is a product of Lussumo. More Information: Documentation, Community Support.
. . . #include "ntkdll.ch" Static hStatusBar Func Main() . . . CREATE WINDOW hWnd TITLE ... . . . ACTIVATE WINDOW hWnd NORMAL hStatusBar := CreateStatusWindow( WS_CHILD+WS_VISIBLE, "Your status bar message.", hWnd, WM_USER+100 ) AUTO HANDLE EVENTS OF WINDOW hWnd . . . CLOSE WINDOW hWnd Return(Nil) /* change statusbar message */ Func SetStatusBarMsg(hWndSB, cNewMsg) Return( NTK_SetWindowText(hWndSB, cNewMsg) ) /* wrapper for external C/Win32 API */ _DLL FUNCTION CreateStatusWindow( style as long, lpsztext as lpctstr, hwndParent as handle, wID as uint ); AS HWND PASCAL:Comctl32.CreateStatusWindowA
. . . ACTIVATE WINDOW hWnd NORMAL //hStatusBar := CreateStatusWindow( WS_CHILD+WS_VISIBLE+SBT_TOOLTIPS, nil, hWnd, WM_USER+100 ) // Same as previous, but more Win32/64 hStatusBar := NTK_CreateWindowEx(0,; STATUSCLASSNAME,; NIL,; WS_CHILD+WS_VISIBLE+SBT_TOOLTIPS+SBARS_SIZEGRIP,; 0,; 0,; 0,; 0,; hWnd, WM_USER+100 ) // Change default height, if needeed. NTK_SendMessage(hStatusBar, SB_SETMINHEIGHT, 50, 0) // e.g. 50 pixel height NTK_SendMessage(hStatusBar, WM_SIZE, 0 , 0 ) /* Define the background color */ //NTK_SendMessage(hStatusBar, SB_SETBKCOLOR, 0, NTK_RGB(0,0,255) ) // Blue /* Create 4 panels */ paSBWidthParts := __NTKA2BIN( {110,200,800,-1} , "int,int,int,int") // Size of each pane in pixel /* paSBWidthParts := L2BIN(100)+L2BIN(200)+L2BIN(800)+L2BIN(-1) // same as previous */ NTK_SendMessage(hStatusBar, SB_SETPARTS, 4, @paSBWidthParts ) /* Set Pane 1 */ NTK_SendMessage(hStatusBar, SB_SETTEXT, 0, "Status Part 0...") NTK_SendMessage(hStatusBar, SB_SETTIPTEXT, 0, "Help on part 0") hIcon := NTK_LoadIcon(nil, IDI_EXCLAMATION) // Windows stockobject NTK_SendMessage(hStatusBar, SB_SETICON, 0, hIcon ) /* Set Pane 2 */ //NTK_SendMessage(hStatusBar, SB_SETTEXT, 1, "Status Part 1" ) NTK_SendMessage(hStatusBar, SB_SETTIPTEXT, 1, "Help on part 1") hIcon := NTK_LoadIcon(nil, IDI_ASTERISK) // Windows stockobject NTK_SendMessage(hStatusBar, SB_SETICON, 1, hIcon ) /* Set Pane 3 */ NTK_SendMessage(hStatusBar, SB_SETTEXT, 2, "Status Part 2") hIcon := NTK_LoadIcon(nil, IDI_HAND) // Windows stockobject NTK_SendMessage(hStatusBar, SB_SETICON, 2, hIcon ) /* Set Pane 4 */ NTK_SendMessage(hStatusBar, SB_SETTEXT, 3, Time()) /* Ensure our statusbar is correctly displayed */ NTK_ShowWindow(hStatusBar, SW_SHOW) AUTO HANDLE EVENTS OF WINDOW hWnd . . .
... Static hStatusBar Static aSB_PaneColor := { {0, "", NTK_RGB(255,0,0), TRANSPARENT } ,; // Pane #1: Red / Transparent {1, "", NTK_RGB(0,255,0), TRANSPARENT } ,; // Pane #2: Green / Transparent {2, "", NTK_RGB(0,0,255), TRANSPARENT } ,; // Pane #3: Blue / Transparent {3, "Colored text!", NTK_RGB(0,128,128), TRANSPARENT } ,; // Pane #4: DKCyan / Transparent } FUNCTION MAIN() . . . CREATE WINDOW hWnd ; TITLE "my window with a statusbar" ; STYLE WS_OVERLAPPEDWINDOW; ON MSG DoEventHandler(); ON PAINT DoRePaint() . . . hStatusBar := NTK_CreateWindowEx(0,; STATUSCLASSNAME,; NIL,; WS_CHILD+WS_VISIBLE+SBT_TOOLTIPS+SBARS_SIZEGRIP,; 0,; 0,; 0,; 0,; hWnd, WM_USER+100 ) // Change default height NTK_SendMessage(hStatusBar, SB_SETMINHEIGHT, 50, 0) // e.g. 50 pixel height NTK_SendMessage(hStatusBar, WM_SIZE, 0 , 0 ) . . . /* Set Pane 3 */ NTK_SendMessage(hStatusBar, SB_SETTEXT, 2, "Status Part 2") hIcon := NTK_LoadIcon(nil, IDI_HAND) // Windows stockobject NTK_SendMessage(hStatusBar, SB_SETICON, 2, hIcon ) /* Set Pane 4 */ /* NTK_SendMessage(hStatusBar, SB_SETTEXT, 3, Time()) */ // change statusbar style to make it Owner-drawn // according to MSDN documentation you might be tempted to write: // NTK_SendMessage(hStatusBar, SB_SETTEXT, NTK_MakeWParam( NTK_MakeWord(3,SBT_OWNERDRAW), NULL), Time()) ) // this will not work. by appearances, the SBT_ styles are defined so that they will automatically appear // in the high byte of the low word if you just OR them with your index value. // MS doc is sometimes a real nightmare! // this one works properly: NTK_SendMessage( hStatusBar, SB_SETTEXT, SBT_OWNERDRAW+3, Nil ) /* Ensure our statusbar is correctly displayed */ NTK_ShowWindow(hStatusBar, SW_SHOW) . . . CLOSE WINDOW hWnd Return(nil) // end of main Function DoEventHandler(hWnd, nMsg, nWParam, nLParam) IF nMsg == WM_DRAWITEM // according to MS documentation, the nlParam contains the lpDrawItemStruct If SB_SetPaneColor( nlParam, aSB_PaneColor ) // according to MS documentation, TRUE means we processed the message Return(1) Endif ELSEIF nMsg==WM_SIZE // parent window size has changed //nSizeType := nWParam // resizing flag: SIZE_MAXIMIZED, SIZE_* //nWidth := NTK_LoWord(nLParam) // width of parent client area //nHeight := NTK_HiWord(nLParam) // height of parent client area // auto-adjust our statusbar to the parent new size NTK_MoveWindow( hStatusBar, nil,nil,nil,nil, .T. ) Return(0) // zero means we processed the message ENDIF Return( NTK_DefWindowProc(hWnd, nMsg, nWParam, nLParam) ) Function SB_SetPaneColor( lpDrawItemStruct, aPaneColor ) Local aDrawItemStruct := NTK_DRAWITEM2A(lpDrawItemStruct) // see DRAWITEM/DIS structure members in NTKGDI.CH Local hStatBar := aDrawItemStruct[DIS_hwndItem] // the handle to our statusbar Local nPaneID := aDrawItemStruct[DIS_itemID] // the pane index in which the OS is ready to draw Local hDC := aDrawItemStruct[DIS_hDC] // a valid DC to the window statusbar Local nLeft := aDrawItemStruct[DIS_rcLeft] // // x offset -- Local nTop := aDrawItemStruct[DIS_rcTop] // y offset | the pane rectangle Local nRight := aDrawItemStruct[DIS_rcRight] - nLeft // width | coordinates Local nBottom := aDrawItemStruct[DIS_rcBottom] - nTop // height -- Local nPos // retrieve color information about pane being drawn nPos := ASCAN( aPaneColor, { |x| x[1]==nPaneID .AND. !EMPTY(x[2]) } ) IF nPos>0 // draw text in the pane @ nTop+2, nLeft+2 SAY aPaneColor[nPos, 2] SIZE nBottom-2, nRight-2 ; STYLE DT_CENTER+DT_VCENTER+DT_SINGLELINE ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR aPaneColor[nPos, 3] ; BACKCOLOR aPaneColor[nPos, 4] ; INTO CONTEXT hDC ELSE // no specific color information found for this nPaneID // so do nothing. ie. standard behaviour RETURN(.F.) ENDIF Return(.T.)
#include "windows.ch" #include "ntkacc.ch" #include "ntkcmd.ch" #include "ntkcmdex.ch" #include "wNtk.ch" #include "wNtkKeys.ch" FUNCTION MAIN() LOCAL hWndMain LOCAL cWinTitle := "Basic Header & Status bars" CREATE WINDOW hWndMain; TITLE cWinTitle; STYLE WS_OVERLAPPEDWINDOW; AT 0,0 SIZE CW_USEDEFAULT, CW_USEDEFAULT; ON PAINT DoMainRePaint() ACTIVATE WINDOW hWndMain CENTER AUTO HANDLE EVENTS OF WINDOW hWndMain CLOSE WINDOW hWndMain RETURN //////////////////////////////////////////////////////////////////////////// FUNCTION DoMainRepaint(hWnd, message, nwParam, nlParam, hDC) Local nMaxRow := __NtkMaxRow(hWnd) Local nMaxCol := __NtkMaxCol(hWnd) Local hBmpResize := NTK_LoadBitmap(NULL, OBM_SIZE) Local hIconAlert := NTK_LoadIcon(NULL, IDI_EXCLAMATION) Local nHHB := 45 // Header bar height Local nHSB := 35 // Status bar height //////////////////////////////////////////////////////////////////////////////////////////////// // Draw the Header Bar //////////////////////////////////////////////////////////////////////////////////////////////// SET RGB COLOR TEXT NTK_RGB(255,128,0) BACK NTK_RGB(100,100,100) @ 0,0 SAY ">>> Header bar Title <<<" SIZE nHHB, nMaxCol; STYLE DT_SINGLELINE+DT_CENTER+DT_VCENTER; FONT NTK_GetStockObject(SYSTEM_FONT); INTO CONTEXT hDC //////////////////////////////////////////////////////////////////////////////////////////////// // // Some code here... // //////////////////////////////////////////////////////////////////////////////////////////////// // Draw a pseudo 3D raised Status Bar //////////////////////////////////////////////////////////////////////////////////////////////// @ nMaxRow-nHSB,1 , nMaxrow,nMaxCol BOX NTK_BXS_3DRAISED INTO CONTEXT hDC COLOR "N+/N+" // SB Part one SET COLOR TO N/T @ nMaxRow-nHSB,4 SAY ICON HANDLE hIconAlert INTO CONTEXT hDC @ nMaxRow-(nHSB-2),2 SAY "Part 1 - some text..."; SIZE (nHSB-2),200 FONT NTK_GetStockObject(ANSI_VAR_FONT); STYLE DT_SINGLELINE+DT_CENTER+DT_VCENTER; INTO CONTEXT hDC // SB Part two @ nMaxRow-(nHSB-2),200, nMaxrow-2,202 BOX NTK_BXS_3DRAISED INTO CONTEXT hDC COLOR "N+/N+" SET COLOR TO B/T @ nMaxRow-(nHSB-2),210 SAY "Part 2 - blah, blah, blah, blah"; SIZE (nHSB-2),200 FONT NTK_GetStockObject(ANSI_VAR_FONT); STYLE DT_SINGLELINE+DT_CENTER+DT_VCENTER; INTO CONTEXT hDC // SB Part three @ nMaxRow-(nHSB-2),nMaxCol-97, nMaxrow-2,nMaxCol-95 BOX NTK_BXS_3DRAISED INTO CONTEXT hDC COLOR "N+/N+" SET COLOR TO R+/T @ nMaxRow-(nHSB-2),nMaxCol-100 SAY Time(); SIZE (nHSB-2),100 FONT NTK_GetStockObject(SYSTEM_FONT); STYLE DT_SINGLELINE+DT_CENTER+DT_VCENTER; INTO CONTEXT hDC @ nMaxRow-20,nMaxCol-20 SAY BITMAP HANDLE hBmpResize; TRANSPARENCY BY NTK_RGB(240,240,240); INTO CONTEXT hDC NTK_DeleteObject(hIconAlert) NTK_DeleteObject(hBmpResize) //////////////////////////////////////////////////////////////////////////////////////////////// RETURN(0)
FUNCTION MYWNDPROC( hWnd, nMessage, nwParam, nlParam) Local aPS := ARRAY(PS_LENGTH) // see NTKGDI.CH Local hDC Local aRect DO CASE CASE message == WM_CREATE // Do some code here RETURN(0) // Inform MS-Windows we've processed the message. CASE message == WM_PAINT hDC := NTK_BEGINPAINT( hWnd, aPS ) aRect := NTK_GetClientRect(hWnd) NTK_TextOut( hDC, 10, 10 Hello: Time is "+Time() ) NTK_ENDPAINT( hWnd, aPS ) RETURN(0) CASE message == WM_DESTROY NTK_PostQuitMessage(0) RETURN(0) ENDCASE // Default processing of all the other messages... RETURN( NTK_DefWindowProc(hWnd, nMessage, nwParam, nlParam) )
CREATE WINDOW hWndMain TITLE 'My Main' STYLE WS_OVERLAPPEDWINDOW; ON INIT DoInitProc(); // Response to the WM_CREATE message ON PAINT DoPaintProc(); // Response to the WM_PAINT message ON MSG DoWndProc(); // User Defined proc for processing other WM_* messages ON EXIT DoExitProc() // Response to the WM_DESTROY message
. . . FUNCTION MAIN() . . . CREATE WINDOW hWndMain TITLE 'My Main' STYLE WS_OVERLAPPEDWINDOW; ON PAINT DoPaintProc() ACTIVATE WINDOW hWndMain NORMAL AUTO HANDLE EVENTS OF WINDOW hWndMain CLOSE WINDOW hWndMain RETURN // End of main. Procedure DoPaintProc(hWnd, nMsg, nWParam, nLParam, hDC) SET COLOR TO R+/W @ 10,50 SAY Hello: Time is "+Time() SIZE 30,200 INTO CONTEXT hDC RETURN(0)
NTK_InvalidateRect(hWndMain) // Refresh the whole window // Only refresh the Time() area NTK_InvalidateRect(hWndMain, {50,10,200,30}, .T.) NtkRePaint(hWnd, 10,50,40,250) NtkRePaint(hWnd, 10,50,40,250, .T.) // less flicking REFRESH SCREEN OF hWndMain FROM 10,50 TO 30,200
@ 10,10 SAY Hello: Time is "+Time() SIZE 30,200 INTO WINDOW hWndMain
1 to 21 of 21