What is Handle exactly ?

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • What is Handle exactly ?

    Word 'handle' is used at many places in document. Like Button Handle, Window handle.. What is handle exactly ?

    For example, to set font for the button, i have to pass handle of the button as a first argument in
    BUTTON_SetFont(BUTTON_Handle hObj, const GUI_FONT * pFont);

    what i'm passing here as first argument ? Is it address or Value or Structure or something else ?
    The API is not exposed to the user so thought to ask it here.
  • Hello Amit,

    when creating a button with the function BUTTON_Create(), the function returns a handle of the button.

    C Source Code

    1. WM_HWIN hButton
    2. hButton = BUTTON_Create(0, 0, 80, 30, 0, WM_CF_SHOW);
    3. BUTTON_SetFont(hButton, pFont);

    This handle can be used to set different properties of a button, just like you want to do.

    Take a look into the sample attached. There I receive the handle of a button in two different ways.

  • Thank Sven for your reply.

    My question was little different. What do you mean by 'handle' of a widget ?
    Is it some memory address or a number or anything else ?
    When i pass ButtonHandle to any Button related API, What am i exactly passing as a handle ? Is it a memory address or just a value or something else ?
  • Hi,

    emWin uses his own memory management system, when we init emWin,
    GUI_ALLOC_AssignMemory() init it!

    A Window or WIDGET handle may be a Memory buffer's handle or Index something (?..., no source) and
    A Window or WIDGET object pointer is Object structure pointer. We can use WM_H2P ( or GUI_ALLOC_h2p() )function convert it!

    for example:
    BUTTON_Handle hWin;
    BUTTON_Obj * pObj;

    hWin = BUTTON_Create(...);
    pObj = (BUTTON_Obj *)WM_H2P(hWin);

    BUTTON_Obj is defined in BUTTON_Private.h

    Best Regards,

    The post was edited 2 times, last by chensie ().