 |
|
|
 |
|
 |
Thx for such a useful code. When I run your application independtly it executes successfully, but when I incorporated files in my project and build the application it give following error.
error C2664: 'strlen' : cannot convert parameter 1 from 'unsigned short [32]' to 'const char *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
error is on following part of code
BOOL CALLBACK FPC_EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData)
{
CFontPreviewCombo *pThis = reinterpret_cast<CFontPreviewCombo*>(lpData);
int index = pThis->AddString(lplf->lfFaceName);
ASSERT(index!=-1);
int maxLen = lptm->tmMaxCharWidth * strlen(lplf->lfFaceName); *error*
int ret = pThis->SetItemData (index, dwType);
ASSERT(ret!=-1);
pThis->AddFont (lplf->lfFaceName);
return TRUE;
}
Help in this regard is really appreciated.
Thx
|
|
|
|
 |
|
 |
When used in NEW Visual Studio 2003 or 5 projects the drop down list only contains one visible item at a time. Importing the project and converting it to the newer formats does not affect operation. I have tried another similar project with the same result. I suspect some sort of owner draw problem with the projects created by the new compilers, but any assistance would be appreciated.
The test projects are available to anyone interested in this problem, please email.
-- modified at 9:31 Saturday 21st October, 2006
|
|
|
|
 |
|
 |
Has anyone else noticed that when the droplist is displayed and the mouse wheel is used to scroll through the choices, that the visual refresh of the list is always top-down??
Give it a try - it won't matter which direction you scroll with the mouse, the list will always appear to scroll in the same direction - no reverse when the mouse wheel reverses direction. I've looked a little into the sources, but it isn't apparent to me how MeasureItem and DrawItem would be controlling that behavior. Is this a "feature" of owner-drawn drop-lists for comboboxes?
Any ideas on how to correct [eliminate the feature] the behavior so the visual feedback is more intuitive and pleasing?
Thanks!
|
|
|
|
 |
|
 |
It is a bug with the animation of the listbox control and is dependent on the system visual effects settings.
If the "smooth-scroll list boxes" visual effects setting is checked (in XP this is located in System Properties | Advanced | Visual Effects | Custom...) AND the listbox is owner-draw, then the animation of the control gets screwed up. A hack I have used is to call SystemParametersInfo using the SPI_SETLISTBOXSMOOTHSCROLLING parameter to enable and disable this when the control gains and loses focus, respectively. You should reset the users visual effect settings back to the original state when the control loses focus.
Undoubtably, you have the smooth scroll setting enabled on your system if you are seeing this animation bug. I find it interesting that not much can be found written about this bug.
-- modified at 0:32 Saturday 28th January, 2006
|
|
|
|
 |
|
 |
Hello,
Debuger finds memeory leak while runing example program:
Detected memory leaks!
Dumping objects ->
c:\documents and settings\darius\desktop\aa\fontpreviewcombo.cpp(336) : {141} client block at 0x00376230, subtype c0, 8 bytes long.
a CFont object at $00376230, 8 bytes long
Object dump complete.
The program '[548] FasterFont.exe: Native' has exited with code 0 (0x0).
Please any comments
Darius
|
|
|
|
 |
|
 |
i can't reproduce it, so i'm guessing it's because the font's are being placed in a map based on their name, and if it turns out you have two fonts with the same face name you end up losing the pointer to the first one.
this might fix it:
void
CFontPreviewCombo::AddFont (const CString& faceName)
{
if (m_style != NAME_GUI_FONT)
{
CFont* cf = new CFont;
BOOL createFontResult =
cf->CreateFont(m_iFontHeight,0,0,0,FW_NORMAL,FALSE, FALSE,
FALSE,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH, faceName);
_ASSERTE (createFontResult);
CFont *pDummy;
BOOL lookupResult = m_fonts.Lookup (faceName, (void*&)pDummy) != NULL;
int i = 2;
CString originalFaceName = faceName;
CString newFaceName = faceName;
while (lookupResult)
{
newFaceName.Format("%s [%d]", originalFaceName, i);
lookupResult = m_fonts.Lookup (newFaceName , (void*&)pDummy) != NULL;
i++;
}
m_fonts.SetAt(newFaceName, cf);
}
}
note that this only applies to the updated code, as my original code doesn't use a map.
Cleek / Software
|
|
|
|
 |
|
 |
Thank's that solved the problem!
Only one notice:
should be:
lookupResult = m_fonts.Lookup (newFaceName, (void*&)pDummy) != NULL;
and it was endless loop:
lookupResult = m_fonts.Lookup (FaceName, (void*&)pDummy) != NULL;
Best regards
Darius
|
|
|
|
 |
|
 |
Good find Chris and Darius....
|
|
|
|
 |
|
 |
