📄 mswin.h
字号:
/*------------------------------------------------------------------------------*
* File Name: MSWin.h *
* Creation: CPY 4/12/2001 *
* Purpose: Win32 functions *
* Copyright (c) OriginLab Corp.2001 *
* All Rights Reserved *
* *
* Modification Log: *
* CPY 11/15/02 v7.0434 ORIGIN_8_FEATURES *
*------------------------------------------------------------------------------*/
#ifndef _MSWIN_H
#define _MSWIN_H
#ifndef _OC_TYPES_H
#include <OC_types.h> // if not already included, this will provide SYSTEMTIME
#endif
//--------------------------------------------------------------------------
// From Microsoft's windef.h
//--------------------------------------------------------------------------
typedef DWORD COLORREF;
typedef DWORD *LPCOLORREF;
//--------------------------------------------------------------------------
// From Microsoft's wingdi.h
//--------------------------------------------------------------------------
/* Logical Font */
#define LF_FACESIZE 32
#define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16)))
// some colors
#ifndef COLOR_RED
#define COLOR_RED RGB(255,0,0)
#define COLOR_GREEN RGB(0,255,0)
#define COLOR_BLUE RGB(0,0,255)
#define COLOR_YELLOW RGB(255,255,0)
#define COLOR_NAVY RGB(0,0,128)
#define COLOR_LTYELLOW RGB(255,255,128)
#define COLOR_ORANGE RGB(255,128,0)
#define COLOR_BLACK RGB(0,0,0)
#define COLOR_WHITE RGB(255,255,255)
#endif
#define ANSI_CHARSET 0
#define DEFAULT_CHARSET 1
#define SYMBOL_CHARSET 2
#define SHIFTJIS_CHARSET 128
//--------------------------------------------------------------------------
// From Microsoft's winuser.h
//--------------------------------------------------------------------------
#define WM_CLOSE 0x0010
#define WM_QUERYENDSESSION 0x0011
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
//-------- CPY 11/15/02 v7.0434 ORIGIN_8_FEATURES
// Origin 8 or later
#if _OC_VER > 0x0703
typedef struct tagRECT
{
int left;
int top;
int right;
int bottom;
} RECT;
#define RECT_WIDTH(_RR) (_RR.right - _RR.left)
#define RECT_HEIGHT(_RR) (_RR.bottom - _RR.top)
#define RECT_X(_RR) ((_RR.left + _RR.right)/2)
#define RECT_Y(_RR) ((_RR.bottom + _RR.top)/2)
typedef struct tagSIZE
{
LONG cx;
LONG cy;
} SIZE;
/* Stock Logic fonts */
#define ORIGIN_FIXED_FONT (-1)
#define ORIGIN_VAR_FONT (-2)
#define ORIGIN_MENU_FONT (-3)
#define OEM_FIXED_FONT 10
#define ANSI_FIXED_FONT 11
#define ANSI_VAR_FONT 12
#define SYSTEM_FONT 13
#define DEVICE_DEFAULT_FONT 14
#define SYSTEM_FIXED_FONT 16
#define DEFAULT_GUI_FONT 17
#define LOGPIXELSX 88 /* Logical pixels/inch in X */
#define LOGPIXELSY 90 /* Logical pixels/inch in Y */
#define HDC LPVOID
/** >User Interface Controls
The DeviceContext class defines a class of device-context objects.
Example:
Page pb;
pb = Project.Pages(); // Get the project's active page
if( pb.IsValid() )
{
Window myWindow = pb.GetWindow();
DeviceContext myDC = myWindow.GetDC();
int nPixels = myDC.GetDeviceCaps(LOGPIXELSX);
}
*/
class DeviceContext
{
public:
/**
*/
DeviceContext();
/**
*/
DeviceContext(DeviceContext &dc);
/**
*/
~DeviceContext();
public:
/**
Use hDC set internal hDC value.
*/
BOOL Attach(HDC hDC );
/**
Return internal hDC value of class and set internal hDC to NULL
*/
HDC Detach( );
/**
This method retrieves a wide range of device-specific information about the display device.
Parameters:
nIndex = the type of information to return.
Return:
The value of the requested capability if the function is successful.
*/
int GetDeviceCaps(int nIndex) const;
/**
Computes the width and height of a line of text on the attribute device context using the current font to determine the dimensions.
Parameters:
lpszString = Points to a string of characters.
nCount = Specifies the number of characters in the string.
Return:
The dimensions of the string (in logical units) in a SIZE structure.
Example:
void test()
{
Window wnd = MyDlg.GetWindow();
DeviceContext dc = wnd.GetDC();
SIZE sz[10];
sz[2] = dc.GetTextExtent("ABC",3);
out_int("x_width = ", sz[2].cx);
out_int("y_width = ", sz[2].cy);
}
*/
SIZE GetTextExtent(LPCTSTR lpszString, int nCount);
/**
Computes the width and height of a line of text on the attribute device context using the current font to determine the dimensions.
Parameters:
str = A string object.
Return:
The dimensions of the string (in logical units) in a SIZE structure.
Example:
void test()
{
Window wnd = MyDlg.GetWindow();
DeviceContext dc = wnd.GetDC();
SIZE sz[10];
sz[2] = dc.GetTextExtent("ABC",3);
out_int("x_width = ", sz[2].cx);
out_int("y_width = ", sz[2].cy);
}
*/
SIZE GetTextExtent(const string &str);
};
/** >User Interface Controls
Example:
*/
class CmdTarget
{
public:
/**
*/
CmdTarget();
protected:
Msgmap m_msgmap;
};
/** >User Interface Controls
The Window class is the base class for all window classes.
This class is similar to the MFC CWnd class
Example:
// Get "Data1" worksheet window...if not valid...
WorksheetPage wksPg("Data1");
Window winWks = wksPg.GetWindow();
if(winWks)
{
printf("Worksheet window is %s\n", winWks.Text);
}
*/
class Window :public CmdTarget
{
public:
/**
*/
Window();
/**
*/
Window(HWND hWnd);
/**
*/
Window(Window& ctrl);
/**
This function returns the window handle
Example:
// make active window iconized
Window winDlg = myDlg.GetWindow();
MessageBox(winDlg.GetSafeHwnd(), "Hello", "Test", MB_OK);
Return:
Returns the window handle for a window.
Returns NULL if the Window class is not attached to a window.
*/
HWND GetSafeHwnd();
/**
*/
BOOL Attach(Window& ctrl);
/**
Return:
The previous position of the scroll box.
Parameters:
nBar = the scroll bar to be set. This parameter can be either of the following:
SB_HORZ Sets the position of the scroll box in the horizontal scroll bar of the window.
SB_VERT Sets the position of the scroll box in the vertical scroll bar of the window.
nPos = the new position of the scroll box. It must be within the scrolling range.
bRedraw = whether the scroll bar should be repainted to reflect the new scroll-box position.
If this parameter is TRUE, the scroll bar is repainted; if FALSE, the scroll bar is not repainted.
Remarks:
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.
*/
int SetScrollPos( int nBar, int nPos, BOOL bRedraw = TRUE );
/**
Return:
The previous position of the scroll box.
Parameters:
nBar = the scroll bar to be set. This parameter can be either of the following:
SB_HORZ Sets the position of the scroll box in the horizontal scroll bar of the window.
SB_VERT Sets the position of the scroll box in the vertical scroll bar of the window.
nPos = the new position of the scroll box. It must be within the scrolling range.
bRedraw= whether the scroll bar should be repainted to reflect the new scroll-box position. If this parameter is TRUE, the scroll bar is repainted; if FALSE, the scroll bar is not repainted.
Remarks:
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.
*/
void SetScrollRange( int nBar, int nMinPos, int nMaxPos, BOOL bRedraw = TRUE );
/**
Return:
Specifies the current position of the scroll box in the scroll bar if successful; otherwise 0.
Parameters:
nBar = the scroll bar to examine. The parameter can take one of the following values:
SB_HORZ Retrieves the position of the horizontal scroll bar.
SB_VERT Retrieves the position of the vertical scroll bar.
Remarks:
Retrieves the current position of the scroll box of a scroll bar.
The current position is a relative value that depends on the current scrolling range.
For example, if the scrolling range is 50 to 100 and the scroll box is in the middle of the bar, the current position is 75.
*/
int GetScrollPos( int nBar ) const;
/**
Parameters:
nBar = the scroll bar to examine. The parameter can take one of the following values:
SB_HORZ Retrieves the position of the horizontal scroll bar.
SB_VERT Retrieves the position of the vertical scroll bar.
nMinPos = integer variable that is to receive the minimum position.
nMaxPos = integer variable that is to receive the maximum position.
Remarks:
Copies the current minimum and maximum scroll-bar positions for the given scroll bar to the locations specified by lpMinPos and lpMaxPos.
If window does not have a scroll bar, then the GetScrollRange member function copies 0 to lpMinPos and lpMaxPos.
The default range for a standard scroll bar is 0 to 100. The default range for a scroll-bar control is empty (both values are 0).
*/
void GetScrollRange( int nBar, int& nMinPos, int& nMaxPos ) const;
/**
*/
UINT SendMessage(uint msg, DWORD wParam = 0, DWORD lParam = 0);
/**
*/
BOOL PostMessage(uint msg, DWORD wParam = 0, DWORD lParam = 0);
/**
Remark:
This function sets the specified window's show state.
Parameters:
nCmdShow = SW_HIDE, SW_NORMAL, SW_MINIMIZE, SW_MAXIMIZE etc.
Example:
// make "Data1" worksheet window iconized
WorksheetPage wksPg("Data1");
Window winWks = wksPg.GetWindow();
if(winWks)
winWks.ShowWindow(SW_MINIMIZE);
Return:
If the window was previously visible, the return value is TRUE.
If the window was previously hidden, the return value is FALSE.
*/
BOOL ShowWindow(int nCmdShow);
/**
Remark:
Changes the position and dimensions.
Parameters:
lpRect: Points to a RECT structure that specifies the new size and position
bRepaint: Specifies whether Window is to be repainted.
Example:
//Please make sure you have a "Data1" worksheet window exist when you run the example
void test_MoveWindow()
{
WorksheetPage testWks("Data1");
Window testWin = testWks.GetWindow();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -