Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Checklist limited to 255

Author
Message
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 30th Jun 2008 18:46
Is there any way of getting round the maximum checklist limitation? I need it for the perform checklist for fonts (I have well over a thousand fonts).

And I have searched.


Did you know - 12% of Americans believe Joan of Arc was Noah's wife.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Jul 2008 08:30
Well, if you are any good with dlls you could use the win32 api and enumerate the fonts yourself. Without writing your own dll you could use the winapi and ChooseFont function. Though I think you would have to install all the desired fonts for them to be picked up by the DBC app. - in which case you'd call AddFontResource() from the winapi.

You could also use perform checklist for files in the font directory. You'd use the checklist string$() to return the file names, then you'd have to get the actual name of the typeface out of the filename. The place where the name is in each file can vary depending on the whether it's truetype or a raster/vector font. Most likely you'd have to install all of these fonts as a resource in the application. I'm not sure if DarkBasic does that already (maybe only the first 255?) I think maybe fonts are installed on demand using the Set Font command so they are not all already there.

The perform checklist for files function could also be used in the ChooseFont method to aid you in installing the fonts for the application you are writing.

Enjoy your day.
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 3rd Jul 2008 19:43
Thanks Latch, I'm not very good with DLLs, could you post some example code?


Did you know - 12% of Americans believe Joan of Arc was Noah's wife.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 3rd Jul 2008 23:31
Ok,

Here's the bare bones check font directory filenames. It only returns the files in there, does check to make sure they are only fonts, and it doesn't look in the files for their names, but it gives you an idea of the method that you could expand on:



Here's the ChooseFont method:
I went ahead and created another "bare bones" example DLL that uses the ChooseFile() function from the win32 api. Here is the main function in C of the DLL:



If you look up the ChooseFont function, you'll see that there are two structures (If you are familiar with types, a structure is basically a type - a block of memory of a series of named data types) CHOOSEFONT and LOGFONT. By setting the different members of CHOOSEFONT, I can tell the font dialog box basically how to behave. I use the LOGFONT structure to get the return values as a result of selecting an item from the font dialog box.

The parameters for my function dbcFontDialog(HWND hwnd, char *selection) are the parameters that DBC is going to pass to the DLL.
hwnd is the handle of the DBC window. This can be NULL (or zero in DBC) in which case the Font Dialog box won't have an owner. The parameter char *selection is a string variable that will be passed from DBC. In C, it's a pointer to an area of memory. DBC automagically creates a pointer when it creates a string and this is really what I'm passing to the DLL: the pointer to the string information.

Once the user has selected a font in the dialog box, the command
strcpy(selection,lf.lfFaceName);
copies the string information from the member lfFaceName of my LOGFONT structure to the selection pointer (the string variable in DBC). This is returned to DBC.

I'll attach a copy of the actual DLL.

Here is the code to run from DBC when using the DLL:


It works best in windowed mode. If you don't use windowed mode, I think you'll have to naviaget the font box without the mouse useing TAB and arrow keys.

There are options for the choosefont dialog box. This example just gets it running and returning a font name. If you have access to a C/C++ compiler and some time if you are not too familiar with C, you may be able to play with and modify the code to your liking.

You can also recreate this in DBC alone without creating your own DLL by using memblocks to create the necessary structures. You'll have to make them the correct size however which can be tricky. You call ChooseFont() from comdlg32.dll:
assuming choosptr is a memblock pointer to CHOOSEFONT structure and
comdlg32 is the loaded dll number:
call dll comdlg32,"ChooseFontA",chooseptr

I haven't tried enumerating the fonts yet... It's a little more complicated... I'll see how I feel about giving that a go.

Enjoy your day.

Attachments

Login to view attachments
NanoGamez guy
18
Years of Service
User Offline
Joined: 13th Jan 2007
Location: Closer than you think...
Posted: 4th Jul 2008 21:42
Wow Latch, That's excellent! Thank you very much, that helped me alot.


Did you know - 12% of Americans believe Joan of Arc was Noah's wife.

Login to post a reply

Server time is: 2025-06-06 00:04:13
Your offset time is: 2025-06-06 00:04:13