winlib.c
来自「深圳市微逻辑电子有限公司 巨果• Kingmos® 系统核心」· C语言 代码 · 共 2,006 行 · 第 1/4 页
C
2,006 行
#include <eframe.h>
#include <eugwme.h>
#include <eapisrv.h>
#include <epcore.h>
//#define ENTER_SERVER( idServer )
/// CALLSTACK cs;
// =
//#define LEAVE_SERVER(
//extern const PFNVOID lpWindowAPI[];
static UINT IsSysClass( LPCTSTR lpszClassName )
{
/*
if( stricmp( lpszClassName, classBUTTON ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classSTATIC ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classCOMBOBOX ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classEDIT ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classLISTBOX ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classCOMBOLISTBOX ) )
{
return TRUE;
}
if( stricmp( lpszClassName, classMENU ) )
{
return TRUE;
}
return FALSE;
*/
/*
if( stricmp( lpszClassName, classBUTTON ) )
{
return WSC_BUTTON;
}
if( stricmp( lpszClassName, classSTATIC ) )
{
return WSC_STATIC;
}
if( stricmp( lpszClassName, classCOMBOBOX ) )
{
return WSC_COMBOBOX;
}
if( stricmp( lpszClassName, classEDIT ) )
{
return WSC_EDIT;
}
if( stricmp( lpszClassName, classLISTBOX ) )
{
return WSC_LISTBOX;
}
if( stricmp( lpszClassName, classCOMBOLISTBOX ) )
{
return WSC_COMBOLISTBOX;
}
if( stricmp( lpszClassName, classMENU ) )
{
return WSC_MENU;
}
*/
}
typedef HWND ( WINAPI * PWND_CREATEEX )( DWORD dwExStyle,
LPCTSTR lpcClassName,
LPCTSTR lpcText,
DWORD dwMainStyle,
int x, int y, int dx, int dy,
HWND hParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpCreateParam );
HWND WINAPI Wnd_CreateEx(
DWORD dwExStyle,
LPCTSTR lpcClassName,
LPCTSTR lpcText,
DWORD dwMainStyle,
int x, int y, int dx, int dy,
HWND hParent,
HMENU hMenu,
HINSTANCE hInstance,
LPVOID lpCreateParam )
{
HWND hWnd;
int loop = 0;
_again:
#ifdef CALL_TRAP
{
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_CREATEEX, 12 );
cs.arg0 = (DWORD)dwExStyle;
hWnd = (HWND)CALL_SERVER( &cs, lpcClassName, lpcText, dwMainStyle, x, y, dx, dy, hParent, hMenu, hInstance, lpCreateParam );
}
#else
{
//PWND_CREATEEX lpCreateEx;// = (PWND_CREATEEX)lpWindowAPI[WND_CREATEEX];
CALLSTACK cs;
//HWND hWnd = NULL;
PWND_CREATEEX lpCreateEx;
if( API_Enter( API_WND, WND_CREATEEX, &lpCreateEx, &cs ) )
{
lpcClassName = MapProcessPtr( lpcClassName, (LPPROCESS)cs.lpvData );
lpcText = MapProcessPtr( lpcText, (LPPROCESS)cs.lpvData );
hWnd = lpCreateEx( dwExStyle, lpcClassName, lpcText, dwMainStyle, x, y, dx, dy, hParent, hMenu, hInstance, lpCreateParam );
API_Leave( );
}
}
//return hWnd;
#endif
if( hWnd == NULL && loop == 0 )
{
DEBUGMSG( 0, ( "init sys class++.\r\n" ) );
//if( IsSysClass(lpcClassName) )
{
extern BOOL InitialSystemWindowClass( HINSTANCE hInst );
WNDCLASS wc;
HINSTANCE hInst;
//RETAILMSG( 1, ( "init sys class001.\r\n" ) );
hInst = (HINSTANCE)GetModuleHandle( NULL );
//RETAILMSG( 1, ( "init sys class002.\r\n" ) );
if( GetClassInfo( hInst, classBUTTON, &wc ) == FALSE )
{ //系统类没有初始化或不存在
//RETAILMSG( 1, ( "init sys class003.\r\n" ) );
InitialSystemWindowClass(hInst);
loop ++;
//RETAILMSG( 1, ( "init sys class--.\r\n" ) );
goto _again;
}
}
}
return hWnd;
}
typedef int ( WINAPI * PWND_GETCLASSNAME )( HWND hWnd, LPTSTR lpszClassName, int nMaxCount );
int WINAPI Wnd_GetClassName( HWND hWnd, LPTSTR lpszClassName, int nMaxCount )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_GETCLASSNAME, 3 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, lpszClassName, nMaxCount );
#else
PWND_GETCLASSNAME lpGetClassName;
CALLSTACK cs;
int retv = 0;
if( API_Enter( API_WND, WND_GETCLASSNAME, &lpGetClassName, &cs ) )
{
lpszClassName = MapProcessPtr( lpszClassName, (LPPROCESS)cs.lpvData );
retv = lpGetClassName( hWnd, lpszClassName, nMaxCount );
API_Leave( );
}
return retv;
#endif
}
typedef BOOL ( WINAPI * PWND_ISWINDOW )( HWND );
BOOL WINAPI Wnd_IsWindow( HWND hWnd )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_ISWINDOW, 1 );
cs.arg0 = (DWORD)hWnd ;
return (DWORD)CALL_SERVER( &cs );
#else
PWND_ISWINDOW pIsWindow;// = (PWND_ISWINDOW)lpWindowAPI[WND_ISWINDOW];
CALLSTACK cs;
BOOL bRetv = FALSE;
if( API_Enter( API_WND, WND_ISWINDOW, &pIsWindow, &cs ) )
{
bRetv = pIsWindow( hWnd );
API_Leave( );
}
return bRetv;
#endif
}
/*
typedef BOOL ( WINAPI * PWND_SHOWSCROLLBAR )( HWND, int, BOOL );
BOOL WINAPI Wnd_ShowScrollBar( HWND hWnd, int fnBar, BOOL bShow )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_SHOWSCROLLBAR, 3 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, fnBar, bShow );
#else
PWND_SHOWSCROLLBAR pShowScrollBar;// = (PWND_SHOWSCROLLBAR)lpWindowAPI[WND_SHOWSCROLLBAR];
CALLSTACK cs;
BOOL bRetv = FALSE;
if( API_Enter( API_WND, WND_SHOWSCROLLBAR, &pShowScrollBar, &cs ) )
{
bRetv = pShowScrollBar( hWnd, fnBar, bShow );
API_Leave( );
}
return bRetv;
#endif
}
*/
/*
typedef LRESULT ( WINAPI * PWND_DEFPROC )( HWND, UINT, WPARAM, LPARAM );
LRESULT WINAPI Wnd_DefProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_DEFPROC, 4 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, msg, wParam, lParam );
#else
PWND_DEFPROC pDefProc;// = (PWND_DEFPROC)lpWindowAPI[WND_DEFPROC];
CALLSTACK cs;
LRESULT bRetv = -1;
if( API_Enter( API_WND, WND_DEFPROC, &pDefProc, &cs ) )
{
bRetv = pDefProc( hWnd, msg, wParam, lParam );
API_Leave( );
}
return bRetv;
#endif
}
*/
typedef BOOL ( WINAPI * PWND_DESTROY )( HWND );
BOOL WINAPI Wnd_Destroy( HWND hWnd )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_DESTROY, 1 );
cs.arg0 = (DWORD)hWnd ;
return (DWORD)CALL_SERVER( &cs );
#else
PWND_DESTROY pDestroy;// = (PWND_DESTROY)lpWindowAPI[WND_DESTROY];
CALLSTACK cs;
BOOL bRetv = FALSE;
if( API_Enter( API_WND, WND_DESTROY, &pDestroy, &cs ) )
{
bRetv = pDestroy( hWnd );
API_Leave( );
}
return bRetv;
#endif
}
typedef BOOL ( WINAPI * PWND_ISCHILD )( HWND, HWND );
BOOL WINAPI Wnd_IsChild( HWND hwndParent, HWND hwndChild )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_ISCHILD, 2 );
cs.arg0 = (DWORD)hwndParent;
return (DWORD)CALL_SERVER( &cs, hwndChild );
#else
PWND_ISCHILD pIsChild;// = (PWND_ISCHILD)lpWindowAPI[WND_ISCHILD];
CALLSTACK cs;
BOOL bRetv = FALSE;
if( API_Enter( API_WND, WND_ISCHILD, &pIsChild, &cs ) )
{
bRetv = pIsChild( hwndParent, hwndChild );
API_Leave( );
}
return bRetv;
#endif
}
typedef HWND ( WINAPI * PWND_GETPARENT )( HWND );
HWND WINAPI Wnd_GetParent( HWND hWnd )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_GETPARENT, 1 );
cs.arg0 = (DWORD)hWnd ;
return (HWND)CALL_SERVER( &cs );
#else
PWND_GETPARENT pGetParent;// = (PWND_GETPARENT)lpWindowAPI[WND_GETPARENT];
CALLSTACK cs;
HWND hWndRet = NULL;
if( API_Enter( API_WND, WND_GETPARENT, &pGetParent, &cs ) )
{
hWndRet = pGetParent( hWnd );
API_Leave( );
}
return hWndRet;
#endif
}
typedef HWND ( WINAPI * PWND_SETPARENT )( HWND hwndChild, HWND hwndParent );
HWND WINAPI Wnd_SetParent( HWND hwndChild, HWND hwndParent )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_SETPARENT, 2 );
cs.arg0 = (DWORD)hwndChild;
return (HWND)CALL_SERVER( &cs, hwndParent );
#else
PWND_SETPARENT pSetParent;// = (PWND_SETPARENT)lpWindowAPI[WND_SETPARENT];
CALLSTACK cs;
HWND hWndRet = NULL;
if( API_Enter( API_WND, WND_SETPARENT, &pSetParent, &cs ) )
{
hWndRet = pSetParent( hwndChild, hwndParent );
API_Leave( );
}
return hWndRet;
#endif
}
typedef BOOL ( WINAPI * PWND_ISVISIBLE )( HWND );
BOOL WINAPI Wnd_IsVisible( HWND hWnd )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_ISVISIBLE, 1 );
cs.arg0 = (DWORD)hWnd ;
return (DWORD)CALL_SERVER( &cs );
#else
PWND_ISVISIBLE pIsVisible;// = (PWND_ISVISIBLE)lpWindowAPI[WND_ISVISIBLE];
BOOL bRetv = FALSE;
CALLSTACK cs;
if( API_Enter( API_WND, WND_ISVISIBLE, &pIsVisible, &cs ) )
{
bRetv = pIsVisible( hWnd );
API_Leave( );
}
return bRetv;
#endif
}
typedef BOOL ( WINAPI * PWND_SHOW )( HWND, int );
BOOL WINAPI Wnd_Show(HWND hWnd, int nCmdShow)
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_SHOW, 2 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, nCmdShow );
#else
PWND_SHOW pShow;// = (PWND_SHOW)lpWindowAPI[WND_SHOW];
BOOL bRetv = FALSE;
CALLSTACK cs;
if( API_Enter( API_WND, WND_SHOW, &pShow, &cs ) )
{
bRetv = pShow( hWnd, nCmdShow );
API_Leave( );
}
return bRetv;
#endif
}
typedef BOOL ( WINAPI * PWND_ENABLE )( HWND, BOOL );
BOOL WINAPI Wnd_Enable( HWND hWnd, BOOL bEnable )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_ENABLE, 2 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, bEnable );
#else
PWND_ENABLE pEnable;// = (PWND_ENABLE)lpWindowAPI[WND_ENABLE];
BOOL bRetv = FALSE;
CALLSTACK cs;
if( API_Enter( API_WND, WND_ENABLE, &pEnable, &cs ) )
{
bRetv = pEnable( hWnd, bEnable );
API_Leave( );
}
return bRetv;
#endif
}
typedef BOOL ( WINAPI * PWND_ISENABLED )( HWND );
BOOL WINAPI Wnd_IsEnabled( HWND hWnd )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_ISENABLED, 1 );
cs.arg0 = (DWORD)hWnd ;
return (DWORD)CALL_SERVER( &cs );
#else
PWND_ISENABLED pIsEnable;// = (PWND_ISENABLED)lpWindowAPI[WND_ISENABLED];
BOOL bRetv = FALSE;
CALLSTACK cs;
if( API_Enter( API_WND, WND_ISENABLED, &pIsEnable, &cs ) )
{
bRetv = pIsEnable( hWnd );
API_Leave( );
}
return bRetv;
#endif
}
typedef BOOL ( WINAPI * PWND_SETTEXT )( HWND, LPCSTR );
BOOL WINAPI Wnd_SetText(HWND hWnd, LPCSTR lpcstr)
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_SETTEXT, 2 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, lpcstr );
#else
PWND_SETTEXT pSetText;// = (PWND_SETTEXT)lpWindowAPI[WND_SETTEXT];
BOOL bRetv = FALSE;
CALLSTACK cs;
if( API_Enter( API_WND, WND_SETTEXT, &pSetText, &cs ) )
{
lpcstr = MapProcessPtr( lpcstr, (LPPROCESS)cs.lpvData );
bRetv = pSetText( hWnd, lpcstr );
API_Leave( );
}
return bRetv;
#endif
}
typedef int ( WINAPI * PWND_GETTEXT )( HWND, LPSTR, int );
int WINAPI Wnd_GetText( HWND hWnd, LPSTR lpstr, int nMax )
{
#ifdef CALL_TRAP
CALLTRAP cs;
cs.apiInfo = CALL_API( API_WND, WND_GETTEXT, 3 );
cs.arg0 = (DWORD)hWnd;
return (DWORD)CALL_SERVER( &cs, lpstr, nMax );
#else
PWND_GETTEXT pGetText;// = (PWND_GETTEXT)lpWindowAPI[WND_GETTEXT];
int iRetv = 0;
CALLSTACK cs;
if( API_Enter( API_WND, WND_GETTEXT, &pGetText, &cs ) )
{
lpstr = MapProcessPtr( lpstr, (LPPROCESS)cs.lpvData );
iRetv = pGetText( hWnd, lpstr, nMax );
API_Leave( );
}
return iRetv;
#endif
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?