2.2.6.32 Window


Name

Window

Remark

The Window class is the base class for all window classes. This class is similar to the MFC CWnd class.

Hierarchy

Examples

EX1

int Window_ex1()
{
    // Get the worksheet window...if not valid...
    WorksheetPage  wksPg = Project.WorksheetPages(0);
    if (wksPg)
    {
        Window winWks = wksPg.GetWindow();
        if(winWks)
          {
            printf("Worksheet window is %s\n", winWks.Text);
        }
    }
    return 1;
}

EX2

int Window_ex2()
{
    Window win;
    Page pb;
    pb = Project.Pages(); // Get the project's active page
    win = pb.GetWindow(); // child window of Origin
    
    // About Windows, Frames, Screen Coordinates, Client Coordinates
    // A Window consists of a Frame, and a client area. 
    // The client area is where drawing of tables and graphs etc. takes place.
    // The frame may contain controls such as minimize, close, and scroll bars.
    // Coordinates of points on the screen can be expressed in Screen coordinates 
    // or in Client coordinates (with respect to a particular client area).
    // Screen coordinates have their origin (x, y) = (0, 0) at the upper left corner of the screen.
    // The x coordinate increases as the point moves to the right. 
    // Then y coordinate increases as the point ges down the screen.
    // Thus, screen coordinates always have positive x and y values.
    //
    // Client coordinates are with respect to a client area of a particular window.
    // The upper left point of the client area is given client coordinates (x, y) = (0, 0).
    // Points in the client area have positive coordinates.
    // Points to the left of the client origin have negative x value. 
    // Points above the client origin have negative y value.
    // Note: the upper left corner of the frame surrounding a client area has negative x and y client coordinates.
    // Note: the upper left corner of the screen has negative x and y client coordinates.
    // Finally, many windows may exist, and some may be child windows contained within the client area of another window.
    // When you open a graph in Origin, the graph window is a child window inside Origin. 
    // Note that Origin's main window contains the graph window within it's client area.
    // The graph is drawn inside the client area of the graph window.
    // Two different client areas are involved.
    // Thus, when discussing client coordinates, you need to be aware of what client area the coordinates belong to.
    
    RECT rect1 = {10, 10, 300, 300};// a rectangle, interpreted as Origin client coordinates.
    win.MoveWindow(&rect1);// this will move and resize the window into the rectangle rect1, interpreted as client coordinates with respect to the parent window.
    printf("A) MoveWindow: window location in Origin client coordinates:\n(left, top, right, bottom) =  (%d, %d, %d, %d)\n\n", 
    rect1.left, rect1.top, rect1.right, rect1.bottom);
    
    RECT rectTemp;
    win.GetWindowRect(&rectTemp); // rectTemp receives the screen coordinates of the window win.
    printf("B) GetWindowRect: window rectangle in Screen coordinates:\n(left, top, right, bottom) =  (%d, %d, %d, %d)\n\n", 
    rectTemp.left, rectTemp.top, rectTemp.right, rectTemp.bottom);
    
    win.ScreenToClient(&rectTemp); // rectTemp receives the window's own client coordinates of the window win.
    printf("C) ScreenToClient: window rectangle with respect to the window's own client coordinates:\n(left, top, right, bottom) =  (%d, %d, %d, %d)\n\n", 
    rectTemp.left, rectTemp.top, rectTemp.right, rectTemp.bottom);
    
    win.GetClientRect(&rectTemp); // 
    printf("D) GetClientRect: window's client rectangle with respect to the window's own client coordinates:\n(left, top, right, bottom) =  (%d, %d, %d, %d)\n\n",
    rectTemp.left, rectTemp.top, rectTemp.right, rectTemp.bottom);
    
    win.ClientToScreen(&rectTemp); // 
    printf("E) ClientToScreen: window's client rectangle with respect to Screen coordinates:\n(left, top, right, bottom) =  (%d, %d, %d, %d)\n\n",
    rectTemp.left, rectTemp.top, rectTemp.right, rectTemp.bottom);
    
    printf("Note: C has negative left and top coordinates.\nNote: B and C have same area = area of window. D and E have same area = area of window's client area.\n");
    
    return 0;
}

Header to Include

origin.h

Reference

Members

Name Brief Example
Attach Attaches a Windows window to a Window object.
CheckRadioButton This method selects, adds a check mark to a specified radio button in a group and clears, removes a check mark from all other radio buttons in the group.
ClientToScreen Converts the client coordinates of a given RECT structure pointer on the display to screen coordinates. Examples
GetActiveXControl This function provides COM support for ActiveX controls that are placed into Origin windows or Dialog Builder winodws. Examples
GetCheckedRadioButton This method retrieves the identifier of the currently checked radio button in the specified group.
GetClientRect Examples
GetControlType
GetDC Retrieves a device context for the client area. Examples
GetDlgItem You can use the GetDlgItem function with any parent-child window pair, not just with dialog boxes. As long as the parent window and the child window has a unique identifier, GetDlgItem returns a valid child window.
GetParent Function can return an owner window instead of a parent window.
GetSafeHwnd This function returns the window handle Examples
GetScrollPos
GetScrollRange
GetWindowRect Examples
Invalidate Invalidates the entire client area of Window.
InvalidateRect Invalidates the client area within the given rectangle by adding that rectangle to the Window update region.
IsIconic This function checks if window is minimized. Examples
IsZoomed This function checks if window is maximized. Examples
ModifyStyle Modifies the current window style. Examples
MoveWindow Changes the position and dimensions. Examples
PostMessage Places a message in the message queue associated with the thread that created the window. Returns without waiting for the thread to process the message. Examples
ScreenToClient Converts the screen coordinates of a given RECT structure pointer on the display to client coordinates. Examples
SendMessage Sends a message to the window and does not return until the window procedure has processed the message. Examples
SetFont Set stock logic font for the control
SetRedraw An application calls SetRedraw to allow changes to be redrawn or to prevent changes from being redrawn. Examples
SetScrollPos Sets the current position of a scroll box and, if requested, redraws the scroll bar to reflect the new position of the scroll box. Setting bRedraw to FALSE is useful whenever the scroll bar will be redrawn by a subsequent call to another function.
SetScrollRange Sets the current position of a scroll box and, if requested, redraws the scroll bar to reflect the new position of the scroll box. Setting bRedraw to FALSE is useful whenever the scroll bar will be redrawn by a subsequent call to another function.
ShowWindow This function sets the specified window's show state. Examples
SizeInSplitter Changes the size of the window when inside a splitter pane of a workbook or a graph.
SizeMoveChildWindows multiple-window repositioning and resizing
UpdateWindow Updates the client area by sending a WM_PAINT message if the update region is not empty.
SetIcon Call this member function to set the handle to a specific icon, as identified by hIcon.
GetIcon Call this member function to get the handle to either a big (32x32) or the handle to a small (16x16) icon, as indicated by bBigIcon.
Window Default constructor for a Window object. Examples


Property

Name Brief Example
Enable
FontName Returns the font used to display text in a control or in a run-time drawing or printing operation. Read only Examples
FontSize in points
Text
Visible Gets or sets whether the window is visible Examples