window.cpp
来自「SimpleGraphicOperatingSystem 32位图形化操作系统 」· C++ 代码 · 共 168 行
CPP
168 行
#include <System.h>
#include <osdef.h>
#include <Api.h> //Sgos api
namespace System{
//获取桌面窗体
void* Window::GetDesktopWindow()
{
return KGetDesktopWindow();
}
//创建窗体
void* Window::CreateWindow( void* parent, char* text, unsigned int len, int style, int x, int y, int w, int h )
{
return KCreateWindow( parent, text, len, style, x, y, w, h );
}
void* Window::GetParentWindow( void* window )
{
return KGetParentWindow( window );
}
//设置窗体位图
BitmapInfo* Window::SelectBitmap( void* window, BitmapInfo* bitmap )
{
return (BitmapInfo*)KSelectBitmap(window, bitmap );
}
//获得窗体位置和大小
int Window::GetWindowRect( void* window, void* r)
{
return KGetWindowRect( window, r );
}
//获得一个窗体的位图
void* Window::GetWindowBitmap( void* window )
{
return KGetWindowBitmap( window );
}
//移动一个窗体
int Window::MoveWindow( void* window, int x, int y, int w, int h )
{
int flag;
flag = 0;
if( w<=0&&h<=0 )
flag|=SWP_NOSIZE;
if( x==-1&&y==-1 )
flag|=SWP_NOMOVE;
int ret=KSetWindowPosition( window, x, y, w, h, 0, flag );
Application::DoEvent(WM_SIZE);
Application::DoEvent(WM_MOVE);
return ret;
}
//置顶
int Window::MoveToTop( void* window, bool always )
{
int flag, order;
flag = SWP_NOMOVE | SWP_NOSIZE | SWP_ORDER;
if( always )
order = ALWAYSONTOP;
else
order = ONTOP;
int ret=KSetWindowPosition( window, 0, 0, 0, 0, order, flag );
}
int Window::MoveToBottom( void* window, bool always )
{
int flag, order;
flag = SWP_NOMOVE | SWP_NOSIZE | SWP_ORDER;
if( always )
order = ALWAYSONBOTTOM;
else
order = ONBOTTOM;
int ret=KSetWindowPosition( window, 0, 0, 0, 0, order, flag );
}
//设置窗体文本
int Window::SetWindowText( void* window, char *Text, int len )
{
return KSetWindowText( window, Text, len );
}
//获得窗体文本
int Window::GetWindowText( void* window, char* Text, int len )
{
return KGetWindowText( window, Text, len );
}
//获得窗体
int Window::GetWindowOwner( void* window )
{
return KGetWindowOwner( window );
}
//活动该层的活动窗体
void* Window::GetActiveChildWindow( void* window )
{
return KGetActiveChildWindow( window );
}
//判断是否活动窗体
int Window::IsActiveWindow( void* window )
{
return KIsActiveWindow( window );
}
//活动一个窗体
int Window::SetActiveWindow( void* window )
{
return KSetActiveWindow( window );
}
//销毁一个窗体,子窗体也被销毁
int Window::DestroyWindow( void* p )
{
return KDestroyWindow( p );
}
//计算该在屏幕位置的窗体。 Note:没可能返回NULL
void* Window::WindowFromPos( void* p )
{
return KWindowFromPos( p );
}
//显示窗体
int Window::ShowWindow( void* window, int show )
{
return KShowWindow( window, show );
}
int Window::ShowMouse( void* window, int show )
{
return KShowMouse( window, show );
}
//刷新窗体,提交一个重画请求到桌面或父窗体
void Window::RefreshWindow( void* window, void* r )
{
//
return KRefreshWindow( window, r );
}
int Window::GetWindowData( void* window, int pos )
{
return KGetWindowData( window, pos );
}
int Window::SetWindowData( void* window, int pos, int value )
{
return KSetWindowData( window, pos, value );
}
int Window::IsWindowVisible( void* window )
{
return KIsWindowVisible( window );
}
int Window::EnableWindow( void* window, int enable )
{
return KEnableWindow( window, enable );
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?