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.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorGaza
    • CommentTimeJul 8th 2011
     
    Dear Jean,

    Please advise how to make Gradient background and Gradient Button with NTK.

    Rgds,
    Gaza
    •  
      CommentAuthorjnd
    • CommentTimeJul 9th 2011 edited
     
    Dear Gaza,

    Good question. Here are a couple answers supposed to be helpful. :bigsmile:
    Regards,
    JN

    I - Gradient Background.
    I see at least 2 ways of doing this.

    1. By creating a bitmap background brush you pass to your CREATE WINDOW command via the BRUSH clause.

    e.g.
    . . .
    hBmpGradientBkg := NTK_ReadPictureToBmp( "GradientBkg.jpg" )
    CREATE BITMAP BRUSH FROM hBmpGradientBkg TO hWndBgkBrush
    
    
    // Create the main program window
    CREATE WINDOW hWndMain  ;
           STYLE WND_STANDARD+F_MAX+F_MIN ;
           BRUSH hWndBgkBrush ;
           AT 0,0 SIZE CW_USEDEFAULT, CW_USEDEFAULT ;
           TITLE "Gradient background with NTKRad..." ;
           ON PAINT MainRepaint()
    . . .
    


    or

    2. By inserting a @ y,x SAY WALLPAPER ... command into the 'ON PAINT' procedure attached to your window. Of course, you'll have to take care to previously declare a static var in which a gradient Bitmap is loaded using the NTK_ReadPictureToBitmap() function. Also, take care to include to your PRG, the NTKCMDEX.CH which contains all the definitions related to the @ y,x SAY BITMAP ... commands.

    N.B. No need to create a bitmap brush in that case!

    e.g.
    . . .
    hBmpGradientBkg := NTK_ReadPictureToBmp( "GradientBkg.jpg" )
    
    // Create the main program window
    CREATE WINDOW hWndMain  ;
           STYLE WND_STANDARD+F_MAX+F_MIN ;
           AT 0,0 SIZE CW_USEDEFAULT, CW_USEDEFAULT ;
           TITLE "Gradient background with NTKRad..." ;
           ON PAINT MainRepaint()
    . . .
    
    FUNCTION MainRepaint(hWnd, nMsg, nwParam, nlParam, hDC)
    . . .
    // Draw Gradient Bkg
    @ 0,0 SAY WALLPAPER BITMAP HANDLE hBmpGradientBkg TO hWnd INTO CONTEXT hDC                                         
    . . . 
    RETURN 0
    



    II - Gradient Buttons.
    Gradient buttons can be obtained either by passing a bitmap brush to the 'BACKGROUND BRUSH' clause of a Hyperlink button:
    . . .
    @ 000,002 HYPERLINK "&Exit Program"   SIZE 030,100           ;
                        ID ID_BTN_QUIT                           ;
                        SUPER ACCEL KEY K_ALT_C                  ;
                        STATE NTK_BT_ENABLE                      ;
                        FONT NTK_GetStockObject(ANSI_VAR_FONT)   ;
                        TEXTCOLOR NTK_RGB(255,255,255)           ;
                        BACKCOLOR NTK_RGB(255,255,128)           ;
                        BACKGROUND BRUSH  hBtnBgkBrush           ;
                        BITMAP UP     "16_ExitUp"                ;
                        BITMAP DN     "16_ExitDn"                ;
                        BITMAP GRAYED "16_ExitOff"               ;
                        BITMAP OVER   "16_ExitOvr"               ;
                        ACTION NTK_SendQuitEvent()               ; // send a close signal to Exit program
                        OF hWndMain                              ;
                        MESSAGE "Close all and quit this app."
    
    . . . 
    


    Or, by passing a different gradient bitmap to each BITMAP clause of a FreeShape button. i.e. One for each state. i.e. up,dn,mouseover and eventually off/grayed.
    . . .
    @ 002,220 BUTTON  "&Test2..."  SIZE 030,100            ;
                      ID ID_BTN_TEST2                      ;
                      TYPE  NTK_BT_OD_FREESHAPE            ;
                      STYLE BS_CENTER                      ;
                      BITMAP UP "rBkgBtnUP"                ;
                      BITMAP DN "rBkgBtnDN"                ;
                      BITMAP OVER "rBkgBtnOvr"             ;
                      ACTION NTK_MsgBox(hWndMain, "Running Test2...") ;
                      OF hWndMain                          ;
                      MESSAGE "This is a freeshape button"+CHR(13)+;
                              "using gradient bitmaps"
    . . . 
    


    In order to give you a better idea, see the attached tutorial.
    •  
      CommentAuthorGaza
    • CommentTimeJul 10th 2011
     
    Dear JN,

    Thank you for your help.

    But when I click HYPERLINK icon, will popup the message,
    when I click OK or (X), popup still there I have to do to terminate the program with "Ctrl" + "Del".

    Beside using image *.bmp or *.jpg, do you have any way
    to make gradient, I look at FiveWin samples, they
    can manipulate to make gradient directly with a program without using any image, maybe NTK in the next release.

    Rgds,
    Gaza
    •  
      CommentAuthorjnd
    • CommentTimeJul 11th 2011 edited
     
    Morning Gaza,

    >when I click OK or (X), popup still there I have to do to terminate the program with
    >"Ctrl" + "Del".
    No pb for me, it's work fine on my PC. See my executable attached.


    >Beside using image *.bmp or *.jpg, do you have any way to make gradient, I look at FiveWin samples, they can
    >manipulate to make gradient directly with a program without using any image, maybe NTK in the next release.

    The same is possible with NTK. Also, using the _DLL . . . or lastest @ y,x ActiveX . . . commands, you can even access to many other external functions provided by the Win32 Apis or any other manufacturers libraries.
    You might be interested in Win32 APis like 'GradienFill', and so on. So, Feel free to have a look to MSDN online documentation...
    But IMO, a picture software such as Paintshop, The gimp, Photofiltre, etc. will let you create very good-looking gradients and textures, in an even faster and more efficient way!

    However, I don't see where is the bargain to spend much time making gradients programmatically, when you have tons of available fancy textures on the web. Then, It is very easy to reuse them into your application using the technics explained in my previous post.
    Keep in mind, the technics shown in the above are very commonly used in order to make applications proposing a fully skinnable interface to their end-user.

    Kind regards,
    JN
    •  
      CommentAuthorMarkus II
    • CommentTimeJul 11th 2011 edited
     
    Hi Gaza,

    to enhanced the look & feel of your application, it's easy with GDI functions of NTK. And you can also used my lib NTKMKII. You can download it on http://markus2.e-monsite.com/ Try the demo.
    You can create your own design with any paint soft.

    Have fun with NTK

    Bye
    MARKUS II
    •  
      CommentAuthorGaza
    • CommentTimeJul 13th 2011
     
    Dear JN and MARKUS II

    Thank you, my question only for cosmestic purpose not so important in programming.

    We use xHarbour + NTK to manipulated DataBase in windows enviroment this is the point.

    I am new in xHarbour + NTK I need more samples to have an idea how to convert my old clipper code to
    xHarbour + NTK, I think faster learning to do copy and paste the code and do compiling running and see what going on and the effect.

    Rgds,
    Gaza