How to align the item text in the combobox vertically centred after increasing the height of the combobox in mfc?
I want to make the item text of the combobox to be aligned vertically(Centred) . Actually I increased the height
of the combobox and after the increasing the combobox height, the text is not centred vertically.The code
snippet for increasing the height is as follows,
m_SpecifyCombo.SetItemHeight(-1,20);//CCombobox m_SpecifyCombo
After increasing the height the text in the combobox is not in the centre as shown in the below image,
But I want the text to be centred as shown in the below image.
Code snippet for owner drawn combobox:
#if !defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)
#define AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
typedef enum {FONTS} STYLE; //Why have I enumerated, Cos, Maybe I might want something other than Fonts here
class COwnerDrawCombo : public CComboBox
// Construction
public:
COwnerDrawCombo();
COwnerDrawCombo (STYLE);
// Attributes
public:
void SetHilightColors (COLORREF hilight,COLORREF hilightText)
m_clrHilight = hilight;
m_clrHilightText = hilightText;
void SetNormalColors (COLORREF clrBkgnd,COLORREF clrText)
m_clrNormalText = clrText;
m_clrBkgnd = clrBkgnd;
static BOOL CALLBACK EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData);
void FillFonts ();
int GetSelFont (LOGFONT&);
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CCustComboBox)
public:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~COwnerDrawCombo();
// Generated message map functions
protected:
STYLE m_enStyle;
COLORREF m_clrHilight;
COLORREF m_clrNormalText;
COLORREF m_clrHilightText;
COLORREF m_clrBkgnd;
BOOL m_bInitOver;
void DrawDefault (LPDRAWITEMSTRUCT);
void DrawFont(LPDRAWITEMSTRUCT);
void InitFonts ();
//{{AFX_MSG(CCustComboBox)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnDestroy();
//}}AFX_MSG
afx_msg long OnInitFonts (WPARAM, LPARAM);
DECLARE_MESSAGE_MAP()
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
#endif //!defined(AFX_CUSTCOMBOBOX_H__F8528B4F_396E_11D1_9384_00A0248F6145__INCLUDED_)
// OwnerDrawCombo.cpp : implementation file
#include "stdafx.h"
#include "combobox.h"
#include "OwnerDrawCombo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define WM_INITFONTS (WM_USER + 123)
//I chose 123 cos nobody might use the same exact number.. I can improve this by use RegisterWindowMessage..
// COwnerDrawCombo
//Initial values of the text and highlight stuff
COwnerDrawCombo::COwnerDrawCombo()
m_enStyle = FONTS;
m_clrHilight = GetSysColor (COLOR_HIGHLIGHT);
m_clrNormalText = GetSysColor (COLOR_WINDOWTEXT);
m_clrHilightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
m_clrBkgnd = GetSysColor (COLOR_WINDOW);
m_bInitOver = FALSE;
COwnerDrawCombo::COwnerDrawCombo (STYLE enStyle)
m_enStyle = enStyle;
m_clrHilight = GetSysColor (COLOR_HIGHLIGHT);
m_clrNormalText = GetSysColor (COLOR_WINDOWTEXT);
m_clrHilightText = GetSysColor (COLOR_HIGHLIGHTTEXT);
m_clrBkgnd = GetSysColor (COLOR_WINDOW);
m_bInitOver =FALSE;
COwnerDrawCombo::~COwnerDrawCombo()
BEGIN_MESSAGE_MAP(COwnerDrawCombo, CComboBox)
//{{AFX_MSG_MAP(COwnerDrawCombo)
ON_WM_CREATE()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
ON_MESSAGE (WM_INITFONTS,OnInitFonts)
END_MESSAGE_MAP()
// COwnerDrawCombo message handlers
void COwnerDrawCombo::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
//I might want to add something else someday
switch (m_enStyle)
case FONTS:
DrawFont(lpDrawItemStruct);
break;
//I dont need the MeasureItem to do anything. Whatever the system says, it stays
void COwnerDrawCombo::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
void COwnerDrawCombo::DrawFont(LPDRAWITEMSTRUCT lpDIS)
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
CRect rect;
TRACE0 ("In Draw Font\n");
// draw the colored rectangle portion
rect.CopyRect(&lpDIS->rcItem);
pDC->SetBkMode( TRANSPARENT );
if (lpDIS->itemState & ODS_SELECTED)
pDC->FillSolidRect (rect,m_clrHilight);
pDC->SetTextColor (m_clrHilightText);
else
pDC->FillSolidRect (rect,m_clrBkgnd);
pDC->SetTextColor (m_clrNormalText);
if ((int)(lpDIS->itemID) < 0) // Well its negetive so no need to draw text
else
CString strText;
GetLBText (lpDIS->itemID,strText);
CFont newFont;
CFont *pOldFont;
((LOGFONT*)lpDIS->itemData)->lfHeight = 90; //9 point size
((LOGFONT*)lpDIS->itemData)->lfWidth = 0;
newFont.CreatePointFontIndirect ((LOGFONT*)lpDIS->itemData);
pOldFont = pDC->SelectObject (&newFont);
pDC->DrawText(strText, rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
pDC->SelectObject (pOldFont);
newFont.DeleteObject ();
void COwnerDrawCombo::InitFonts ()
CDC *pDC = GetDC ();
ResetContent (); //Delete whatever is there
EnumFonts (pDC->GetSafeHdc(),NULL,(FONTENUMPROC) EnumFontProc,(LPARAM)this);//Enumerate
m_bInitOver = TRUE;
BOOL CALLBACK COwnerDrawCombo::EnumFontProc (LPLOGFONT lplf, LPTEXTMETRIC lptm, DWORD dwType, LPARAM lpData)
if (dwType == TRUETYPE_FONTTYPE) //Add only TTF fellows, If you want you can change it to check for others
int index = ((COwnerDrawCombo *) lpData)->AddString(lplf->lfFaceName);
LPLOGFONT lpLF;
lpLF = new LOGFONT;
CopyMemory ((PVOID) lpLF,(CONST VOID *) lplf,sizeof (LOGFONT));
((COwnerDrawCombo *) lpData)->SetItemData (index,(DWORD) lpLF);
return TRUE;
int COwnerDrawCombo::OnCreate(LPCREATESTRUCT lpCreateStruct)
if (CComboBox::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
if (m_enStyle == FONTS)
//SetItemHeight(-1,30);
PostMessage (WM_INITFONTS,0,0);
return 0;
long COwnerDrawCombo::OnInitFonts (WPARAM, LPARAM)
InitFonts ();
return 0L;
void COwnerDrawCombo::OnDestroy()
if (m_enStyle == FONTS)
int nCount;
nCount = GetCount ();
for (int i = 0; i < nCount; i++)
delete ((LOGFONT*)GetItemData (i)); //delete the LOGFONTS actually created..
// TODO: Add your message handler code here
CComboBox::OnDestroy();
void COwnerDrawCombo::FillFonts ()
m_enStyle = FONTS;
PostMessage (WM_INITFONTS,0,0); //Process in one place
int COwnerDrawCombo::GetSelFont (LOGFONT& lf)
int index = GetCurSel ();
if (index == LB_ERR)
return LB_ERR;
LPLOGFONT lpLF = (LPLOGFONT) GetItemData (index);
CopyMemory ((PVOID)&lf, (CONST VOID *) lpLF, sizeof (LOGFONT));
return index; //return the index here.. Maybe the user needs it:-)
void COwnerDrawCombo::PreSubclassWindow()
// TODO: Add your specialized code here and/or call the base class
//Tried to do what Roger Onslow did for the button.. Did not work..?? Any R&D guys around :-)
Can anyone please let me know how can I achieve this.
Any help can be appreciated.
Thanks in advance
SivaV
Hi sivavuyyuru,
I cannot find a easy way to make this.
I think you may need to draw your own Combo Box control. And you could change the edit control more like static text. Check the article:
http://www.codeguru.com/cpp/controls/combobox/fontselectioncombos/article.php/c1795/Owner-Drawn-Font-Selection-Combobox.htm
In the resource editor, Owner draw -> variable , Has string->true, type->drop list.
The result:
Best regards,
Shu Hu
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.
Similar Messages
-
How to retrieve the item text from VL03 transaction .
How to retrieve the item text from VL03 transaction .
The requirement is like this, the item text thus retrieved should be printed in the script under the item.Jagadieshwar,
Use <b>READ_TEXT</b> function module to get the proper item text of Delivery.
<b>ID</b>: Probably you want 0002 (Item Note), but it depends which text you want Item Note, Material Sales Text ,etc..
<b>NAME</b>: CONCATENATE Delivery Doc. Number + Delivery Item Number (e.g. 0080001729000010)
<b>OBJECT</b>: VBBP
<b>
LANGUAGE</b>: sy-langu or whatever you want. -
The payment request do not transfer the Item Text field to FI doc
The payment request do not transfer the Item Text (SGTXT) field to FI documents (accounting document) when they are paid by F111 and the payment request is created from repetitive codes (Trx FRFT_B). Therefore is not able to display a text description in the FI line items accounts, even the payment request document number is not available in the accounting document.
Even the program SAPLKKBL (F8BT) does not contain available the Accounting document.
So, there is not easy trace.
Does anybody know how can I match this?This is the SAP Response:
Dear customer,
The standard FRFT_B transaction does not directly or indirectly pass
the text to the F111 payment document since the initial program design.
In other words, you will not able to experience the reported issue
in the system with standard SAP coding.
However, the text value can be passed via business transaction event
(BTE) for example or other modifications as a substitution.
I hope this confirmation of the standard system behaviour is
useful to you.
I regret not to be able to give you a positive answer. -
The bookmarks toolbar is there but has no item buttons on it. How do I get the items back for this toolbar?
Also would like to know if the toolbar can be put on the same line to make more room on the page (drag & drop) ?? Like the menu & bookmarks toolbar could/should fit on same line. This would add more page view...
Floyd Perry
ThanksCheck that you still have the "Bookmarks Toolbar items" placed on the Bookmarks Toolbar
* Make sure that you have the "Bookmarks Toolbar" visible: "View > Toolbars"
* Check in "View > Toolbars > Customize" that the "Bookmarks Toolbar items" is on the Bookmarks Toolbar
* If the "Bookmarks Toolbar items" is not on the Bookmarks Toolbar then drag it back from the Customize window onto the Bookmarks Toolbar
* If you do not see the "Bookmarks Toolbar items" then click the "Restore Default Set" button
You can only move the content from a toolbar onto other toolbars if all toolbars support that feature. You need to check that in the options of each toolbar. -
Copying the item text in case of multiple line items
Hi All,
I have a scenario where the sales order gets created in our SAP through a 850 idoc. The incoming idoc has only one item segment which carries the total order quantity ( for example say 1000). Since my company has contractual agreements with the end customer for doing multiple shipments , our sales department splits the total quantity into multiple line items in the sales order. Say splitting the 1000 quantities into 5 line items of 200 each.
The problem here is that when the sales order got created , all the related item text were copied only to the first line item ( of 1000 qty) and which is standard SAP. Since the order quantity was manually split, the related item text are not carried to the subsequent line items. The issue comes when an outbound (810) idoc is sent to customer . As I told earlier since only the first line item has the item text , the 810 idoc which was created for the first line item only has the item text . The rest of the 810 which were subsequently created for multiple shipments/invoices on different dates didn't have the item text in the 810's. This is becoming a major problem as the 810 files are failing at our trading partners end because of missing text.
Now my question is, Is there a way that I can make the item text copy automatically when multiple line items are created manually by business. Like is there a way where I can modify MV45AFZZ to copy the item text in their respective segemnts ( z003,z004 etc) to "N" number of line items.
Also please suggest if there is a better way of doing it. Suggstions are most welcome !!!.
Regards
AmrithHi,
First of all try to avoid doing select into corresponding fields. THis would improve the performance of the program.
Try to do a single fetch from the BSIS table . fetch the hkont, belnr, dmbtr fields in to a master internal table. Manipulate and play with the data as required. Don't hit the data base table more than once (unless it is required) . This would improve the performance of your code.
Try to code this way.
types: begin of ty_bsis,
hkont type hkont,
belnr type belnr_d,
dmbtr type dmbtr,
end of ty_bsis.
data: it_bsis type standard table of ty_bsis,
wa_bsis type ty_bsis,
select hkont belnr dmbtr
from bsis
into table it_bsis
WHERE HKONT IN S_RACCT
AND PRCTR IN P_PRCTR
AND MONAT IN S_POPER
AND BUKRS EQ P_BUKRS
AND GJAHR EQ P_GJAHR
AND PRCTR IN S_PRCTR.
Using the data availabe in the it_bsis, you can manipulate as required.
Hope this would be helpful
Regards
Ramesh Sundaram -
Enhancement for VL02N to update the item text(BSEG-SGTXT) during PGI
Hello all,
Actually, I need your help experts. I am trying to update the item text(BSEG-SGTXT) for accounting documents with the sales order number during their creation(post goods issue) from transaction VL02N, VL01N, VL09.
I have checked the 17 exits available for these transactions and non of these 17 exits allow me to modify the item text(BSEG-SGTXT). I am currently investigating on the two badi's available for these transactions.
I am not sure if it possible to make these modifications via Badi's.
Does anyone have any idea or technique that can help me to find a way to modify/update the item text(BSEG-SGTXT) for any accounting document generated during post goods issue using transaction VL02N, VL01N, VL09?
Thanks a lot in advance for your help experts.
Kind Regards,
BryanHello Ankur Agrawal,
Thanks a lot for your help.
I got the item text from the mentioned BADI. I will get back to this post if it works.
Thank again for your quick reply.
Kind Regards,
Bryan -
Dear All,
I had come across one issue.
In the Purchase order print i am printing the item text and also the header text.
But in this if it is having the symbol " & " then the text after the "&" symbol was not printing.
After that symbol it was skipping.
Can anyone help me in this.Hi,
'&' is used for priting variable's values e.g suppose there is a variabel 'lv_var' and if i want to print the value of it in script i have
to write code as '&LV_VAR&' (& in the start and end of the variable name), and this is why the text after '&' in your line item, is
not getting printed.
To resolve this issue just replace '&' with 'and' (hope is is being used for AND).
Regards,
Raj Gupta -
PR Short text getting copied to the Item text
Hi All,
I have a scenario in which i need the PR short text getting copied to the Item text while creating a PR. Please let me know if there are any settings for the same.
Thanks,PR short text you mean line item short text field beside material is getting copied?, in such cases make sure that Item text copying rule. from where its getting copied from SPRO>Material Management> purchasing>PR>Texts for Purchase Requisitions >Define Copying Rules.
regards,
qsm sap -
Firefox could not install this item because "install.rdf" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem.
Well that is the message i get. I can still use firefox(version3.6.8)You get that error if an extension is using an old and no longer supported method to install a plugin.
Which plugin are you trying to install?
See also http://kb.mozillazine.org/Unable_to_install_themes_or_extensions -
Firefox could not install this item because "install.rdf" (provided by the item) is not well-formed or does not exist. Please contact the author about this problem.
The statement above is in the pop up error box every time, when I launch Firefox. If I click ok in the box Firefox then opens. How do I fix this initializing/launch problem?Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).<br />
See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
If it does work in Safe-mode then disable all your extensions and then try to find which is causing it by enabling one at a time until the problem reappears.<br />
You can use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.<br />
You have to close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")<br /> -
How come, when I add myYahoo! email account to MAIL, after verifying, I always get the "server unavailable. please try again later"
THANKS! this worked !!!
I hit "DELETE THIS ACCOUNT" on my iphone (this is the Yahoo I tried to set up by "picking" it from the list that the iphone5 gives you) and then confirmed to delete everything.
THEN: while in Mail (still in the Settings Section) I tapped on "ADD ACCOUNT..." but this time tapped on "OTHER" and manually put in my yahoo ID and password and I did not even have to go to the SMTP or IMAP incomming/outgoing stuff at all. But I checked it out under the "ADVANCE" tab and it was already correct for yahoo. (ALMOST SEEMED TOO EASY)
Went to my home screen and tapped on MAIL and my yahoo email loaded up just right!
Now, I have no idea if I have any other issues like if I delete mail on the iphone; does it delete properly on my ipad...etc..etc. but one problem at a time is getting fixed. THANKS! -
onjour
j ai des probleme au demarage d iphoto le dialogue s affiche et me demande le texte suivant ?
138 photos n’ayant pas été importées ont été trouvées dans la bibliothèque iPhoto.
Souhaitez-vous les importer ? oui ou non avez vous deja rencontrer ce proble si oui pouvez vous m aider
Merci
Hello
J have problem in the demarage d iphoto the dialogue displays and asks me for the following text?
138 photos not having been imported were found in the iPhoto library(bookcase).
Would you care for import them? Yes or no you already have meet this prowheat if yes can you m help
Thank youOpen your iPhoto Library package with the Finder as shown in this screenshot
and look in the folder named Auto Import. Move any files in that folder to a folder on the Desktop and close the package. Do not make any other changes. Launch iPhoto (the message should be gone) and drag the folder on the Dersktop into the open iPhoto window to import them.
OT -
I accidentally deleted part of an iphone (4s) note. Is there a way to restore the deleted text? I learned too late about being able to shake the iphone in order to undo my action, so is there any other way?
Restoring a phone from a backup will put the device back to the state it was when the backup took place, i.e. all info that you had on that phone before using the backup will be gone.
You could try to restore the phone, which will back up the actual data on the phone, including the passcode, and use this backup to set up a new phone with. The passcode will still be the same, because it is part of the backup.
More info here, iPhone and iPod touch: Wrong passcode results in red disabled screen
Not being able to fill in the passcode is not much different from forgetting it.
If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup). If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present. Refer to Updating and restoring iPhone, iPad and iPod touch software.
Also have a look at this one: iTunes: About iOS backups -
Hello
I am trying to install the latest itunes software to my computer. After installing I keep receiving the error messages. Runtime error.
Please see the screen capture of the error messages.
Please help, Thank you
Ab MajidSee Troubleshooting issues with iTunes for Windows updates.
tt2 -
Bootcamp won't launch, I've been getting the message "quit unexpectedly". This started happening after I erased "pre" from the code now I can't open it any more. What should I do?
Please try
sudo codesign --deep -fs - /Applications/Utilities/Boot\ Camp\ Assistant.app
Maybe you are looking for
-
Preview and print..
i trying to make my system have preview and print button... preview button--> how can i make it?? if i want to preview it in a text file and with a specific format. --> any sample or tutorial i can follow to learn this?? --> can i used JEditorPane fo
-
Stock in Quality can not be cleared throgh Transfer posting.
Dear All, i am facing one problem, i,e i deactivated the all inspection types in the material master and QM proc. key and control key are in active position. by default whenever i do MIGO. system is proposing Quality inspection stock. Same think happ
-
Hi gurus, I am facing the problem please help When viewing When viewing commitment line items and actual/plan/commitment reports in CO, there appears to be a difference between the two. I have executed transaction KSB2 with the following parameters:
-
Problem with hp photo creations
Hi! i'm trying to use the premium settings and the program is keeping showing me the window to registrer or sign in (i alredy bought this function). My emal is [Personal Information Removed]
-
This does not allow me to buy any purchases on the iPad