[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Determine if textbox is multilined

Posted on 2007-03-30
16
Medium Priority
?
329 Views
Last Modified: 2010-08-05
Language:  VB6

Scenario:  I have a handle to a textbox.  I need to determine if that textbox is multi-lined or not.  I've looked here but could not find anything:  http://msdn2.microsoft.com/en-us/library/aa924582.aspx

I'm guessing it would go something like this, if I only knew what flag to us instead of [???].
------------------------------------------------------------------------
Dim lngResult As Long

lngResult = SendMessage(hwndTextbox,  [???], ByVal CLng(0), ByVal CLng(0))
------------------------------------------------------------------------

500 points for a quick answer - thanks!
0
Comment
Question by:enable99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 7
16 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 18825268
Couldnt you just look for a carriage return or line feed?
 If InStr(1, Textbox1.Text, vbCr) > 0 Or InStr(1, Textbox1.Text, vbLf) Then
  'multiline
 Else
  'not multiline
 End If

Or am I missing something?
Matt
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 18825344
if (TextWidth(Text1.Text)>Text1.Width) then
msgbox "it is multi-line"
end if
0
 

Author Comment

by:enable99
ID: 18825347
Matt,

A textbox has a 'Multilined" property.  If this is set to TRUE, the textbox is a multi-lined textbox (even if it contains zero or one line of text).  So although your suggestion works sometime, it will now work all the time.

My goal is to determine if the textbox's Multilined property is true or false.  Any ideas?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:enable99
ID: 18825354
EDDYKT,

Thanks for your post, please see my response to Matt.  (As you notice, I am actively watching this post.)  500 points to the first person to give me a solid answer!  Thanks Experts!
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18825567
Can I assume you ONLY have the handle for the textbox?
If not, couldn't you just use:
 If TextBox1.MultiLine Then

If so, then using your sendmessage api, you should be able to use EM_GETLINECOUNT:

Const EM_GETLINECOUNT As Long = &HBA

'...

If SendMessage(hwndTextbox,  [???], ByVal CLng(0), ByVal CLng(0)) > 1 Then
 'multiline
Else
 'one-line
End if

Matt
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18825684
Ok, after looking up a bit on this, using EM_GETLINECOUNT in place of [???] won't do anything, since using EM_GETLINECOUNT only works on multiline textboxes anyways, and a return value of 1 would just mean there is only 1 line in that multiline textbox (as it won't return 0 if not multiline or anything).
I'm sorry, I think I will have to bow out of this question, I'm sure EDDYKT or someone else will be able to help. I'll take a look further, but if you can't just test the object's .multiline property then I'm not sure how I'd be able to help.
0
 

Author Comment

by:enable99
ID: 18825861
mvidas,

Thanks for your posts.  Yes, I only have the handle because the textbox resides in another application (not in mine).  Perhaps theres a call to get some property from a multi-lined textbox that FAILS if it is NOT a multi-lined textbox.  This failure/error could be used to determine if the textbox is multi-lined.

Still needing help from someone!  500 points is a-wait-'in!  Thanks Experts!
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18825939
As I don't have VB6 where I am now I cannot test this (I only have VBA here), perhaps you could make 2 simple exe's with forms, one with multiline=true and the other with multiline=false, and see what gets returned using SendMessage from both?
Matt
0
 

Author Comment

by:enable99
ID: 18826052
mvidas,

That is exactly what I've tried (good suggestion) but everything returns the same regardless of wether the textbox is multi-lined or not.  

AH:  Check this out:  http://msdn2.microsoft.com/en-us/library/aa930492.aspx

How would I get the ES_MULTILINE style?  I bet this is the answer...  500 points to someone who can give me the code - I can't seem to get it to work using SendMessage().  Perhaps I need a different API call??
0
 
LVL 35

Accepted Solution

by:
mvidas earned 2000 total points
ID: 18826154
I thought about that too, but without testing all I can do is guess at what to do with the code. What about something like:

'declarations:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
  ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Const GWL_STYLE As Long = -16&
Private Const ES_MULTILINE = &H4

'then use the code
 Dim WStyle As Long
 WStyle = GetWindowLong(hwndTextbox, GWL_STYLE)
 MsgBox WStyle And ES_MULTILINE

Try using that on your two text forms/textboxes? Again, just a guess, but trying to get an answer for you
0
 

Author Comment

by:enable99
ID: 18826440
mvidas,

Let me try that now and I'll report back...
0
 

Author Comment

by:enable99
ID: 18826485
<b>Ding!  Ding!  Ding!   We have a winner!</b>

<b>Thanks for your persistance mvidas!</b>
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18826498
Great! I had read tons of things about using setwindowlong to create a new multiline textbox (since the property is readonly at runtime), so I hoped getwindowlong would work for it. The syntax was my only issue. Glad to help!
I really need vb6 at work :(
0
 
LVL 35

Expert Comment

by:mvidas
ID: 18826525
I'm afraid I'd have even less of an idea what to do there. EDDYKT is pretty clever, so if he is still subscribed here hopefully he'll check it out (at least I've always assumed EDDYKT was a he)
Matt
0
 

Author Comment

by:enable99
ID: 18826602
mvidas,

Thanks anyways.
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is about my first experience with programming Arduino.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question