This is a tiny little thing, but I'm desparate to give something back to this community that has given me so much.
I'm using this in a modeless dialog and would like to use a different sample string when the program state changes.
Changing the m_csSample variable is easy enough, but you'll get errors if you try to run Init() again.
I just cloned the Init function, called it Refresh, and removed this line:
m_img.Create(IDB_TTF_BMP, GLYPH_WIDTH, 1, RGB(255,255,255));
Works like a charm.
Thanks Dave and Chris.
-----------
ps- I also wanted to list only TrueType fonts. So I added this to the EnumFonts callback routine ("FPC_EnumFontProc"):
if ((lptm->tmPitchAndFamily & TMPF_TRUETYPE)) {
}
open the conditional at the beginning and close it before the return statement.
|
|
|
|
 |
|
 |
is there any way of controling Combo Client size (edit box+ dropdown arrow) apart from CComboBox::SetFont()?
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Email: y_becker@netvision.net.il
|
|
|
|
 |
|
 |
If you're using the Resource Editor to create your ComboBox, you can click on the down arrow in the editor and that lets you modify the total displayed height of the control.
|
|
|
|
 |
|
 |
Dear Dave,
i want to embed a combobox inside a list control subitem. now, by changing the combo font size i can control the combo (==edit+arrow == -1 item) size (SetItemHeight(-1, x) fails here), and visibly make it smaller than system default (without resorting to Owner-Drawn combo). alas, i wish to programatically quantify the combo frame VISIBLE size, to some actual pixel measure (i do not wish to use the resource editor). i cannot get it with GetClient\WindowRect() because of unknown reasons (which have nothing to do with drop down list size).
i hope i could profit from your experience.
Thank you , , yonatan
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Email: y_becker@netvision.net.il
|
|
|
|
 |
|
 |
Hello everyone,
I have created an ActiveX Ctrl with a combo box in it.
I filled in the items in the combo box through the Data tab in the properties dialog box of the combo box but the problem is that whenever I test it using the ActiveX Control Test Container, there is nothing in the drop down list of the combo box.
So, I tried again, this time using a for loop to insert the items in the combo box like this:
char *cFont[3]={"Arial","Times New Roman","Batang"};
for(int k=0; k<3; k++)
comboCtrl->AddString(cFont[k]);
But the same problem still persists. There are no items in the drop down list of the combo box.
Are there any alternate ways to add the items into the combo box control so that the items show each time I pull down the list?
Thank you
|
|
|
|
 |
|
 |
I used this Font Combo as a control in a property page. I got error when the program invokes the property sheet the second time and I select the property page with this control. I found the error was due to repeated creation of m_img in Init().
I am not clear where would be better to detach the image list. So I did the following at the beginning of Init:
m_img.Detach();
Is it a good way to solve the problem?
Anyway, this is a good control. It is very helpful to me. Thx.
|
|
|
|
 |
 | Error  |  | Anonymous | 15:13 5 Aug '02 |
|
 |
I add some codes in OnInitDialog , but the application crashs
CFontPreviewCombo* p =new CFontPreviewCombo;
p->m_style = CFontPreviewCombo::NAME_ONLY;
CRect RC( 10,230, 200,440);
p->Create ( WS_VISIBLE | WS_TABSTOP | WS_VSCROLL|CBS_SORT | CBS_HASSTRINGS | CBS_DROPDOWNLIST , RC , this ,160);
p->Init();
|
|
|
|
 |
|
 |
where does it crash?
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
 |
|
 |
Sorry. The codes lost the style CBS_OWNERDRAWVARIABLE :
p->Create ( WS_VISIBLE | WS_TABSTOP | WS_VSCROLL|CBS_SORT | CBS_OWNERDRAWVARIABLE |CBS_HASSTRINGS | CBS_DROPDOWNLIST , RC , this ,160);
When debug to this row , the application crashs.
|
|
|
|
 |
|
 |
step into it
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
 |
|
 |
There's a comment in the code about 'feeling bad on creating this font on each draw'. What do you think about a buffer bitmap with all combo items - in this scenario you create each font once.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
 |
|
 |
do you mean a set of bitmaps, one for each item?
yeah, i guess that would make things more efficient for drawing.
-c
Smaller Animals Software, Inc.
Few things are harder to put up with than the annoyance of a good example.
Mark Twain
|
|
|
|
 |
|
 |
No, I mean one bitmap for all items to reduce the GDI overhead.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
 |
|
 |
Hey Chris I've done something similar (not implying that you based your stuff on mine in any shape or form!), a nice feature that my font combo exhibited was a tooltip showing the font drawn it the selected font. Just thought you could add the same on your font combo.
Normski. - Professional Windows Programmer
|
|
|
|
 |
|
 |
is it on CP? i looked but didn't see it. i did see your font dlg on codeguru. tho.
yeah, i liked that tooltip touch, and the MRU list at the top, too.
i'm afraid if i do that, it will be exactly like your's
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
 |
|
 |
Can u give me a link to your article on the font selection combo with MRU.
Thanks
|
|
|
|
 |