Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
Hi!
 
I am trying to fix a tricky problem but after a few hours I have not yet found the solution!
 
I created a dialog box and I added a combobox object using dialog editor.
You can see the resource file:
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"

#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#ifndef APSTUDIO_INVOKED
#include "targetver.h"
#endif
#include "afxres.h"

/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
 
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32

#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//

1 TEXTINCLUDE 
BEGIN
    "resource.h\0"
END
 
2 TEXTINCLUDE 
BEGIN
    "#ifndef APSTUDIO_INVOKED\r\n"
    "#include ""targetver.h""\r\n"
    "#endif\r\n"
    "#include ""afxres.h""\r\n"
    "\0"
END
 
3 TEXTINCLUDE 
BEGIN
    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
    "#define _AFX_NO_OLE_RESOURCES\r\n"
    "#define _AFX_NO_TRACKER_RESOURCES\r\n"
    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
    "\r\n"
    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
    "LANGUAGE 9, 1\r\n"
    "#pragma code_page(1252)\r\n"
    "#include ""res\\ydtyjy.rc2""  // non-Microsoft Visual C++ edited resources\r\n"
    "#include ""afxres.rc""     // Standard components\r\n"
    "#endif\r\n"
    "\0"
END
 
#endif    // APSTUDIO_INVOKED

 
/////////////////////////////////////////////////////////////////////////////
//
// Version
//

VS_VERSION_INFO VERSIONINFO
 FILEVERSION 1,4,0,0
 PRODUCTVERSION 1,4,0,0
 FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
 FILEFLAGS 0x1L
#else
 FILEFLAGS 0x0L
#endif
 FILEOS 0x4L
 FILETYPE 0x2L
 FILESUBTYPE 0x0L
BEGIN
    BLOCK "StringFileInfo"
    BEGIN
        BLOCK "040904e4"
        BEGIN
            VALUE "CompanyName", "zdfhdrhzf zdhhzdffhd"
            VALUE "FileDescription", "dzhzdfh DLL"
            VALUE "FileVersion", "1.4.0.0"
            VALUE "InternalName", "xcfgdfh.dll"
            VALUE "LegalCopyright", "Copyright (c) ahrh-ahfh zdhdfh zdhhfh.  All rights reserved."
            VALUE "OriginalFilename", "adhrfhdfhh.dll"
            VALUE "ProductName", "dfhadfhfh Dynamic Link Library"
            VALUE "ProductVersion", "1.4.0.0"
        END
    END
    BLOCK "VarFileInfo"
    BEGIN
        VALUE "Translation", 0x409, 1252
    END
END
 

/////////////////////////////////////////////////////////////////////////////
//
// Dialog
//

IDD_MEMTA_DIALOG DIALOGEX 0, 0, 1064, 722
STYLE DS_SETFONT | DS_FIXEDSYS | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "        "
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
    COMBOBOX        IDC_UIFIGYF_COMBO,23,7,85,92,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
 

/////////////////////////////////////////////////////////////////////////////
//
// DESIGNINFO
//

#ifdef APSTUDIO_INVOKED
GUIDELINES DESIGNINFO 
BEGIN
    IDD_MEMTA_DIALOG, DIALOG
    BEGIN
        LEFTMARGIN, 7
        RIGHTMARGIN, 1060
        TOPMARGIN, 7
        BOTTOMMARGIN, 718
    END
END
#endif    // APSTUDIO_INVOKED

#endif    // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////

 
/////////////////////////////////////////////////////////////////////////////
// English (Canada) resources

#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENC)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_CAN
#pragma code_page(1252)
#endif //_WIN32

/////////////////////////////////////////////////////////////////////////////
//
// Bitmap
//

#endif    // English (Canada) resources
/////////////////////////////////////////////////////////////////////////////

 

#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#define _AFX_NO_SPLITTER_RESOURCES
#define _AFX_NO_OLE_RESOURCES
#define _AFX_NO_TRACKER_RESOURCES
#define _AFX_NO_PROPERTY_RESOURCES
 
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE 9, 1
#pragma code_page(1252)
#include "res\dfjjgj.rc2"  // non-Microsoft Visual C++ edited resources
#include "afxres.rc"     // Standard components
#endif
 
/////////////////////////////////////////////////////////////////////////////
#endif    // not APSTUDIO_INVOKED
 
After I added a second combobox by hand:
//Header file
CComboBox myCombo;
//Source file
myCombo.Create(CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP, CRect(37,146,37+75,146+105), this, 4008+i*100);
 
The same problem occurs according to others control objet (CStatic class, CEdit class, etc); in conclusion, this is what you see:
http://img52.imageshack.us/img52/1002/unledul.png[^]
 
Why are 2 combobox objets visually different?
What should I add in my code in order to make graphical appearance of the second combobox equal to the first one?
 
Thanks!
 
(If in doubt do not hesitate to ask questions.)
Posted 28-Oct-11 13:50pm
csergio515
Edited 28-Oct-11 13:51pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

For dynamically created controls, you do need to use SetFont as otherwise it will just use the default system font.
 
It's been several years since I did any of this, but I vaguely remember doing this back then: get the font of the parent dialog and use that on the created control (you may need to make a new font object depending on your specific needs).
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 28 Oct 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100