Restored from previous forum. Originally posted by teachco.
It's only possible to change the font and the text in a textgadget. Is it correct?
Here some wishes for chrismas or earlier :
- transparent, rgb-colored background and text (VERY IMPORTANT)
- bold, italic, underlined, striked, (link?)...
- font height
Thanks
Edited by - teachco on 26 June 2002 14:14:31
More options for textgadget needed
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
In that case, you could load the same font with the new height and change the gadget font before you create the text gadget. That's what would have to happen internally, so it's not like it would be any more work (well, it changes whether you or Fred has the extra work- font height

--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by teachco.
Yes, that's a good idea with fontheight. Thank you.
I think, from the wishes above, the transparent- and color-feature for text and background is the most important one, because I've absolutly no idea how I can change the gray background of gadgets.
Yes, that's a good idea with fontheight. Thank you.
I think, from the wishes above, the transparent- and color-feature for text and background is the most important one, because I've absolutly no idea how I can change the gray background of gadgets.
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by MrVainSCL.
Here are some informations about the stuff you want/need... I dont want to code a small PB example for that... I think the following docs are more interested... Have a look to it, try to understand it (isnt really hard) and use the API commands you need in your PB source... Hope this will help you a bit...
Hi teachcoteachco wrote:
I think, from the wishes above, the transparent- and color-feature for text and background is the most important one, because I've absolutly no idea how I can change the gray background of gadgets.
Here are some informations about the stuff you want/need... I dont want to code a small PB example for that... I think the following docs are more interested... Have a look to it, try to understand it (isnt really hard) and use the API commands you need in your PB source... Hope this will help you a bit...

Code: Select all
[u]Introduction:[/u]
This article is just going to show you how to implement fonts into your game. The target is mostly for beginners. I will show you the easiest way(in my opinion) to do it. This tutorial will be in 16-bit Direct X and assumes that you have everything set up. It will use lpddsback as the back buffer.
[u]Setting it up:[/u]
First you want to make a new HFONT variable like so:
HFONT fnt;
Then you want to fill in the with the CreateFont Function:
//Fill in the structure with default
// values and use the Arial Font
Fnt = CreateFont(14,0,0,0,0,0,0,0,0,0,0,0,0, "Arial")
What that does is tell windows to use Arial with all the default values. The next step is creating a function to use this information
[u]Drawing Text:[/u]
Making the function to draw text using GDI is straight forward enough so I will just show you the function:
void Draw_Text(char *text, int x,int y,
COLORREF color,
LPDIRECTDRAWSURFACE lpdds,
HFONT fnt)
{
//this function draws text in 16-bit DX mode
// with the selected font
HDC dc; // the dc
// get the dc from surface
lpdds->GetDC(&dc)
// set the colors
SetTextColor(dc,color);
// set background mode to transparent
// so black isn't copied
SetBkMode(dc, TRANSPARENT);
// draw the text using the font
SelectObject(dc, fnt);
TextOut(dc,x,y,text,strlen(text));
// release the dc
lpdds->ReleaseDC(dc);
} // end Draw_Text
[u]Using all of this[/u]
Now I will show you an example of how to use all this to use fonts:
//First make the font
HFONT fnt;
Fnt = CreateFont(14,0,0,0,0,0,0,0,0,0,0,0,0,"Arial");
//Draw the text in Arial
Draw_Text("This text is in Arial at Size 14",
0,0,RGB(255, 255, 255), lpddsback, fnt);
And that's all there is to it. You can change the font size by changing the 14 in the above example, and you can change the font face by changing the text in parentheses. For more information look in your compilers on-line documentation(assuming MSVC) for CreateFont. That will tell you what every parameter does.
PIII450, 256MB Ram, 6GB HD, RivaTNT, DirectX8.1, SB AWE64, Win2000 + all Updates...
greetz
MrVainSCL! aka Thorsten
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
- PureBasic Guru
- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by tinman.
.
As for redraw problems, what do you mean? I found that I sometimes needed to force a redraw, which you can use "HideGadget(x,1) : HideGadget(x,0)" to do.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
If your background is fairly static, you could grab an image from the background, write your text over the top of it (onto the image you just grabbed) and then use that image as a gadget. Maybe this is what MrVain's code did (I don't know, it went way over my headDrawText is not the problem. Here transparent-mode is possible but not for gadgets. And gadgets I need to solve some redraw problems.

As for redraw problems, what do you mean? I found that I sometimes needed to force a redraw, which you can use "HideGadget(x,1) : HideGadget(x,0)" to do.
--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)