How to select the client window of the FrameWindow as the active Window

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

  • How to select the client window of the FrameWindow as the active Window

    Hello together,

    I just want to write some text in the client area of a frame window.
    The parent of the frame window is WM_HBKWIN (Desktop).
    I first retrieve the handle of the client window and therafter set it as the active window
    to receive text:

    handle = WM_GetClientWindow(hFrameWin);
    //at this stage the handle of the child of framewin (client area) is valid
    handle = WM_SelectWindow(handle);
    //at this stage the handle equals to WM_HBKWIN!!
    GUI_DispStringAt("Text",10,180);

    However the WM_SelectWindow(handle) function obviously doesn´t accept the handle of the client area,
    so it returns the current active window (WM_HBKWIN).

    How can I make the client area of a frame window to be the active window in order to receive simple text instructions?
    Or is it only possible to place text in the client area by modifying the WM_PAINT message in the callback function of the
    client area?

    Thanks a lot in advance for your help
    Andy
  • Hello Andy,

    I am afraid the return value of the function WM_SelectWindow() is not properly documented. The function does not return the selected window. In fact it returns the previously selected window. So your application should work as expected.

    Best regards,
    Adrian
  • Hello Adrian,

    thank you for your answer regarding the return value of WM_SelectWindow().
    Using WM_GetActiveWindow() I verified that the active window is actually the client area of the frame window.
    So WM_SelectWindow() works.

    But the framewindow is still displayed only with headline in the header window but no text in the client area.

    I managed meanwhile to get the text into client area with callback functions. But this a lot of code overhead for doing this simple job.

    I would very much appreciate if you could provide an example where the client area of a frame window is selected as the active window and thereafter receives GUI_DispString() Instructions?

    Thanks a lot for your help

    Andy
  • Hello Andy,

    In fact using the function WM_SelectWindow() is the only way to avoid using callbacks. Nevertheless in most cases it is not recommended to use this function, because by using it the application does not exactly follow the principle of the Window Manager anymore. Using callbacks is a reliable way to adapt the function of windows or widgets.

    Best regards,
    Adrian
  • Adrian,

    Is there no way for GUI_Disp*() functions to draw on a window other than the background/desktop window without overriding WM_PAINT? My theory of operation for the library is still fuzzy on why I can't draw arbitrarily on a window other.

    Or, perhaps I am drawing on it, but the window is refreshing itself and not redrawing the GUI_Disp*() data. Because the background/desktop window does not have a callback by default, it does not redraw over the GUI_Disp*() work until we manually do it with GUI_Clear() and so on. Is this correct?

    Cheers,
    Joe
  • Adrian et al,

    I have solved it. I feared overriding WM_PAINT, but forgot that there is WM_PRE_PAINT and WM_POST_PAINT as well. So I have defined all my GUI_Disp*() functionality within the callback handler case for
    WM_POST_PAINT. This leaves WM_PAINT intact as well as my ability to continue using GUIBuilder (edits with // USER comment blocks).

    Cheers,
    Joe
  • Hello Joe,

    Please note that the messages WM_PRE_PAINT and WM_POST_PAINT are not intended to perform drawing operations. Those are sent to the window in order to inform it about the start and end of a drawing operation. In order to draw a window the Window Manager might send several WM_PAINT messages according to the tiling function.

    If you want to keep the internal paint function, please do the following:

    C Source Code

    1. static void _cbBackground(WM_MESSAGE * pMsg) {
    2. switch (pMsg->MsgId) {
    3. case WM_PAINT:
    4. //
    5. // Draw something below the default appearance.
    6. //
    7. WM_DefaultProc(pMsg);
    8. //
    9. // Draw something on top of the default appearance.
    10. //
    11. break;
    12. }
    13. }
    Display All

    Please note that this applies to windows. If you like to do this using Widgets, you will have to call the widget callback function (<WIDGET>_Callback()) instead of the function WM_DefaultProc().

    Best regards,
    Adrian