buildh32.bat tim
tim.prg
- Code: Select all Expand view RUN
- #include "FiveWin.ch"
function Main()
local oWnd
DEFINE WINDOW oWnd
ACTIVATE WINDOW oWnd ;
ON PAINT PrnSayRTF( hDC )
return nil
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
#include <Richedit.h>
#include <TextServ.h>
#include <memory>
EXTERN_C const IID IID_ITextHost = {
0xc5bdd8d0,
0xd26e,
0x11ce,
{ 0xa8, 0x9e, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5 }
};
EXTERN_C const IID IID_ITextServices = {
0x8d33f740,
0xcf58,
0x11ce,
{ 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5 }
};
typedef HRESULT ( _stdcall * PCREATETEXTSERVICES ) ( IUnknown *, ITextHost *, IUnknown ** );
class TextHost : public ITextHost {
public:
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override {
if (ppvObject == nullptr) {
return E_POINTER;
}
if ((riid == IID_IUnknown) || (riid == IID_ITextHost)) {
*ppvObject = this;
return S_OK;
}
*ppvObject = nullptr;
return E_NOINTERFACE;
}
ULONG __stdcall AddRef(void) override {
return 0;
}
ULONG __stdcall Release(void) override {
return 0;
}
HDC TxGetDC() override {
return nullptr;
}
INT TxReleaseDC(HDC hdc) override {
return 0;
}
BOOL TxShowScrollBar(INT fnBar, BOOL fShow) override {
return FALSE;
}
BOOL TxEnableScrollBar(INT fuSBFlags, INT fuArrowflags) override {
return FALSE;
}
BOOL TxSetScrollRange(INT fnBar, LONG nMinPos, INT nMaxPos, BOOL fRedraw) override {
return FALSE;
}
BOOL TxSetScrollPos(INT fnBar, INT nPos, BOOL fRedraw) override {
return FALSE;
}
void TxInvalidateRect(LPCRECT prc, BOOL fMode) override {
}
void TxViewChange(BOOL fUpdate) override {
}
BOOL TxCreateCaret(HBITMAP hbmp, INT xWidth, INT yHeight) override {
return FALSE;
}
BOOL TxShowCaret(BOOL fShow) override {
return FALSE;
}
BOOL TxSetCaretPos(INT x, INT y) override {
return FALSE;
}
BOOL TxSetTimer(UINT idTimer, UINT uTimeout) override {
return FALSE;
}
void TxKillTimer(UINT idTimer) override {
}
void TxScrollWindowEx(INT dx, INT dy, LPCRECT lprcScroll, LPCRECT lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate, UINT fuScroll) override {
}
void TxSetCapture(BOOL fCapture) override {
}
void TxSetFocus() override {
}
void TxSetCursor(HCURSOR hcur, BOOL fText) override {
}
BOOL TxScreenToClient(LPPOINT lppt) override {
return FALSE;
}
BOOL TxClientToScreen(LPPOINT lppt) override {
return FALSE;
}
HRESULT TxActivate(LONG * plOldState) override {
return E_NOTIMPL;
}
HRESULT TxDeactivate(LONG lNewState) override {
return E_NOTIMPL;
}
HRESULT TxGetClientRect(LPRECT prc) override {
return E_NOTIMPL;
}
HRESULT TxGetViewInset(LPRECT prc) override {
return E_NOTIMPL;
}
HRESULT TxGetCharFormat(const CHARFORMATW **ppCF) override {
if (char_format_ == nullptr) {
char_format_ = std::make_unique<CHARFORMATW>();
char_format_->cbSize = sizeof(CHARFORMATW);
}
*ppCF = char_format_.get();
return S_OK;
}
HRESULT TxGetParaFormat(const PARAFORMAT **ppPF) override {
if (para_format_ == nullptr) {
para_format_ = std::make_unique<PARAFORMAT>();
para_format_->cbSize = sizeof PARAFORMAT;
}
*ppPF = para_format_.get();
return S_OK;
}
COLORREF TxGetSysColor(int nIndex) override {
return GetSysColor(nIndex);
}
HRESULT TxGetBackStyle(TXTBACKSTYLE *pstyle) override {
return E_NOTIMPL;
}
HRESULT TxGetMaxLength(DWORD *plength) override {
return E_NOTIMPL;
}
HRESULT TxGetScrollBars(DWORD *pdwScrollBar) override {
return E_NOTIMPL;
}
HRESULT TxGetPasswordChar(_Out_ TCHAR *pch) override {
return E_NOTIMPL;
}
HRESULT TxGetAcceleratorPos(LONG *pcp) override {
return E_NOTIMPL;
}
HRESULT TxGetExtent(LPSIZEL lpExtent) override {
return E_NOTIMPL;
}
HRESULT OnTxCharFormatChange(const CHARFORMATW * pCF) override {
return E_NOTIMPL;
}
HRESULT OnTxParaFormatChange(const PARAFORMAT * pPF) override {
return E_NOTIMPL;
}
HRESULT TxGetPropertyBits(DWORD dwMask, DWORD *pdwBits) override {
*pdwBits = 0;
return S_OK;
}
HRESULT TxNotify(DWORD iNotify, void *pv) override {
return E_NOTIMPL;
}
HIMC TxImmGetContext() override {
return nullptr;
}
void TxImmReleaseContext(HIMC himc) override {
}
HRESULT TxGetSelectionBarWidth(LONG *lSelBarWidth) override {
*lSelBarWidth = 0;
return S_OK;
}
private:
std::unique_ptr<CHARFORMATW> char_format_;
std::unique_ptr<PARAFORMAT> para_format_;
};
HB_FUNC( PRNSAYRTF )
{
IUnknown * unknown;
TextHost textHost;
HMODULE hDLL = LoadLibrary( "riched20.dll" );
PCREATETEXTSERVICES pCreateTextServices = ( PCREATETEXTSERVICES ) GetProcAddress( hDLL, "CreateTextServices" );
ITextServices * pTextServices;
RECT rect;
rect.top = 0;
rect.left = 0;
rect.bottom = 200;
rect.right = 200;
pCreateTextServices( nullptr, &textHost, &unknown );
unknown->QueryInterface( IID_ITextServices, ( void ** ) &pTextServices );
pTextServices->TxSetText( L"Yes, its working!" );
pTextServices->TxDraw( DVASPECT_CONTENT, 0, nullptr, nullptr, ( HDC ) hb_parnl( 1 ),
nullptr, ( LPCRECTL ) &rect, nullptr, nullptr, nullptr, 0, 0 );
FreeLibrary( hDLL );
}
#pragma ENDDUMP