Solved

How To SendMessageString To A ComboBox in VB 6.0

Posted on 2008-10-18
7
635 Views
Last Modified: 2012-05-05
I can succesfull use the sendmessagestring, WM_SETTEXT to a command button or to a textbox  but i can't get it work to a combobox, What i am doing wrong? Please look at my attached code
Dim nHwnd As Long

Dim statica As Long

Dim nEditHwnd2 As Long

nHwnd = FindWindow(vbNullString, "Profile: s")

statica = FindWindowEx(nHwnd, 0&, vbNullString, "Pre")

nedithwnd2 = FindWindowEx(statica, 0&, "ComboBox", vbNullString)

SendMessageSTRING EditHwnd2, WM_SETTEXT, 0&, ByVal "test1"

Open in new window

0
Comment
Question by:KingSencat
  • 4
  • 3
7 Comments
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 22751690
The reason it's not working isn't your code, just stop for a second and think what you are trying to do. A textbox and a command button both have a property which you could call 'Text', so you are setting that property with the WM_SETTEXT message. A combo box doesn't have a text property as such, it has a list of items which you select.

Try these links...

C++ code for setting and adding combo items: http://en.wikibooks.org/wiki/Windows_Programming/User_Interface_Controls
0
 

Author Comment

by:KingSencat
ID: 22753952
So there is no way to add a new text/item to the combobox?
0
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 22755777
KingSencat, did you even open the link I sent you? It has API to add new items to a combo but WM_SETTEXT is not the way.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:KingSencat
ID: 22773172
sorry i you didnt notice but i am not using c++, just vb
0
 
LVL 10

Expert Comment

by:c0ldfyr3
ID: 22775731
KingSencat, I know you are using VB, I'm trying to get you to use your intuition. If you bothered to READ the page you'd know exactly how to approach this.

API is the same for all languages.
0
 

Author Comment

by:KingSencat
ID: 22784150
I have read the page and i have no idea how i can accomplish it using vb 6.0 , can you do it for me pls?
0
 
LVL 10

Accepted Solution

by:
c0ldfyr3 earned 500 total points
ID: 22790332
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now