Thanks, Dominic, it's crystal clear now.
-CMR
Announcement
Collapse
No announcement yet.
Calling GetGlyphOutline...
Collapse
X
-
The PowerBASIC Win32Api.inc file declares the lpBuffer as
lpBuffer AS ANY
The use of ANY in the include files is a pain in the ...
It would be nice if PB just drop the ANY keyword from all the includes.
Leave a comment:
-
Here is a modified version of you code that works.
Code:FUNCTION Form1_TextBtn1_Clicked _ ( _ BYVAL hWndParent AS DWORD, _ ' handle of parent window BYVAL hWndCtrl AS DWORD _ ' handle of control ) AS LONG LOCAL GlyphMets AS GLYPHMETRICS LOCAL xformation AS MAT2 LOCAL bufferPointer AS DWORD LOCAL hDC AS DWORD LOCAL hFont AS DWORD LOCAL hOldFont AS DWORD LOCAL point_size AS LONG LOCAL points_per_inch AS LONG LOCAL pixels_per_inch AS LONG LOCAL logical_height AS LONG LOCAL bufferSize AS DWORD hDC = GetDC(hWndParent) point_size =30 points_per_inch =72 pixels_per_inch =GetDeviceCaps(hDC, %LOGPIXELSY) logical_height = -MulDiv(point_size, pixels_per_inch, points_per_inch) hFont = CreateFont(logical_height,0,0,0,0,%TRUE,0,0,%ANSI_CHARSET,0,0,0,0,"Times New Roman") hOldFont=SelectObject(hDC, hFont) xformation.eM11.value =1 xformation.eM11.fract =0 xformation.eM12.value =0 xformation.eM12.fract =0 xformation.eM21.value =0 xformation.eM21.fract =0 xformation.eM22.value =1 xformation.eM22.fract =0 bufferSize=GetGlyphOutline(hDC, ASC("A"), %GGO_NATIVE, GlyphMets, 0, BYVAL %NULL, xformation) MSGBOX FORMAT$(bufferSize) bufferPointer = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, bufferSize) IF bufferPointer THEN IF GetGlyphOutline(hDC, ASC("A"), %GGO_NATIVE, GlyphMets, bufferSize, BYVAL bufferPointer, xformation) <> %GDI_ERROR THEN MSGBOX "success" END IF HeapFree GetProcessHeap(), 0, bufferPointer END IF DeleteObject(SelectObject(hDC, hOldFont)) ReleaseDC(hWndParent,hDC) END FUNCTION
Last edited by Dominic Mitchell; 27 Jan 2008, 11:44 AM.
Leave a comment:
-
Calling GetGlyphOutline...
Anyone know why the latter GetGlyphOutline call tanks and produces a '...has encountered a problem and needs to close. We are sorry for the inconvenience' error?
The first call to GetGlyphOutline returns a buffer size of 380 in this case, so that call seems to work. The second call, however, doesn't like what I'm passing to it because I get the error mentioned above. BTW: How does one allocate a buffer of a particular size in PB if one doesn't know the size to begin with? My 'DIM buffer AS STRING*600' was an attempt to get something to work, but I'm sure there's a better way.
Code:hScreenDC=GetDC(%NULL) point_size =30 points_per_inch =72 pixels_per_inch =GetDeviceCaps(hScreenDC, %LOGPIXELSY) logical_height = -MulDiv(point_size, pixels_per_inch, points_per_inch) hFont=CreateFont(logical_height,0,0,0,0,%TRUE,0,0,%ANSI_CHARSET,0,0,0,0,"Times New Roman") hOldFont=SelectObject(hScreenDC, hFont) DIM GlyphMets AS GLYPHMETRICS, xformation AS MAT2, bufferSize AS DWORD, bufferPointer AS STRING POINTER, buffer AS STRING*600 xformation.eM11.value =1 xformation.eM11.fract =0 xformation.eM12.value =0 xformation.eM12.fract =0 xformation.eM21.value =0 xformation.eM21.fract =0 xformation.eM22.value =1 xformation.eM22.fract =0 bufferSize =0 bufferPointer =%NULL bufferSize=GetGlyphOutline(hScreenDC, ASC("A"), %GGO_NATIVE, GlyphMets, bufferSize, bufferPointer, xformation) MSGBOX FORMAT$(bufferSize) bufferPointer=VARPTR(buffer) GetGlyphOutline(hScreenDC, ASC("A"), %GGO_NATIVE, GlyphMets, bufferSize, bufferPointer, xformation) DeleteObject(SelectObject(hScreenDC, hOldFont)) ReleaseDC(%NULL,hScreenDC)
Last edited by C.M. Rouleau; 27 Jan 2008, 09:17 AM.Tags: None
Leave a comment: