TextAlgin if style is Edit Field Only

The place for threads about TimoSoft ComboListBoxControls
Post Reply
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

TextAlgin if style is Edit Field Only

Post by Mex »

Hi Timo!

Is it possible set TextAlign for combobox if style is set to Edit Field Only?
I'v tested with SetTextAlgin API, but this doesnt work


Alles gute;
Meelis
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

It should work if you call GetWindowLong(GWL_STYLE) for the hWndEdit window, set/remove the ES_CENTER/ES_LEFT/ES_RIGHT styles and call SetWindowLong(GWL_STYLE) to apply the changes.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

Hi again


Dim lngStyle As Long
lngStyle = GetWindowLong(ComboBox1.hWndEdit, GWL_STYLE)
SetWindowLong ComboBox1.hWndEdit, GWL_STYLE, lngStyle Or ES_RIGHT


Does not work. Am i doing something wrong?


BR;
Mex
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

Hmm i think if control is created i cant change style anymore at runtime :(?
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

For a normal Edit control the alignment styles may be set and removed after window creation. The combo box uses a normal edit control, so it should work. But it might be that the combo box prevents such changes to the edit control. If this is the case, you are out of luck.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

Ha! I tried it myself. All you need is to force a redraw of the control after you changed the styles.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

Hi

What you mean with "force redraw"?
SendMessage and WM_PAINT?



Mex
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

Calling Refresh should be enough.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

Refresh does not help

Is my code correct in first post?
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

Assuming that you defined the constants and API functions correctly, it is correct, yes.

When I tried it myself on Tuesday, all I needed was to move another window over the control so that it will redraw. I thought that Refresh would be sufficient. Obviously it is not sufficient. Try this:

Code: Select all

Call SetWindowPos(ComboBox1.hWndEdit, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOOWNERZORDER Or SWP_NOZORDER)
If this does not help, try this:

Code: Select all

Call SetWindowPos(ComboBox1.hWndEdit, 0, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOOWNERZORDER Or SWP_NOZORDER Or SWP_FRAMECHANGED)
If this also does not help, you could toggle the Visible property twice, but then the control will flicker.
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

Nope, nothing works :(
User avatar
TiKu
Administrator
Administrator
Posts: 832
Joined: 28 Sep 2004, 21:10
Location: München
Contact:

Re: TextAlgin if style is Edit Field Only

Post by TiKu »

Does your application have Windows skins enabled? I tried on Windows 7 x64 with skins enabled. Maybe it works only if skinning is enabled (Windows loads a newer version of comctl32.dll then).
Crunching for Fab36_Folding-Division at Folding@Home. Join Fab36/Fab30! - Folding@Home and BOINC
Boycott DRM! Boycott HDCP!
User avatar
Mex
Captain
Posts: 130
Joined: 24 Sep 2009, 19:47

Re: TextAlgin if style is Edit Field Only

Post by Mex »

OK
It works with Win 7 but not XP
Post Reply