|
From: Marc H. <ma...@e-...> - 2002-10-01 13:24:29
|
Hi,
I had a similar problem using the common font dialog in VB. As far as I can
remember you have to specify a type of font to list using one of the flags
otherwise Windows doesn't know which fonts to enumerate.
CF_WYSIWYG, CF_PRINTERFONTS or CF_TTONLY
_____________________________
Marc Heiligers
-----Original Message-----
From: Vlada Djurovic [mailto:dj...@im...]
Sent: 01 October 2002 12:57 PM
To: DevC++ help
Subject: [Dev-C++] fonts
Hi.
I have a strange problem: I want to use ChooseFont API function to display
font selection dialog. I wrote a procedure, compiled, but when I start the
application and press choose font from the menu, I get the message: "There
are no fonts instaled. Open Fonts folder in Control Panel to install
fonts.". Of course, fonts are installed. I have Windows 2000 and DevCpp
4.9.5.0. Can anyone tell me what could cause this? Here is the code I wrote
to display font dialog:
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FORMAT_FONT:
{
CHOOSEFONT chFont;
chFont.lStructSize=sizeof(CHOOSEFONT);
chFont.hwndOwner=hwnd;
chFont.lpLogFont=&lFont;
chFont.iPointSize=1;
chFont.Flags=CF_INITTOLOGFONTSTRUCT|CF_EFFECTS;
chFont.rgbColors=RGB(0,0,0);
chFont.nFontType=REGULAR_FONTTYPE;
if(!ChooseFont(&chFont))
MessageBox(hwnd,"Error in font
dialog","Error",MB_OK|MB_ICONSTOP);
}
break;
}
|
|
From: Marc H. <ma...@e-...> - 2002-10-02 08:02:38
|
Hi, I just had a look at msdn.microsoft.com and this is the example they provide: HWND hwnd; // owner window HDC hdc; // display device context of owner window CHOOSEFONT cf; // common dialog box structure static LOGFONT lf; // logical font structure static DWORD rgbCurrent; // current text color HFONT hfont, hfontPrev; DWORD rgbPrev; // Initialize CHOOSEFONT ZeroMemory(&cf, sizeof(cf)); cf.lStructSize = sizeof (cf); cf.hwndOwner = hwnd; cf.lpLogFont = &lf; cf.rgbColors = rgbCurrent; cf.Flags = CF_SCREENFONTS | CF_EFFECTS; if (ChooseFont(&cf)==TRUE) { hfont = CreateFontIndirect(cf.lpLogFont); hfontPrev = SelectObject(hdc, hfont); rgbCurrent= cf.rgbColors; rgbPrev = SetTextColor(hdc, rgbCurrent); . . . } The only differences I can see is that: 1. They specify CF_SCREENFONTS, but you said you tried that 2. They ZeroMemory the CHOOSEFONT struct before use. Common dialog examples can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI /WindowsUserInterface/UserInput/CommonDialogBoxLibrary/UsingCommonDialogBoxe s.asp <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinU I/WindowsUserInterface/UserInput/CommonDialogBoxLibrary/UsingCommonDialogBox es.asp> Also the full set of flags can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui /windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxrefere nce/commondialogboxstructures/choosefont.asp <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winu i/windowsuserinterface/userinput/commondialogboxlibrary/commondialogboxrefer ence/commondialogboxstructures/choosefont.asp> _____________________________ Marc Heiligers -----Original Message----- From: Vlada Djurovic [mailto:dj...@im...] Sent: 02 October 2002 09:39 AM To: 'Marc Heiligers'; 'DevC++ help' Subject: RE: [Dev-C++] fonts Hi, Marc Thanks for your help, but it still doesn't work. I still get the same message. Can it be that I need to include some header files? I included windows.h and commdlg.h. Or maybe there is a problem with my Windows 200? Regards, Vlada -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Marc Heiligers Sent: utorak, 1. oktobar 2002 15:27 To: 'Vlada Djurovic'; DevC++ help Subject: RE: [Dev-C++] fonts Hi, I had a similar problem using the common font dialog in VB. As far as I can remember you have to specify a type of font to list using one of the flags otherwise Windows doesn't know which fonts to enumerate. CF_WYSIWYG, CF_PRINTERFONTS or CF_TTONLY _____________________________ Marc Heiligers -----Original Message----- From: Vlada Djurovic [mailto:dj...@im...] Sent: 01 October 2002 12:57 PM To: DevC++ help Subject: [Dev-C++] fonts Hi. I have a strange problem: I want to use ChooseFont API function to display font selection dialog. I wrote a procedure, compiled, but when I start the application and press choose font from the menu, I get the message: "There are no fonts instaled. Open Fonts folder in Control Panel to install fonts.". Of course, fonts are installed. I have Windows 2000 and DevCpp 4.9.5.0. Can anyone tell me what could cause this? Here is the code I wrote to display font dialog: case WM_COMMAND: switch(LOWORD(wParam)) { case ID_FORMAT_FONT: { CHOOSEFONT chFont; chFont.lStructSize=sizeof(CHOOSEFONT); chFont.hwndOwner=hwnd; chFont.lpLogFont=&lFont; chFont.iPointSize=1; chFont.Flags=CF_INITTOLOGFONTSTRUCT|CF_EFFECTS; chFont.rgbColors=RGB(0,0,0); chFont.nFontType=REGULAR_FONTTYPE; if(!ChooseFont(&chFont)) MessageBox(hwnd,"Error in font dialog","Error",MB_OK|MB_ICONSTOP); } break; } |
|
From: Vlada D. <dj...@im...> - 2002-10-02 09:54:24
|
MessageHi, Marc This solved my problem. Thanks. ----- Original Message -----=20 From: Marc Heiligers=20 To: 'Vlada Djurovic' ; 'DevC++ help'=20 Sent: Wednesday, October 02, 2002 10:04 AM Subject: RE: [Dev-C++] fonts Hi, =20 I just had a look at msdn.microsoft.com and this is the example they = provide: =20 HWND hwnd; // owner window HDC hdc; // display device context of owner window CHOOSEFONT cf; // common dialog box structure static LOGFONT lf; // logical font structure static DWORD rgbCurrent; // current text color HFONT hfont, hfontPrev; DWORD rgbPrev; // Initialize CHOOSEFONT ZeroMemory(&cf, sizeof(cf)); cf.lStructSize =3D sizeof (cf); cf.hwndOwner =3D hwnd; cf.lpLogFont =3D &lf; cf.rgbColors =3D rgbCurrent; cf.Flags =3D CF_SCREENFONTS | CF_EFFECTS; if (ChooseFont(&cf)=3D=3DTRUE) { hfont =3D CreateFontIndirect(cf.lpLogFont); hfontPrev =3D SelectObject(hdc, hfont); rgbCurrent=3D cf.rgbColors; rgbPrev =3D SetTextColor(hdc, rgbCurrent); . . . } The only differences I can see is that: 1. They specify CF_SCREENFONTS, but you said you tried that 2. They ZeroMemory the CHOOSEFONT struct before use. =20 Common dialog examples can be found at: =20 = http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/winui/= WinUI/WindowsUserInterface/UserInput/CommonDialogBoxLibrary/UsingCommonDi= alogBoxes.asp =20 Also the full set of flags can be found at: =20 = http://msdn.microsoft.com/library/default.asp?url=3D/library/en-us/winui/= winui/windowsuserinterface/userinput/commondialogboxlibrary/commondialogb= oxreference/commondialogboxstructures/choosefont.asp _____________________________ Marc Heiligers -----Original Message----- From: Vlada Djurovic [mailto:dj...@im...]=20 Sent: 02 October 2002 09:39 AM To: 'Marc Heiligers'; 'DevC++ help' Subject: RE: [Dev-C++] fonts Hi, Marc Thanks for your help, but it still doesn't work. I still get the = same message. Can it be that I need to include some header files? I = included windows.h and commdlg.h. Or maybe there is a problem with my = Windows 200? =20 Regards, Vlada =20 -----Original Message----- From: dev...@li... = [mailto:dev...@li...] On Behalf Of Marc = Heiligers Sent: utorak, 1. oktobar 2002 15:27 To: 'Vlada Djurovic'; DevC++ help Subject: RE: [Dev-C++] fonts =20 Hi, =20 I had a similar problem using the common font dialog in VB. As far = as I can remember you have to specify a type of font to list using one = of the flags otherwise Windows doesn't know which fonts to enumerate. =20 CF_WYSIWYG, CF_PRINTERFONTS or CF_TTONLY =20 =20 _____________________________ Marc Heiligers -----Original Message----- From: Vlada Djurovic [mailto:dj...@im...]=20 Sent: 01 October 2002 12:57 PM To: DevC++ help Subject: [Dev-C++] fonts Hi. I have a strange problem: I want to use ChooseFont API function to = display font selection dialog. I wrote a procedure, compiled, but when I = start the application and press choose font from the menu, I get the = message: "There are no fonts instaled. Open Fonts folder in Control = Panel to install fonts.". Of course, fonts are installed. I have Windows = 2000 and DevCpp 4.9.5.0. Can anyone tell me what could cause this? Here = is the code I wrote to display font dialog: =20 case WM_COMMAND: switch(LOWORD(wParam)) { case ID_FORMAT_FONT: { CHOOSEFONT chFont; chFont.lStructSize=3Dsizeof(CHOOSEFONT); chFont.hwndOwner=3Dhwnd; chFont.lpLogFont=3D&lFont; chFont.iPointSize=3D1; = chFont.Flags=3DCF_INITTOLOGFONTSTRUCT|CF_EFFECTS; chFont.rgbColors=3DRGB(0,0,0); chFont.nFontType=3DREGULAR_FONTTYPE; if(!ChooseFont(&chFont)) MessageBox(hwnd,"Error in font = dialog","Error",MB_OK|MB_ICONSTOP); } break; } |
|
From: Vlada D. <dj...@im...> - 2002-10-02 07:37:46
|
Hi, Marc
Thanks for your help, but it still doesn't work. I still get the same
message. Can it be that I need to include some header files? I included
windows.h and commdlg.h. Or maybe there is a problem with my Windows
200?
Regards, Vlada
-----Original Message-----
From: dev...@li...
[mailto:dev...@li...] On Behalf Of Marc
Heiligers
Sent: utorak, 1. oktobar 2002 15:27
To: 'Vlada Djurovic'; DevC++ help
Subject: RE: [Dev-C++] fonts
Hi,
I had a similar problem using the common font dialog in VB. As far as I
can remember you have to specify a type of font to list using one of the
flags otherwise Windows doesn't know which fonts to enumerate.
CF_WYSIWYG, CF_PRINTERFONTS or CF_TTONLY
_____________________________
Marc Heiligers
-----Original Message-----
From: Vlada Djurovic [mailto:dj...@im...]
Sent: 01 October 2002 12:57 PM
To: DevC++ help
Subject: [Dev-C++] fonts
Hi.
I have a strange problem: I want to use ChooseFont API function to
display font selection dialog. I wrote a procedure, compiled, but when I
start the application and press choose font from the menu, I get the
message: "There are no fonts instaled. Open Fonts folder in Control
Panel to install fonts.". Of course, fonts are installed. I have Windows
2000 and DevCpp 4.9.5.0. Can anyone tell me what could cause this? Here
is the code I wrote to display font dialog:
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FORMAT_FONT:
{
CHOOSEFONT chFont;
chFont.lStructSize=sizeof(CHOOSEFONT);
chFont.hwndOwner=hwnd;
chFont.lpLogFont=&lFont;
chFont.iPointSize=1;
chFont.Flags=CF_INITTOLOGFONTSTRUCT|CF_EFFECTS;
chFont.rgbColors=RGB(0,0,0);
chFont.nFontType=REGULAR_FONTTYPE;
if(!ChooseFont(&chFont))
MessageBox(hwnd,"Error in font
dialog","Error",MB_OK|MB_ICONSTOP);
}
break;
}
|
|
From: Carlos d. M. <cg...@wo...> - 2002-10-02 10:10:55
|
First, Your mail is messed with the text you're answering and your answer, and it's really hard to read it. You shall define a LOGFONT before the use of the definition of the CHOOSEFONT and initialize the lpLogFont field of CHOOSEFONT with it. And then you select this on a HFONT, with CreateFontIndirect(LPLOGFONT). Anyway, if it's there and I didn't see it, check the CHOOSEFONT specification at your Win32 API reference, perhaps there is some field you should initialize due to the use of some option and you're not initializing it. I did a simple experiment with it and I had the same error (win2k), till I realized that I hadn't initialize the Flags field of CHOOSEFONT, and then it disappeared. |