by allistar >> Tue, 20 Jul 2004 21:29:02 GMT
Hi all,
I recently had the need to allow the user to select a font from a drop down list. Using the CMDFontDlg was not an option. Here is how it is done:
create an external method on the StringArray class with this signature:
populateWithFonts(hwnd: Integer) is enumerateFonts in gtassist;
(gtassist is the name of the dll I put the "enumerateFonts" function in).
The code in that dll is:
BOOL CALLBACK EnumFontProc(LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData)
{
DskBuffer *pBuffer = (DskBuffer*)lpData;
DskArray self(&pBuffer->oid);
DskParam p1;
paramSetCString(p1, lplf->lfFaceName);
self.sendMsg(TEXT("add"), &p1, 0, __LINE__);
return TRUE;
}
extern "C" int DllExport JOMAPI enumerateFonts(void*, DskBuffer* pBuffer, DskParam* pParam, DskParam*)
{
//get the hwnd passed in
Integer integer;
paramGetInteger(*pParam, integer);
HWND hwnd = (HWND)(int)integer;
HDC dc = GetWindowDC(hwnd);
EnumFonts (dc, 0,(FONTENUMPROC) EnumFontProc,(LPARAM)pBuffer);
return 0;
}
This can be called in JADE to populate a combo box like this:
vars
array: StringArray;
string: String;begin
create array transient;
array.populateWithFonts(cbCombo.hwnd);
foreach string in array do
cbCombo.addItem(string);
endforeach;
epilog
delete array;
end;
This does the trick quite well. I hope someone else can make good use of it.
Regards,
Allistar.
--
------------------------------------------------------------------
Allistar Melville
Software Developer, Analyst allistar@silvermoon.co.nz
Auckland, NEW ZEALAND
Silvermoon Software
Specialising in JADE development and consulting
Visit us at: http://www.silvermoon.co.nz
*NEW* Simple web access to Jade at: www.silvermoon.co.nz/jhp.html ------------------------------------------------------------------