asavard
asked on
CComboBox alignment
Hi!
I'm trying to right align text in a combo box. The checkbox in the properties doesnt seem to change anything at all.
Is it possible to change the alignment of the text?
I'm trying to right align text in a combo box. The checkbox in the properties doesnt seem to change anything at all.
Is it possible to change the alignment of the text?
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Yet another dumb restriction!
Oh well!
Thanks
:)
Oh well!
Thanks
:)
You can do this without using owner-draw.
In your dialog class you will need to get a pointer to the comboBox. You can use CWnd::GetDlgItem to do this.
Then use CWnd::ModifyStyleEx to change the justification.
CWnd * pComboBox = this->GetDlgItem(COMBOBOX_ ID);
pComboBox->ModifyStyleEx(0 ,WS_EX_RIG HT);
This will right align all the text in the box.
In your dialog class you will need to get a pointer to the comboBox. You can use CWnd::GetDlgItem to do this.
Then use CWnd::ModifyStyleEx to change the justification.
CWnd * pComboBox = this->GetDlgItem(COMBOBOX_
pComboBox->ModifyStyleEx(0
This will right align all the text in the box.
I have tested the code in my above comment and it works fine. I'm sure that MikeBlas is very seldom wrong, but I think on this occasion that he is.
I do not have a localised version of Windows.
I'm not going for points here, this is just fyi.
I do not have a localised version of Windows.
I'm not going for points here, this is just fyi.
ASKER
I wish you were right mnewton, but for some reason you are not. I tried what you said above, text is still aligned on the left side of the box.
No biggie.
Thanks
No biggie.
Thanks
Very strange, it definitely works for me.
Oh well, whatever.
Oh well, whatever.
..B ekiM