********************************************************************************* * Program : GETDMO.PRG * Launch GETDMO.EXE * Aim : Show how to mount in 5 mn a quick application using NTKCORE's * ..........: R.A.D. commands. Over all, the purpose is to explore a alternative * ..........: way to mask/hide (or not) the Win32 message pump implementation... * ..........: Enjoy this sample and feel free to adapt/enhance/improve it ! * Make......: Juste type MKRAD GETDMO * Date : 01/08/05 * Author(s) : Jn Dechereux. Based on a idea from Sylvain Pasquet. Yes we can ! * 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 "windows.ch" #include "ntkbtn.ch" #include "ntkcctrl.ch" #include "ntkgdi.ch" #include "ntkmsg.ch" #include "ntkacc.ch" #include "ntkdlg.ch" #include "ntkmenus.ch" #include "ntkedget.ch" #include "ntkcmd.ch" #include "ntkshell.ch" #include "wNtk.ch" #include "wNtkKeys.ch" #define ID_BTN1 8001 // unique id (used for the Push Button) #define ID_BTN2 8002 // unique id (used for the Push Button) #define ID_GETEDIT1 7001 // unique id (used for the get control) #define ID_GETEDIT2 7002 // unique id (used for the get control) #define ID_GETEDIT21 7021 // unique id (used for the get control) #define ID_GETEDIT3 7003 // unique id (used for the get control) #define ID_GETEDIT4 7004 // unique id (used for the get control) #define ID_GETCHK5 7005 // unique id (used for the get control) #define ID_GETLBOX6 7006 // unique id (used for the get control) #define ID_GETCBOX7 7007 // unique id (used for the get control) #define ID_GETRB8 7008 // unique id (used for the get control) #define ID_GETRB9 7009 // unique id (used for the get control) #define ID_GETRB10 7010 // unique id (used for the get control) #define ID_GETRB11 7011 // unique id (used for the get control) #define ID_GETRB12 7012 // unique id (used for the get control) #define ID_GETRB13 7013 // unique id (used for the get control) #define CR CHR(13) STATIC aGetFont STATIC hGetFont STATIC hGreenBrush STATIC hBtn1 FUNCTION MAIN() LOCAL cMsg LOCAL hInst := NTK_GetInstance() LOCAL hIcon := NTK_LoadIcon( Nil , IDI_HAND ) // IDI_APPLICATION) LOCAL hCurs := NTK_LoadCursor( Nil , IDC_ARROW) LOCAL hBrush := NTK_GetStockObject(LTGRAY_BRUSH) // LTGRAY_BRUSH, WHITE_BRUSH... LOCAL cWinTitle := "NTKCore sample application : Edit/get controls" LOCAL lGetUpdated, lOldReadState, lOldGetMode LOCAL lMenRet PRIVATE aGetList := {} // Must be here! PRIVATE aBtnList := {} // Must be here! PRIVATE cVar1, nVar2, nVar21, dVar3, cVar4, lVar5, aVar6, cVar7 PRIVATE lVar8, lVar9, lVar10 PRIVATE lVar11, lVar12, lVar13 PRIVATE aCbChoices, aLbChoices PRIVATE hWndDemo cVar1 := "Get Me in Upper-case please ! " cVar1 := cVar1 + SPACE( MAX_PATH-LEN(cVar1) ) nVar2 := 123.53 nVar21 := 25 dVar3 := CTOD("01/11/2002") ***dVar3 := CTOD("2002/11/01") // Japenese date cVar4 := "This is a memo in a multi-lines Edit-Get..." lVar5 := .T. // check me aVar6 := { "Banana", "Peach" } aLbChoices := { "Plum", "Banana", "Apple", "Peach", "Apricot" } // or only "Orange" cVar7 := "Potatoes" aCbChoices := { "Spinash", "Potatoes", "Carrots", "Tomatoes"} // or only "Radish" aCbChoices := { "Spinash", "Potatoes", "Carrots", "Tomatoes", "Radish", "Spinash", "Potatoes", "Carrots", "Tomatoes"} // or only "Radish" lVar8 := .F. lVar9 := .T. // RB Medium is the default selection lVar10 := .F. lVar11 := .F. lVar12 := .F. lVar13 := .T. // RB Medium is the default selection hGreenBrush := NTK_CreateSolidBrush( NTK_RGB( 000,128,000) ) //hGreenBrush := NTK_GetStockobject( WHITE_BRUSH ) // ----- If you need a Dos-like font, just load NTK-Dos for Clipper fixed font... NTK_AddFontResource( "NTK08X16.FON" ) // Thx to Marco Selli & JNE for their great contribution... //aGetFont:= {-16,8,0,0,0, .F., .F., .F., 1, 0, 0, 0, 0, "NTK08X16" } //aGetFont:= {-12,06,0,0,0, .F., .F., .F., 1, 0, 0, 0, 0, "TIMES NEW ROMAN" } aGetFont:= {-18,10,0,0,0, .F., .F., .F., 1, 0, 0, 0, 0, "ARIAL" } hGetFont := NTK_CreateFont( aGetFont ) // just look at font definitions in WINDOWS.CH IF hGetFont == 0 NTK_MsgBox( , "Cannot create this font..." ) RETURN Nil ENDIF // ----- Ensure that the common control dynamic-link library (DLL) is loaded. // ----- Don't forget to use this command if U plan to use controls such as DatePicker, tooltips... NTK_InitCommonControlsEx( ICC_DATE_CLASSES + ICC_BAR_CLASSES + ICC_STANDARD_CLASSES + ICC_WIN95_CLASSES ); CREATE WINDOW hWndDemo ; TITLE "Sample" ; AT 0,0 SIZE 640,480 ; ON INIT DoInit() ; // The 4 following clauses can be used with ON PAINT DoRePaint() ; // code block or function using or not ON EXIT DoExit() ; // facultative parameters like : ON MSG DoHandleMsg() // Just in case in we want to handle some message... hWnd, nMsg, nwParam, nlParam,... IF EMPTY( hWndDemo ) NTK_MsgBox( , "Can not create main Window..." ) RETURN Nil ENDIF SET DATE USA SET CENTURY ON SET PIXEL MODE ON // default is always ON SET DEFAULT SAY FONT TO NTK_GetStockObject(ANSI_FIXED_FONT) SET GLOBAL VALIDATION KEY TO VK_F10 // -- allow user to exit Get session by pressing Esc, PgUp, PgDn or GVK... aMenu := NtkCreateMenu() aPopupMenu := NtkCreatePopupMenu() NtkAppendMenu(aPopupMenu, "PRINT", MF_ENABLED + MF_STRING, "&Print", {|| DOABOUT(hwndDemo) }, "Output the document directly to printer." ) NtkAppendMenu(aPopupMenu, "PVIEW", MF_ENABLED + MF_STRING, "Pre&view", {|| DOABOUT(hwndDemo) }, "Create a preview of the document before printing." ) NtkAppendMenu(aPopupMenu, "", MF_SEPARATOR) NtkAppendMenu(aPopupMenu, "QUIT", MF_ENABLED + MF_STRING, "E&xit", {|| DoExit(hWndDemo) } , "Quit this program." ) NtkAppendMenu( aMenu, "FILE", MF_ENABLED + MF_POPUP, "&Files", aPopupMenu, "Files operations..." ) aPopupMenu := NtkCreatePopupMenu() NtkAppendMenu(aPopupMenu, "CUT", MF_ENABLED + MF_STRING, "&Cut", {|| DOCUT() }, "Cut a piece of document into clipboard.." ) NtkAppendMenu(aPopupMenu, "COPY", MF_ENABLED + MF_STRING, "&Copy", {|| DOCOPY() }, "Copy a piece of document into clipboard." ) NtkAppendMenu(aPopupMenu, "PASTE", MF_ENABLED + MF_STRING, "&Paste", {|| DOPASTE() }, "Paste the piece of document previously stored in the clipboard." ) NtkAppendMenu( aMenu, "EDIT", MF_ENABLED + MF_POPUP, "&Editions", aPopupMenu, "Editions : Cut, Paste and Copy..." ) NtkAppendMenu( aMenu, "ABOUT", MF_ENABLED + MF_STRING, "&?", {|| DOABOUT() }, "About this program..." ) lMenRet := NtkSetMenu(hWndDemo, aMenu) //NTK_DrawMenuBar(hWndDemo) //NTK_DrawMenuBar(hWndDemo) NTK_ShowWindow( hWndDemo, SW_SHOW ) NTK_UpdateWindow( hWndDemo ) // -- Allow or not Up/Dn/Enter Key to exit after last get lOldReadState := NTK_ReadExit( .F. ) // .F. means not allowed. So, we will loop to first get... //lOldGetMode := NTK_ReadInsert( .F. ) // Shift to overwrite mode ** With NTK RAD, you can keep on rolling with the old xBase DOS way to write code. ** But, keep in mind that a window can be destroy by another event (menu, button, thread, etc..) ** So don't use DO WHILE .T. ; a better way is to call NTK_IsWindow() ... DO WHILE NTK_IsWindow(hWndDemo) // ------------ Invoke Get Reader System //READ // Minimum declaration READ INTO hWndDemo ; // Complete declaration START FROM 1 ; BUTTON LIST aBtnList ; // Dont forget it, otherwise buttons will not be handled/managed ! MSG AT 10, 0,640 ; MSG COLOR NTK_RGB(255,000,000) ; MSG FONT NTK_GetStockObject(ANSI_VAR_FONT) // this is a hFont ** IF NTK_LastKey()==K_ESC .OR. NTK_LastKey()==NTK_GET_GVK // .OR. NTK_LastKey()==K_ALT_F4 IF NTK_LastKey()==K_ESC .OR. NTK_LastKey()==K_ALT_F4 .OR. NTK_LASTBTN()==-1 NTK_MessageBox( hWndDemo,; "Ha, ha! Seems that you're trying to escape from GETDMO.exe",; "Info!",; MB_OK + MB_ICONINFORMATION ) IF DoExit() EXIT ENDIF ELSEIF NTK_LastKey()==NTK_GET_GVK // default G.V.K is always VK_F10. It can be changed using SET GLOBAL VALIDATION KEY... command. NTK_MessageBox( hWndDemo,; "Maybe you can insert here the source code needed for validation, replace or other stuff",; "Advice!",; MB_OK + MB_ICONINFORMATION ) ENDIF ENDDO //NTK_ReadInsert( lOldGetMode ) // back to insert mode //NTK_ReadExit( lOldReadState ) // ------------------------ Destroy all Editget(s) and clear aGetList[]. Used without parameter means ALL Gets of ALL (even previous) windows. CLEAR GETS // CLEAR GETS OF hWndDemo // ------------------------ Destroy all Buttons and clear aBtnList[]. Used without parameter means ALL Btns of ALL (even previous) windows. . CLEAR BUTTONS // CLEAR BUTTONS OF hWndDemo NTK_DeleteObject( hGetFont ) NTK_RemoveFontResource( "NTK08X16.FON" ) NTK_DeleteObject( hGreenBrush ) NTK_SelectWindow( hWndDemo ) NTK_DestroyWindow( hWndDemo ) // ---------------------------------------------- Display Result Analysis. SET PIXEL MODE OFF // We want Row,Col mode (xBase old school!) @ 01, 02 SAY nVar2 PICTURE "99999.9999" // just to control @ 02, 02 SAY nVar21 PICTURE "99" // just to control SET PIXEL MODE ON // Don't Worry about this Wild Wild Way of displaying things. // At this stage our window has been destroyed, so @ ... SAY clauses // will not have other choice than to directly (or deliberately) paint // into the last immediately available window which is certainly // the Windows Desktop... RETURN ****** ****** ****** FUNCTION DoExit() // This proc. is automatically called each time our window receives a Destroy Msg or // when NTK_SendCloseEvent() is invoked... IF NTK_MsgBox( hWndDemo,; "Do you really want to quit ?",; "Your Attention Please !",; MB_OKCANCEL+MB_ICONQUESTION ) == IDOK NTK_ReadEscape() RETURN( NTK_SendQuitEvent() ) **RETURN( .T. ) // Quit ENDIF RETURN(.F.) // Do not quit, keep on current task ****** ****** ****** FUNCTION DoInit(hWnd,message,nwParam,nlParam) @ 50,50 GET cVar1 ID ID_GETEDIT1 ; PICTURE "@!@S30" ; OF hWnd ; FONT NTK_GetStockObject(ANSI_FIXED_FONT) ; TEXTCOLOR NTK_RGB(000,000,128) ; BACKCOLOR NTK_RGB(255,255,128) ; // Remember: STYLE GS_3DSUNKEN ; // add GS_READONLY, if want to disallow all keyb entries! PICK MySelfolder() ; MESSAGE "Enter a String here... You can press F4 key to try the PICK clause..." @ 50,400 GET nVar2 ID ID_GETEDIT2 ; SIZE 30,090 ; PICTURE "99999.9999" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(255,128,255) ; BACKCOLOR NTK_RGB(000,000,000) ; BACKBRUSH NTK_GetStockObject(WHITE_BRUSH) ; STYLE GS_3DTHICKSUNKEN ; MESSAGE "Enter Here a number up to 100... If you set a value up to 500, ID_GETEDIT2 will be disabled next time !" ; WHEN if( nVar2 > 500, ; NTK_SetGetState(aGetList,ID_GETEDIT2,.F.), .T. ) ; // Disable ID_GETEDIT2. Can't acces anymore, at least while its internal value is greate than 500.... VALID nVar2 > 100 @ 50,500 GET nVar21 ID ID_GETEDIT21 ; SIZE 30,050 ; TYPE GXT_NUMSPINNER ; PICTURE "99" ; FONT hGetFont ; TEXTCOLOR NTK_RGB(000,192,000) ; BACKCOLOR NTK_RGB(000,000,000) ; BACKBRUSH hGreenBrush ; STYLE GS_3DSUNKEN ; MESSAGE "Enter Here a number between -5 and 35..." ; RANGE -5,35 // STYLE GS_3DTHICKSUNKEN ; // TYPE GT_NUMERIC + GXT_SPINBOX ; @ 100,400 GET dVar3 ID ID_GETEDIT3 ; FONT hGetFont ; TEXTCOLOR NTK_RGB(255,255,255) ; BACKCOLOR NTK_RGB(255,0,0) ; STYLE GS_3DSUNKEN ; MESSAGE "Enter here a Date between 01/01/02 and 12/31/04..." ; RANGE CTOD("01.01.2002") , CTOD("12.31.2004") //RANGE "01.01.2002" , CTOD("12.31.2004") @ 100, 50 GET cVar4 ID ID_GETEDIT4 ; SIZE 200,250 ; PICTURE "@!" ; TYPE GT_MEMO ; STYLE GS_BORDER ; BACKBRUSH NTK_GetStockObject(WHITE_BRUSH) ; MESSAGE "Enter a Memo string here - Use CTRL-UP/CTRL-DN arrow to move to Prev/Next get..." @ 150, 400 GET lVar5 ID ID_GETCHK5 ; CAPTION "Check Me !" ; FONT NTK_GetStockObject(SYSTEM_FONT) ; TEXTCOLOR NTK_RGB(255,128,128) ; BACKCOLOR NTK_RGB(255,0,0) ; STYLE BS_FLAT ; MESSAGE "Press Space Bar to Enable or Disable this logical get..." @ 180, 400 GET aVar6 ID ID_GETLBOX6 ; SIZE 100,150 ; CAPTION aLbChoices ; TYPE GXT_LISTBOX ; FONT hGetFont ; TEXTCOLOR NTK_RGB(000,000,128) ; BACKCOLOR NTK_RGB(255,255,128) ; STYLE GS_3DRAISED + WS_VSCROLL + LBS_NOTIFY + ; LBS_MULTIPLESEL ; MESSAGE "Select one or more fruits ..." @ 270, 400 GET cVar7 ID ID_GETCBOX7 ; SIZE 120,150 ; CAPTION aCbChoices ; TYPE GXT_COMBOBOX ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(000,000,128) ; BACKCOLOR NTK_RGB(255,255,128) ; BACKBRUSH hGreenBrush ; STYLE GS_3DRAISED + CBS_DROPDOWNLIST + WS_VSCROLL ; MESSAGE "Select your favorite vegetable ..." // BACKBRUSH NTK_GetStockObject(WHITE_BRUSH) ; // -------- From here, we START making the Radio button Group named GRP_VOLUME @ 320, 400 GET lVar8 ID ID_GETRB8 ; SIZE 20,100 ; CAPTION "High" ; TYPE GXT_RADIOBUTTON + "GRP_VOLUME" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(000,255,000) ; BACKCOLOR NTK_RGB(255,255,065) ; // BS_PUSHLIKE BACKBRUSH NTK_GetStockObject(TRANSPARENT) ; STYLE WS_GROUP + BS_FLAT ; MESSAGE "Click here or press space bar for big noise..." @ 350, 400 GET lVar9 ID ID_GETRB9 ; SIZE 20,100 ; CAPTION "Medium" ; TYPE GXT_RADIOBUTTON + "GRP_VOLUME" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(000,128,000) ; BACKCOLOR NTK_RGB(255,255,065) ; STYLE BS_FLAT ; // BS_PUSHLIKE MESSAGE "Click here or press space bar for medium volume..." @ 380, 400 GET lVar10 ID ID_GETRB10 ; SIZE 20,100 ; CAPTION "Low" ; TYPE GXT_RADIOBUTTON + "GRP_VOLUME" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(000,096,000) ; BACKCOLOR NTK_RGB(255,255,065) ; STYLE BS_FLAT ; // BS_PUSHLIKE MESSAGE "Click here or press space bar for low volume..." // -------- END of Radio button Group named GRP_VOLUME // -------- From here, we START making the Radio button Group named GRP_BRIGHTNESS @ 320, 550 GET lVar11 ID ID_GETRB11 ; SIZE 20,100 ; CAPTION "High" ; TYPE GXT_RADIOBUTTON + "GRP_BRIGHTNESS" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(255,000,000) ; BACKCOLOR NTK_RGB(255,255,065) ; STYLE WS_GROUP + BS_FLAT ; MESSAGE "Click here or press space bar for HIGH light..." @ 350, 550 GET lVar12 ID ID_GETRB12 ; SIZE 20,100 ; CAPTION "Medium" ; TYPE GXT_RADIOBUTTON + "GRP_BRIGHTNESS" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(128,000,000) ; BACKCOLOR NTK_RGB(255,255,065) ; STYLE BS_FLAT ; MESSAGE "Click here or press space bar for Medium light..." @ 380, 550 GET lVar13 ID ID_GETRB13 ; SIZE 20,100 ; CAPTION "Low" ; TYPE GXT_RADIOBUTTON + "GRP_BRIGHTNESS" ; FONT NTK_GetStockObject(ANSI_VAR_FONT) ; TEXTCOLOR NTK_RGB(064,000,000) ; BACKCOLOR NTK_RGB(255,255,065) ; STYLE BS_FLAT ; MESSAGE "Click here or press space bar for Low light..." // -------- END of Radio button Group named GRP_VOLUME @ 305,48 BUTTON "&Desactivate Btn #2 (Alt-F1)" SIZE 40,250 ; // TYPE NTK_BT_OD_USERDEFINED ; ID ID_BTN1 ; SUPER ACCEL KEY K_ALT_F1 ; ACTION DoEventBtn1(hWnd) ; STATE NTK_BT_ENABLE ; FONT NTK_GetStockObject(SYSTEM_FONT) ; STYLE BS_CENTER ; // BS_TOP+BS_RIGHT MESSAGE "This is a Standard Windows push button..." ; OF hWnd @ 350,48 BUTTON "Event &2"+CR+"(Alt-F2)" SIZE 40,250 ; ID ID_BTN2 ; TYPE NTK_BT_OWNERDRAWN ; SUPER ACCEL KEY K_ALT_F2 ; ACTION DoAbout() ; STATE NTK_BT_ENABLE ; FONT NTK_GetStockObject(SYSTEM_FONT) ; STYLE BS_CENTER ; // BS_TOP+BS_RIGHT TEXTCOLOR NTK_RGB(255,000,000) ; BACKCOLOR NTK_BT_CLR_DEFBACKGROUND ; // NTK default visual style. see NtkBtn.ch BITMAP UP "LOUPE_UP" ; BITMAP DN "LOUPE_DN" ; BITMAP GRAYED "LOUPE_OFF" ; BITMAP SHIFT TO 5,60 ; // , MESSAGE "This is an owner drawn button, completely painted with NTK_BT_* styles. See NTKBTN.CH ..." ; OF hWnd RETURN( Nil ) ****** ****** ****** FUNCTION DoRepaint(hDC) // you can also use: hWnd, message, nwParam, nlParam, hDC @ 400, 10 SAY "Press Esc or hit right mouse button to quit..." ; INTO CONTEXT hDC ; SIZE 430,620 ; TEXTCOLOR NTK_RGB(255,255,255) ; // White on Red BACKCOLOR NTK_RGB(255,000,000) ; STYLE DT_SINGLELINE+DT_CENTER+DT_VCENTER // ---------- SAY command complete syntax... // @ , SAY INTO CONTEXT ; // SIZE , ; // PICTURE ; // TEXTCOLOR ] ; // BACKCOLOR ] ; // STYLE ; // FONT ] RETURN(0) ****** ****** ****** FUNCTION DoHandleMsg( hWnd, message, nwParam, nlParam ) // 1 - Here you can handle Msg acording to Window's traditionnal manner. // 2 - You're are not expected to handle WM_CREATE, WM_PAINT nor WM_DESTROY. // 3 - Be carreful to the return value... Read Win32 SDK or Petzold's book !! Do Case Case message == WM_SYSCOMMAND IF nwParam == SC_MAXIMIZE NTK_MsgBox( hWnd,; "Sound like you're not allowed to maximize this window...",; "Hello, my little boy !", MB_OK+MB_ICONASTERISK ) RETURN(0) // Returning other value than DefWinProc means we don't want to iconize the window... ENDIF Case message == WM_DRAWITEM // for use with NTK_BT_OD_USERDEFINED button type // DoMyOwnerDrawBtnPainting(.....) //tone(1000,1) //tone(1000,1) //tone(1000,1) *Case message == WM_KEYDOWN *Case message == WM_COMMAND EndCase RETURN( NTK_DEFWNDPROC(hWnd, message, nwParam, nlParam) ) ****** ****** ****** FUNCTION DOCUT() LOCAL nGetID := NTK_GiveGetActive(aGetList) // Current active get (focused) LOCAL hWndGet := NTK_GiveGetHandle(aGetList, nGetID) LOCAL xGetType := NTK_GiveGetType(aGetList, nGetID) LOCAL cData := NTK_ED_GetText(hWndGet) // Retrieve current get's internal buffer LOCAL cClipData := cData LOCAL aSelRect := NTK_ED_GetSelInfo(hWndGet) // Retrieve Infos about Selection into current get LOCAL nSelStart := aSelRect[1]+1 LOCAL nSelEnd := aSelRect[2]+1 // +1 because in Window we start from zero unlike Clipper which start from 1 LOCAL nCurPos := NTK_ED_GetCharPos( hWndGet ) // Get & Save cursor position in current get IF aSelRect[1]+aSelRect[2] > 0 cClipData := SUBSTR( cClipData, nSelStart, (nSelEnd-nSelStart) ) ENDIF // --- Clear ClipBoard NTK_EmptyClipboard() // --- Push the current get internal buffer to clipboard... NTK_PutClipbText( hWndGet, cClipData ) // --- Reset the selected portion or the whole current get's internal buffer according to its TYPE // (we decided to treat only xBase Types) DO CASE CASE xGetType==GT_CHAR .OR. xGetType==GT_MEMO // "C", "M" IF aSelRect[1]+aSelRect[2] > 0 cData := STUFF( cData, nSelStart, (nSelEnd-nSelStart), "" ) +; IIF( xGetType==GT_CHAR, SPACE(nSelEnd-nSelStart), "" ) NTK_SetGetValue( aGetList, nGetID, cData ) NTK_SendMessage(hWndGet, EM_SETSEL, nCurPos, nCurPos) // Back to CurPos.. ELSE cData := SPACE( LEN(cData) ) NTK_SetGetValue( aGetList, nGetID, cData ) ENDIF CASE xGetType==GT_NUMERIC // "N" NTK_SetGetValue( aGetList, nGetID, 0 ) CASE xGetType==GT_DATE // "D" NTK_SetGetValue( aGetList, nGetID, CTOD("") ) CASE xGetType==GT_LOGIC // "L" NTK_SetGetValue( aGetList, nGetID, .F. ) ENDCASE RETURN ****** ****** ****** FUNCTION DOCOPY() LOCAL nGetID := NTK_GiveGetActive(aGetList) // Current active get (focused) LOCAL hWndGet := NTK_GiveGetHandle(aGetList, nGetID) LOCAL cData := NTK_ED_GetText(hWndGet) // Retrieve current get's internal buffer LOCAL aSelRect := NTK_ED_GetSelInfo(hWndGet) // Retrieve Infos about Selection into current get LOCAL nSelStart := aSelRect[1]+1 LOCAL nSelEnd := aSelRect[2]+1 // +1 because in Window we start from zero unlike Clipper which start from 1 //NTK_MsgBox( , "nSelStart="+STR(nSelStart) + "nSelEnd="+STR(nSelEnd), "Selection LoPos / HiPos" ) //NTK_MsgBox( , "aSelRect[1]="+STR(aSelRect[1]) + "aSelRect[2]="+STR(aSelRect[2]), "Selection LoPos / HiPos" ) IF aSelRect[1]+aSelRect[2] > 0 cData := SUBSTR( cData, nSelStart, (nSelEnd-nSelStart) ) ENDIF NTK_PutClipbText( hWndGet, cData ) RETURN ****** ****** ****** FUNCTION DOPASTE() LOCAL nGetID := NTK_GiveGetActive(aGetList) // Current active get (focused) LOCAL hWndGet := NTK_GiveGetHandle(aGetList, nGetID) NTK_SendMessage(hWndGet, WM_PASTE, 0, 0) RETURN ****** ****** ****** FUNCTION MySelFolder() LOCAL cSelFolder //NTK_GetDirDlg( hWndP, cRootPath, cSubTitle, nFlags ) -> cPath cSelFolder := NTK_GetDirDlg( hWndDemo,; nil ,; "PickUp a folder...",; BIF_USENEWUI+BIF_RETURNONLYFSDIRS ) IF !EMPTY(cSelFolder) cVar1 := LEFT( ALLTRIM(cSelFolder), MAX_PATH ) cVar1 := cVar1 + SPACE(MAX_PATH-LEN(cVar1)) REDEFINE GET ID ID_GETEDIT1 ** Just in case you'd prefer to use NTK GetSystem API's functions rather than commands... ** Things also can be done this way : // NTK_SetGetValue(aGetList,ID_GETEDIT1,"Hello Joe !!")); // Force ID_GETEDIT1 value on fly. ENDIF //DISABLE GET ID ID_GETEDIT1 //ENABLE GET ID ID_GETEDIT1 RETURN .T. ****** ****** ****** FUNCTION DoEventBtn1( hWndP ) // Enabled/Disabled Button #2 LOCAL cBtn1Text LOCAL hBtn1 := NTK_GetDlgItem( hWndP, ID_BTN1 ) LOCAL hBtn2 := NTK_GetDlgItem( hWndP, ID_BTN2 ) IF NTK_IsWindowEnabled(hBtn2) NTK_EnableBtn( hBtn2 , .F. ) cBtn1Text := "&Activate Btn #2 (Alt-F1)" NTK_SendMessage( hBtn1, WM_SETTEXT, 0, cBtn1Text ) ELSE NTK_EnableBtn( hBtn2, .T. ) cBtn1Text := "&Desactivate Btn #2 (Alt-F1)" NTK_SendMessage( hBtn1, WM_SETTEXT, 0, cBtn1Text ) ENDIF RETURN(Nil) ****** ****** ****** FUNCTION DOABOUT(hwnd, cDispMsg) IF PCOUNT() < 2 cDispMsg :="" hWnd := NTK_SelectWindow() ELSEIF PCOUNT() < 1 hWnd := NTK_SelectWindow() ENDIF IF EMPTY(cDispMsg) NTK_MsgBox( hWnd,; "Current Active Get is ID #"+ALLTRIM(STR( NTK_GiveGetActive(aGetList) ))+chr(13)+chr(13)+; "EditGET4"+chr(13)+; "Developped with NTK Project for X/HARBOUR."+chr(13)+; "¸ 2004 Jn Dechereux.",; "About...",; MB_OK+MB_ICONASTERISK ) ELSE // "Your choice is "+cDispMsg+chr(13)+chr(13)+; NTK_MsgBox( hWnd,; "Current Active Get is ID #"+ALLTRIM(STR( NTK_GiveGetActive(aGetList) ))+chr(13)+chr(13)+; "EditGET4"+chr(13)+; "Developped with NTKcore Project X/HARBOUR."+chr(13)+; "¸ 2004 Jn Dechereux.",; "About...",; MB_OK+MB_ICONASTERISK ) ENDIF RETURN(Nil) ****** ****** ******