|
-
Apr 26th, 2010, 05:12 AM
#1
Thread Starter
Member
[RESOLVED] Help how to represent constants in combo?
Hi ,
I hope someone can help. I am writing a tool for myself that modifies some windows how i want it to so that my environment suits me.
I want to know how to convert a string to represent a constant in a function.
Let me explain:
I have a form on which I have two combo boxes, one has the actions i want to perform and the other has the window handles.
ie combo1 has SW_HIDE and combo2 has the window ID on which to call it
I already know how to get window/child handles.
this is the api function I need help with:
<code>
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Call ShowWindow(combo2, combo1.text)
</code>
The show code works fine with:
call Showwindow(handle,SW_HIDE)
but fails as invalid with combo1.text as its a text string and not the actual constant i want it to be.
What I am asking is how to get the choice with minimal code from the combo box to represent the constant?? Ie select SW_HIDE in the combo box for it to be valid in the call showindow function.
This works:
<code>
if combo1.text="SW_HIDE" then
call showwindow(combo2,SW_HIDE)
end if
</code>
but its heavy code when there are lots of choices in the combo box. Therefore the desire to replace the SW_HIDE with a changeable variable.
I hope someone can help, its probably something simple staring me in the face, but has got me stumped!
Thanks
-
Apr 26th, 2010, 05:16 AM
#2
Re: Help how to represent constants in combo?
Combo1.AddItem "SW_HIDE"
Combo1.ItemData(Combo1.NewIndex) = SW_HIDE
Combo1.AddItem "SW_SHOW"
Combo1.ItemData(Combo1.NewIndex) = SW_SHOW
Then use Combo1.ItemData(Combo1.ListIndex) to get the Long value. Also, it is a good idea to set Style property to 2 – Dropdown List
-
Apr 26th, 2010, 10:21 AM
#3
Thread Starter
Member
Re: Help how to represent constants in combo?
Thanks very much Merri,
Works a treat and exactly as i wanted.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|