How can I change the style of a textbox from Spy++ or by writing my own application? Take a look at my Spy++ screenshot to see what it is I'm trying to change.
Printable View
How can I change the style of a textbox from Spy++ or by writing my own application? Take a look at my Spy++ screenshot to see what it is I'm trying to change.
Nobody knows? Not even megatron?
I saw the screenshot, but what does the Style represent? The border of the textbox?
It's also kinda late in the night. :)
The style is the different propertys and stuph, I'm trying to change the locked property and I know the style for a non-locked textbox and for a locked text box.
Aarghhh. Pls try not to be so presumptious. I am sure that megatron would hate u saying this as much as other programmers on this site. Probably the reason that noone has answered is becos we (well at least I) have no idea what u are talking about. Do u want to change the style as in colours? 3d look? what? U mentioned the locked property. Do u want locked boxes to appear diff to non locked ones?Quote:
Originally posted by numtel
Nobody knows? Not even megatron?
Pls rephrase qtn so that ppl can help... and who knows u may even get blessed by a *guru* visiting ur thread.
Regards
Stuart
If you want to get/change the style bits of a window, you use the GetWindowLong or SetWindowLong functions with the constant GWL_STYLE, or GWL_EXSTYLE for extended styles (you need the latter for things like determining if a window is an 'on top' one).
See, one just did. Hold on i didnt mean to say that... can't control fingers. Am typing "Kaverin is a genius".... arrrghhhh.... hhhheeeelppppppp mmmmeeeeeeeeeeeQuote:
Originally posted by beachbum
..and who knows u may even get blessed by a *guru* visiting ur thread.
Well, the reason why I haven't answered yet is because I've never seen this thread before...
Use SetWindowLong. Here's an example that locks or unlocks an edit control (same thing as a textbox). EditHwnd is the handle ( or hWnd) if the control.
VB Code:
'These are the declarations Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Const GWL_STYLE = (-16) Private Const ES_READONLY = &H800& 'This code locks the edit control, or textbox Dim lStyle As Long lStyle = GetWindowLong(EditHwnd, GWL_STYLE) lStyle = lStyle Or ES_READONLY SetWindowLong EditHwnd, GWL_STYLE, lStyle 'This code unlocks it Dim lStyle As Long lStyle = GetWindowLong(EditHwnd, GWL_STYLE) lStyle = lStyle And Not ES_READONLY SetWindowLong EditHwnd, GWL_STYLE, lStyle
Note: When I was testing this on a vb textbox, the property of the textbox would change as expected, but the behavior wasn't changing for some reason. Just figured I'd let you know.
wow, two posts were made in the time it took for me to make my post. Looks like I spent too much time on it..
OK Maybe i am missing something here. but surely numtel would just use the Locked property of the textbox if that was what was required. I was assuming that he wanted the textbox to somehow *look* different if locked. I guess we need to wait for him to repost to clarify
Regards
Stuart
I'm guessing he wants to change it in a textbox outside his app.
I just woke up... The set window long might be what I'm looking for. What I'm trying to do is unlock a Edit control in another application.
Why unlock if the programmer of the program wont let you ^_^
If it takes all this trouble (bruhaha?) to do what you're trying to do, it's probably because someone doesn't want you doing it...
Why does it matter? There are plenty of legitimite reasons to want to change the properties and behavior of controls on other programs.Quote:
Originally posted by DaoK
Why unlock if the programmer of the program wont let you ^_^
That a smile = I dont care lolQuote:
^_^
Oh, I was wondering what that was :D