EDN Admin
Well-known member
The functions ScriptStringAnalyse() and ScriptStringOut() dont exhibit anything in the window !!!!!!!!!!!! Why ???????????
If I use ExtTextOut() the characters are printed as expected.<br/>
Both functions return S_OK !!!!!!
<pre class="prettyprint #include <windows.h>
#include <usp10.h>
LRESULT CALLBACK WndProc(HWND, UINT, UINT, LONG);
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pszCmdLine, int nCmdShow)
{
WNDCLASSEX wndclassx;
wndclassx.cbSize = sizeof(WNDCLASSEX);
wndclassx.style = CS_HREDRAW | CS_VREDRAW;
wndclassx.lpfnWndProc = WndProc;
wndclassx.cbClsExtra = 0;
wndclassx.cbWndExtra = 0;
wndclassx.hInstance = hInstance;
wndclassx.hIcon = 0;
wndclassx.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclassx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclassx.lpszMenuName = 0;
wndclassx.lpszClassName = L"WndProc";
wndclassx.hIconSm = 0;
if( !RegisterClassEx(&wndclassx) ) return 0;
HWND hWnd = CreateWindow(L"WndProc", L"WndProc", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, 0, 0, hInstance, 0);
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
MSG msg;
while( GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Retorna msg.wParam
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
static HFONT s_hArial32;
switch ( message )
{
case WM_CREATE:
{
// Create info DC
HDC hInfoDC;
if( !(hInfoDC = CreateIC(L"Display", 0, 0, 0)) ) return -1;
// Get LOGPIXELSY
int iLogPixelsY = GetDeviceCaps(hInfoDC, LOGPIXELSY);
// Create LOGFONT struct with size 32 pts
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(32, iLogPixelsY, 72);
wcscpy_s(lf.lfFaceName, LF_FACESIZE, L"Arial");
// Create font
if( !(s_hArial32 = CreateFontIndirect(&lf)) ) return -1;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
// Set dc background mode and alignment
SetBkMode(ps.hdc, TRANSPARENT);
SetTextAlign(ps.hdc, TA_BASELINE);
// Select s_hArial32
HFONT hFont = (HFONT)SelectObject(ps.hdc, s_hArial32);
wchar_t unicodes[7] = { 0x0061, 0x0062, 0x0020, 0x0750, 0x062D, 0x064C, 0x0651 };
void* p;
HRESULT hres;
hres = ScriptStringAnalyse(ps.hdc, unicodes, 7, 27, -1, SSA_GLYPHS, 0, 0, 0, 0, 0, 0, &p);
hres = ScriptStringOut(&p, 30, 200, 0, 0, 0, 0, false);
ScriptStringFree(&p);
SelectObject(ps.hdc, hFont);
EndPaint(hwnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
[/code]
<br/>
View the full article
If I use ExtTextOut() the characters are printed as expected.<br/>
Both functions return S_OK !!!!!!
<pre class="prettyprint #include <windows.h>
#include <usp10.h>
LRESULT CALLBACK WndProc(HWND, UINT, UINT, LONG);
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pszCmdLine, int nCmdShow)
{
WNDCLASSEX wndclassx;
wndclassx.cbSize = sizeof(WNDCLASSEX);
wndclassx.style = CS_HREDRAW | CS_VREDRAW;
wndclassx.lpfnWndProc = WndProc;
wndclassx.cbClsExtra = 0;
wndclassx.cbWndExtra = 0;
wndclassx.hInstance = hInstance;
wndclassx.hIcon = 0;
wndclassx.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclassx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wndclassx.lpszMenuName = 0;
wndclassx.lpszClassName = L"WndProc";
wndclassx.hIconSm = 0;
if( !RegisterClassEx(&wndclassx) ) return 0;
HWND hWnd = CreateWindow(L"WndProc", L"WndProc", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, 0, 0, hInstance, 0);
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
MSG msg;
while( GetMessage(&msg, NULL, 0, 0) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
// Retorna msg.wParam
return (int)msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, UINT wParam, LONG lParam)
{
static HFONT s_hArial32;
switch ( message )
{
case WM_CREATE:
{
// Create info DC
HDC hInfoDC;
if( !(hInfoDC = CreateIC(L"Display", 0, 0, 0)) ) return -1;
// Get LOGPIXELSY
int iLogPixelsY = GetDeviceCaps(hInfoDC, LOGPIXELSY);
// Create LOGFONT struct with size 32 pts
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(32, iLogPixelsY, 72);
wcscpy_s(lf.lfFaceName, LF_FACESIZE, L"Arial");
// Create font
if( !(s_hArial32 = CreateFontIndirect(&lf)) ) return -1;
}
break;
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint(hwnd, &ps);
// Set dc background mode and alignment
SetBkMode(ps.hdc, TRANSPARENT);
SetTextAlign(ps.hdc, TA_BASELINE);
// Select s_hArial32
HFONT hFont = (HFONT)SelectObject(ps.hdc, s_hArial32);
wchar_t unicodes[7] = { 0x0061, 0x0062, 0x0020, 0x0750, 0x062D, 0x064C, 0x0651 };
void* p;
HRESULT hres;
hres = ScriptStringAnalyse(ps.hdc, unicodes, 7, 27, -1, SSA_GLYPHS, 0, 0, 0, 0, 0, 0, &p);
hres = ScriptStringOut(&p, 30, 200, 0, 0, 0, 0, false);
ScriptStringFree(&p);
SelectObject(ps.hdc, hFont);
EndPaint(hwnd, &ps);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}
[/code]
<br/>
View the full article